Add Shared Parameter to Project

Original Topic

About the original topic of the discussion. I just realized that the problem is that im working with new version API 2016 so the code has changed.

@bikashseas @kiknchikn2060

So in the end it worked with this solution that i found in this post:

http://dynamobim.org/forums/topic/shared-parameter-creation-from-list/

Code modified from the Python.Script of the custom node Add Shared Parameter to Project from Archi-lab:

def addParam(doc, _paramName, _visible, _instance, _groupName, _paramGroup):
	message = None
	if ParamBindingExists(doc, _paramName, _paramType):
		if not RemoveParamBinding(doc, _paramName, _paramType) == "Success":
			message = "Param Binding Not Removed Successfully"
		else:
			message = None
			
	group = file.Groups.get_Item(_groupName)
	if group == None:
		group = file.Groups.Create(_groupName)	

	if group.Definitions.Contains(group.Definitions.Item[_paramName]):
		_def = group.Definitions.Item[_paramName]
	else:
###		_def = group.Definitions.Create(_paramName, _paramType, _visible)
		opt = ExternalDefinitionCreationOptions(_paramName, _paramType)
		opt.Visible = _visible;
		_def = group.Definitions.Create(opt)
		
	param = doc.ParameterBindings.Insert(_def, bind, _paramGroup)
	return message

Thanks a lot for you help and time.

1 Like