Shared Parameter help: "Values can vary by group instance"

We need to create more than 100 new shared parameter, we are able to create then from excel with this:

but the last step we need, is to set “values can vary by groupe instance” to true.
We found this skript here : Shared Parameter: Values can vary by group instance
PNG

can someone help us to change this so that is takes a list of parameter names as input and change all parameters in this list to “values can vary by groupe instance” to true?
As we don´t know about python we are lost :slight_smile:

Thank´s to all,
Johannes

Please post the python as preformatted text, or post the dyn with the python in it. This will help others help you as they won’t have to retype all the code from scratch.

Hope this helps:

import clr

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
import Autodesk

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

TransactionManager.Instance.EnsureInTransaction(doc)

map = doc.ParameterBindings
iterator = map.ForwardIterator()

paramName = ‘Türen’;

namelist =
iterator.Reset()
while iterator.MoveNext():
definition = iterator.Key
namelist.append(definition.Name)
if definition.Name == paramName:
definition.SetAllowVaryAcrossGroups(doc,1)
break

TransactionManager.Instance.TransactionTaskDone()

1 Like

Hey,

I’m not able to get it working, but I think Erik might be interested in adding this funcationality to the Orchid package…

If you raise an issue here:


he might help :slight_smile:

Hopefully that’s useful,

Mark

Did anyone come up with a solution for this? The Python code works great if adding one parameter and you specify the parameter name but I’m looking to add list of parameters that’s pulled from an Excel file.

Unfortunately I’m still very new to Python so I’m not sure how to adjust the code.

Another thought was to create a list from each of my original lists and use that new list to add the parameters and repeat that process for the length of my original list. I’m not even sure if that’s possible but just a thought.

Found it here

Oops. Found it here

https://forum.dynamobim.com/t/add-shared-parameters-to-some-families-orchid-package/21254/11

Have to use levels

Hi I am trying to do a similar thing and getting stuck. I want to make all COBie parameters in my model Edit: Vary value by group - but I get this error message. AttributeError: ‘InternalDefinition’ object has no attribute ‘SetAllowVaryAcrossGroups’

I think most COBie parameters are string parameters so as long as they are not Type parameters I am hoping it is possible to globally change them.

Thanks, Simon

import clr
# Import RevitAPI Classes
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
#the above can be changed to import just specific classes separated by a comma

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

clr.AddReference('RevitNodes')
import Revit
# Adds ToDSType (bool) extension method to wrapped elements
clr.ImportExtensions(Revit.Elements)
#adds ToProtoType, ToRevitType geometry conversion extension methods to objects
clr.ImportExtensions(Revit.GeometryConversion)

#import documentmanager and transaction manager
clr.AddReference('RevitServices')
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

TransactionManager.Instance.EnsureInTransaction(doc)

map = doc.ParameterBindings
iterator = map.ForwardIterator()
stch = UnwrapElement(IN[0])
namlst = []
fails = []

iterator.Reset()
while iterator.MoveNext():
	definit = iterator.Key
	nam = definit.Name
	if nam.StartsWith(stch) and iterator.Key.ParameterType != "Type":
		fails.append("pass")
		definit.SetAllowVaryAcrossGroups(doc,1)
	else:
		fails.append("fail")


TransactionManager.Instance.TransactionTaskDone()

OUT = fails

I have a solution - it only works for instance parameter where value is a string but I think that does what I need.

EDIT: Sorry changed it a bit - COBie - change cobie project and shared parameters to vary by group_FINAL_#1.dyn (22.7 KB)

import clr
# Import RevitAPI Classes
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
#the above can be changed to import just specific classes separated by a comma

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

clr.AddReference('RevitNodes')
import Revit
# Adds ToDSType (bool) extension method to wrapped elements
clr.ImportExtensions(Revit.Elements)
#adds ToProtoType, ToRevitType geometry conversion extension methods to objects
clr.ImportExtensions(Revit.GeometryConversion)

#import documentmanager and transaction manager
clr.AddReference('RevitServices')
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

TransactionManager.Instance.EnsureInTransaction(doc)

map = doc.ParameterBindings
iterator = map.ForwardIterator()
stch = UnwrapElement(IN[0])
namlst = []
failssetlst = []
fails = []
length = []

iterator.Reset()
while iterator.MoveNext():
	definit = iterator.Key
	nam = definit.Name
	length.append("0")
	if nam.StartsWith(stch) and iterator.Key.ParameterType == "Text":
		try:
			definit.SetAllowVaryBetweenGroups(doc,1)
		except:
			failssetlst.append(nam)
	else:
		fails.append("fail")


TransactionManager.Instance.TransactionTaskDone()

OUT = (fails, length, failssetlst)

EDIT: The attribute name in the first script was wrong. :slight_smile:

1 Like