Batch export shared parameters

This was actually a lot simpler than I thought. See below:

import System
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

param_name = IN[0]
param_guid = IN[1]
param_type = ParameterType.Text
group_name = IN[3]

definition_file = app.OpenSharedParameterFile()
definition_groups = definition_file.Groups

for group in definition_groups:
	if group.Name == group_name:
		ops = ExternalDefinitionCreationOptions(param_name, param_type)
		# Construct a Guid from a string
		ops.GUID = System.Guid(param_guid)
		group.Definitions.Create(ops)

I haven’t implemented any loops or exception handling in the above code, so if a parameter by the given name is already in the parameter group or if the GUID is already in use, it will raise an exception. I have also hard-coded the ParameterType for now since I’m not sure if your node is passing the actual ParameterType or just the name of it.

1 Like