app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document
cats = doc.Settings.Categories
cat_sheets = cats.get_Item(BuiltInCategory.OST_Sheets)
cat_views = cats.get_Item(BuiltInCategory.OST_Views)
cat_set = app.Create.NewCategorySet()
cat_set.Insert(cat_sheets)
cat_set.Insert(cat_views)
sp_file = app.OpenSharedParameterFile()
sp_groups = sp_file.Groups
t = Transaction(doc, 'Add Shared Parameters')
t.Start()
for d_group in sp_groups:
for p_def in d_group.Definitions:
if 'PS_' in p_def.Name:
print('Adding Parameter: {}'.format(p_def.Name))
new_instance_binding = app.Create.NewInstanceBinding(cat_set)
doc.ParameterBindings.Insert( p_def,
new_instance_binding,
BuiltInParameterGroup.PG_TEXT)
t.Commit()