# Add shared Parameters to Revit Document, NOT For Current Document

**URL:** <https://forum.dynamobim.com/t/add-shared-parameters-to-revit-document-not-for-current-document/53782>\
**Category:** Developers\
**Created:** [August 6, 2020, 11:54am UTC](https://forum.dynamobim.com/t/add-shared-parameters-to-revit-document-not-for-current-document/53782 "2020-08-06T11:54:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdallahzakaria](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/abdallahzakaria/32/99152_2.png) [@abdallahzakaria](https://forum.dynamobim.com/u/abdallahzakaria)\
**Post date:** [August 6, 2020, 11:54am UTC](https://forum.dynamobim.com/t/add-shared-parameters-to-revit-document-not-for-current-document/53782/1 "2020-08-06T11:54:30Z")

</div>

Hii, Everyone,  
I’m trying to edit the node of “Add Shared Parameters to Project” from Archi Lab Package in order to make it applicable for any Un-opened Revit model ( for Example Linked Models), so what I’ve done is adding a document input to the custom node. the node works fine but the problem is that it creates the parameters in current project not in linked model however i customized the node to work on document not in current project, I just would like to know what is the problem with the below script that leads to that

```
    import clr
    clr.AddReference('ProtoGeometry')
    from Autodesk.DesignScript.Geometry import *

    # Import DocumentManager and TransactionManager
    clr.AddReference("RevitServices")
    import RevitServices
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager

    # Import RevitAPI
    clr.AddReference("RevitAPI")
    import Autodesk
    from Autodesk.Revit.DB import *

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

    from System.Collections.Generic import *

    # Import ToDSType(bool) extension method
    clr.AddReference("RevitNodes")
    import Revit
    clr.ImportExtensions(Revit.Elements)
    import System
    #The inputs to this node will be stored as a list in the IN variable.
    dataEnteringNode = IN

    _paramName = IN[0]
    _groupName = IN[1]
    _paramType = IN[2]
    _visible = IN[3]
    _category = IN[4]
    _paramGroup = IN[5]
    _instance = IN[6]

    inputdocs = UnwrapElement(IN[7]) if isinstance(IN[7],list) else [UnwrapElement(IN[7])]
    inputdoc=inputdocs[0]

    #Part of script from Clockwork
    if inputdoc == None:
    	doc = DocumentManager.Instance.CurrentDBDocument
    elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document":
    	doc = inputdoc
    else: doc = DocumentManager.Instance.CurrentDBDocument

    def ParamBindingExists(_doc, _paramName, _paramType):
    	map = doc.ParameterBindings
    	iterator = map.ForwardIterator()
    	iterator.Reset()
    	while iterator.MoveNext():
    		if iterator.Key != None and iterator.Key.Name == _paramName and iterator.Key.ParameterType == _paramType:
    			paramExists = True
    			break
    		else:
    			paramExists = False
    	return paramExists

    def RemoveParamBinding(_doc, _paramName, _paramType):
    	map = doc.ParameterBindings
    	iterator = map.ForwardIterator()
    	iterator.Reset()
    	while iterator.MoveNext():
    		if iterator.Key != None and iterator.Key.Name == _paramName and iterator.Key.ParameterType == _paramType:
    			definition = iterator.Key
    			break
    	message = None
    	if definition != None:
    		map.Remove(definition)
    		message = "Success"
    	return message

    def addParam(doc, _paramName, _paramType, _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 = app.OpenSharedParameterFile().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:
    		opt = ExternalDefinitionCreationOptions(_paramName, _paramType)
    		opt.Visible = _visible
    		_def = group.Definitions.Create(opt)
    	
    	param = doc.ParameterBindings.Insert(_def, bind, _paramGroup)
    	return message
    #"Start" the transaction
    TransactionManager.Instance.EnsureInTransaction(doc)

    try:
    	file = app.OpenSharedParameterFile()
    except:
    	message = "No Shared Parameter file found."
    	pass

    builtInCategory = System.Enum.ToObject(BuiltInCategory, _category.Id)
    cats = app.Create.NewCategorySet()
    cats.Insert(doc.Settings.Categories.get_Item(builtInCategory))
    if _instance:
    	bind = app.Create.NewInstanceBinding(cats)
    else:
    	bind = app.Create.NewTypeBinding(cats)

    if isinstance(_paramName, list):
    	for i, j, k, l, n in zip(_paramName, _paramType, _visible, _instance, _paramGroup):
    		message = addParam(doc, i, j, k, l, _groupName, n)
    else:
    	message = addParam(doc, _paramName, _paramType, _visible, _instance, _groupName, _paramGroup)
    # "End" the transaction
    TransactionManager.Instance.TransactionTaskDone()

    #Assign your output to the OUT variable
    if message == None:
    	OUT = "Success"
    else:
    	OUT = message

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f6ffe2214b233e6cdd5e5b248388d1634a268f7f.png)  
[Create Shared Paramters in linked models\_v1.dyn](https://forum.dynamobim.com/uploads/short-url/gJmtrprVtOWSBhhAu9OI2Kf360C.dyn) (23.0 KB)

---

<div class="post-metadata">

**Author:** ![thiru2jack](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thiru2jack/32/112308_2.png) [@thiru2jack](https://forum.dynamobim.com/u/thiru2jack)\
**Post date:** [February 4, 2021, 2:25pm UTC](https://forum.dynamobim.com/t/add-shared-parameters-to-revit-document-not-for-current-document/53782/2 "2021-02-04T14:25:13Z")

</div>

hi @abdallahzakaria  
i’m not sure if any changes in any document need to save or syn the doc. so may be this is reason behind…

---

<div class="post-metadata">

**Author:** ![abdallahzakaria](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/abdallahzakaria/32/99152_2.png) [@abdallahzakaria](https://forum.dynamobim.com/u/abdallahzakaria)\
**Post date:** [February 4, 2021, 3:41pm UTC](https://forum.dynamobim.com/t/add-shared-parameters-to-revit-document-not-for-current-document/53782/3 "2021-02-04T15:41:39Z")

</div>

Could you please clarify??
