Hey @shuvro.arc , I don’t know if you have found the solution to your problem. I have recently noticed you post and I came with this script as a solution to add shared parameters to the project. It works for one paramater to one category as well as multiple parameter to multiple parameters.
# -*- coding: utf-8 -*-
# Created by Vasile Corjan
import System
from System import Enum
from pyrevit import forms, script, DB, revit
from category_lists import category_names_type, category_names_instance, built_in_parameter_group
# Get all categories and built-in parameter groups
app = __revit__.Application
doc = revit.doc
all_categories = [category for category in doc.Settings.Categories]
built_in_parameter_groups = [group for group in System.Enum.GetValues(DB.BuiltInParameterGroup)]
built_in_parameter_group_names = [DB.LabelUtils.GetLabelFor(n) for n in built_in_parameter_groups]
# Get the shared parameter file and its groups
sp_file = app.OpenSharedParameterFile()
sp_groups = sp_file.Groups
dict_pg = {g.Name:g for g in sp_groups}
# Select the parameter group
parameter_groups_dict = forms.SelectFromList.show(sorted(dict_pg),
title='Select the Parameter Group',
multiselect=False,
button_name='Select')
if not parameter_groups_dict:
script.exit()
# Select the parameter
definitions = dict_pg.get(parameter_groups_dict).Definitions
parameter_definitions_dict = {d.Name:d for d in definitions}
selected_parameters_names = forms.SelectFromList.show(sorted(parameter_definitions_dict),
title='Select the Parameter',
multiselect=True,
button_name='Select')
if not selected_parameters_names:
script.exit()
parameter_definitions = [parameter_definitions_dict.get(s) for s in selected_parameters_names]
# Select the built-in parameter group
selected_parameters = forms.SelectFromList.show(sorted(built_in_parameter_group),
title='Select the parameters',
multiselect=False,
button_name='Select')
if selected_parameters in built_in_parameter_group_names:
parameter = built_in_parameter_groups[built_in_parameter_group_names.index(selected_parameters)]
else:
None
# Select the binding type (Type or Instance)
bindings = ["Type","Instance"]
selected_binding = forms.SelectFromList.show(bindings,
title='Select the binding type',
multiselect=False,
button_name='Select')
if not selected_binding:
script.exit()
# Get the category names based on the selected binding type
if selected_binding == "Type":
category_names = sorted(category_names_type)
else:
category_names = sorted(category_names_instance)
selected_categories = forms.SelectFromList.show(category_names,
title='Select the category',
multiselect=True,
button_name='Select')
if not selected_categories:
script.exit()
categories = [c for c in all_categories if c.Name in selected_categories]
built_in_categories = [bic.BuiltInCategory for bic in categories]
# Adding the parameter
with revit.Transaction("Add Parameter"):
category_set = app.Create.NewCategorySet()
for bic in built_in_categories:
category_set.Insert(DB.Category.GetCategory(doc,bic))
if selected_binding == "Type":
binding = app.Create.NewTypeBinding(category_set)
else:
binding = app.Create.NewInstanceBinding(category_set)
for param_def in parameter_definitions:
doc.ParameterBindings.Insert(param_def, binding, parameter)
Also I have done the work to filter the categories based on type/instance parameter in a separate file.
category_names_type = ["Air Terminals", "Analytical Links","Analytical Pipe Connections","Assemblies", "Audio Visual Devices","Cable Tray Fittings", "Cable Tray Runs", "Cable Trays", "Casework", "Ceilings", "Columns", "Communication Devices", "Conduit Fittings", "Conduit Runs", "Conduits", "Curtain Panels", "Curtain Systems", "Curtain Wall Mullions", "Data Devices", "Detail Items", "Doors", "Duct Accessories", "Duct Fittings", "Duct Insulations",
"Duct Linings", "Duct Placeholders", "Duct Systems", "Ducts", "Electrical Equipment", "Electrical Fixtures", "Entourage", "Fire Alarm Devices", "Fire Protection", "Flex Ducts", "Flex Pipes", "Floors", "Food Service Equipment", "Furniture", "Furniture Systems", "Generic Models", "Grids", "Hardscape", "Levels", "Lighting Devices", "Lighting Fixtures","Mass", "Mechanical Control Devices", "Mechanical Equipment", "Mechanical Equipment Sets", "Medical Equipment", "MEP Fabrication Containment", "MEP Fabrication Ductwork", "MEP Fabrication Hangers", "MEP Fabrication Pipework", "Model Groups", "Nurse Call Devices", "Parking",
"Pipe Accessories", "Pipe Fittings", "Pipe Insulations", "Pipe Placeholders", "Pipes", "Piping Systems", "Planting", "Plumbing Equipment", "Plumbing Fixtures", "RVT Links", "Railings", "Ramps", "Rebar Shape", "Roads", "Roofs", "Security Devices", "Signage", "Site", "Specialty Equipment", "Sprinklers", "Stairs", "Structural Area Reinforcement", "Structural Beam Systems", "Structural Columns", "Structural Connections", "Structural Fabric Areas", "Structural Fabric Reinforcement", "Structural Foundations", "Structural Framing", "Structural Path Reinforcement", "Structural Rebar", "Structural Rebar Couplers", "Structural Stiffeners", "Structural Trusses", "Telephone Devices", "Temporary Structures", "Topography", "Vertical Circulation", "Walls", "Windows", "Wires"]
category_names_instance = ["Air Systems", "Air Terminals", "Analytical Links", "Analytical Members", "Analytical Nodes", "Analytical Openings", "Analytical Panels", "Analytical Pipe Connections", "Analytical Spaces", "Analytical Surfaces", "Areas", "Assemblies", "Audio Visual Devices",
"Cable Tray Fittings", "Cable Tray Runs", "Cable Trays", "Casework", "Ceilings", "Columns", "Communication Devices", "Conduit Fittings", "Conduit Runs", "Conduits", "Curtain Panels", "Curtain Systems", "Curtain Wall Mullions", "Data Devices", "Detail Items", "Doors",
"Duct Accessories", "Duct Fittings", "Duct Insulations", "Duct Linings", "Duct Placeholders", "Duct Systems", "Ducts", "Electrical Analytical Bus", "Electrical Analytical Loads", "Electrical Analytical Power Source", "Electrical Analytical Transfer Switch",
"Electrical Analytical Transformer", "Electrical Circuits", "Electrical Equipment", "Electrical Fixtures", "Electrical Load Areas", "Entourage", "Fire Alarm Devices", "Fire Protection", "Flex Ducts", "Flex Pipes", "Floors", "Food Service Equipment", "Furniture", "Furniture Systems", "Generic Models", "Grids", "HVAC Zones", "Hardscape", "Levels", "Lighting Devices", "Lighting Fixtures", "MEP Fabrication Containment", "MEP Fabrication Ductwork", "MEP Fabrication Hangers", "MEP Fabrication Pipework", "Mass", "Materials", "Mechanical Control Devices", "Mechanical Equipment", "Mechanical Equipment Sets", "Medical Equipment", "Model Groups", "Nurse Call Devices", "Parking", "Parts", "Pipe Accessories", "Pipe Fittings", "Pipe Insulations", "Pipe Placeholders", "Pipes", "Piping Systems", "Planting", "Plumbing Equipment", "Plumbing Fixtures", "Project Information", "RVT Links", "Railings", "Ramps", "Rebar Shape", "Roads", "Roofs", "Rooms", "Schedules", "Security Devices", "Shaft Openings", "Sheets", "Signage", "Site", "Spaces", "Specialty Equipment", "Sprinklers", "Stairs", "Structural Area Reinforcement", "Structural Beam Systems", "Structural Columns", "Structural Connections", "Structural Fabric Areas", "Structural Fabric Reinforcement", "Structural Foundations", "Structural Framing", "Structural Path Reinforcement", "Structural Rebar", "Structural Rebar Couplers", "Structural Stiffeners", "Structural Trusses", "Switch System", "System-Zones", "Telephone Devices", "Temporary Structures", "Topography", "Vertical Circulation", "Views", "Walls", "Water Loops", "Windows", "Wires", "Zone Equipment"]
built_in_parameter_group = ["Analysis Results", "Analytical Alignment", "Analytical Model", "Constraints", "Construction",
"Data", "Dimensions", "Division Geometry", "Electrical", "Electrical - Circuiting", "Electrical - Lighting", "Electrical - Loads",
"Electrical Analysis", "Fire Protection", "Forces", "General", "Graphics", "Green Building Properties", "Identity Data",
"IFC Parameters", "Layers", "Life Safety", "Materials and Finishes", "Mechanical", "Mechanical Flow", "Mechanical Loads",
"Model Properties", "Moments", "Other", "Overall Legend", "Phasing", "Photometrics", "Plumbing", "Primary End", "Rebar Set", "Releases / Member Forces",
"Secondary End", "Segments and Fittings", "Set", "Slab Shape Edit", "Structural", "Structural Analysis", "Text", "Title Text", "Visibility"]
I hope it will be useful!