Change Shared Parameter Group


#1

Hi guys,

I’ve been given some files where the Shared Parameters have been loaded in the wrong parameter Group. What I want to do is take some of the parameters and set the “Group parameter under” to Identity Data instead of Text (where they are now…the wrong group). See image below for clarification.

Considering that in the nodes that create/add the parameters to the project you can define in which group to set the parameter, I thought it would have been easy to change it as well, but couldn’t find a solution.

Anyone that tried this? ideas?


#2

Really? There’s no way?


#3

Hi @andreatas according to the API the parameter group property only has a get accessor, therefore it cant be set through the API.


#4

Hi @Thomas_Mahon

Thanks for the reply!

So you reckon there is no way to change automatically the Group of some parameters with a script? This is weird…I thought it should have been a rather easy thing to do…


#5

Same, well firstly its very easy to get the group parameter. However, as the API provides no means to set it, unfortunately with these cases its open-and-shut - there is no way.


#6

@Thomas_Mahon,

That’s not true. At least its not entirely true. What you are saying only applies to system parameters that have a BuiltInParameter value different than INVALID. What the OP is asking for however, is a Shared Parameter which always will have the BuiltInParameter value set to INVALID, and hence making it possible to set the ParameterGroup for it via the API. Basically if its a BuiltInParameter you can’t set that, otherwise you can.

Here’s how:

Here’s the code:

# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

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

import System

element = UnwrapElement(IN[0])
name = IN[1]
group = System.Enum.Parse(Autodesk.Revit.DB.BuiltInParameterGroup, IN[2])

TransactionManager.Instance.EnsureInTransaction(doc)

definition = element.GetParameters(name)[0].Definition
definition.ParameterGroup = group

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = 0

Cheers!


Retrieve "parameter group name" of shared parameter
#7

Good spot, I only checked built in parameters!


#8

Thanks @Konrad_K_Sobon !

There is just one thing I’m not sure I’m getting: I’m not sure why you are taking a model element as one of the inputs.
If you change the group of a Shared Parameter that is not going to be changed just for the selected element but for all the elements that have that SP, right?

So why are you taking the element in IN[0]?

Thanks!


#9

Apologies if I jump in. The topic is interesting and I was trying to test it (Revit 2016) but I get an error:

definition = element.GetParameters(name) returns an empty list


#10

@andreatas,

I am using a single element here so that I can retrieve the parameter from it. Parameters cannot be obtained on their own, and since they are Category specific (could be multiple but always a Category), then I can use a single element to extract the parameter from it. Yes, that change will affect all elements in that category.

@salvatoredragotta,

It looks like there is no parameter with that name or that Revit was not able to retrieve it. You can try the OOTB nodes to test if that parameter exists in the model.

Cheers!


#11

Hi @Konrad_K_Sobon

My bad for not posting a screenshot from my script. I am actually able to retieve the parameters in this way:

So after this, my idea was to get the group the parameters are in at the moment and “move” it to the Identity Data group.
Is it possible? Considering that you are able to do it picking an elements I guess it should be doable directly from the parameter, right?


#12

@salvatoredragotta Clockwork package has a node called “Element.ParameterExist” to filter if parameter exist. You can try that.

@andreatas You need to pick first elements and filter the parameters from it. Currently your filtering parameter elements. Connect Elements list to IN[0], Parameter name to IN[1] and Select Built in group to IN[2] to move to another ParameterGroup. Hope that make Sense.


#13

Hi @Kulkul ,

Yeah that makes perfect sense! I was just wondering if there was an alternative way to do it without having to select elements. Considering that I am able to select the actual parameter element I thought there was a way to directly change its group.

From what I see in @Konrad_K_Sobon 'sscript (but my Python is not good at all) you select an element, get the parameter with the same name as in the Code Block and then change its group. Is there a way to jump the first two steps if I directly feed in the parameters that I get in my screenshot (the output of the filter by boolean mask)?

Thanks for the help guys :wink: