Get ParameterType from FamilyParameters in 2.16 (Python)

Hello,

I have a graph to batch copy family parameters from one family to a number of other family documents using “FamilyParameter.Create” from the Orchid Package.
The parameter names, types and groups of the source parameters are extracted using a python script.

After converting my graph from Dynamo 2.12 to Dynamo 2.16 for Revit 2023 it doesn’t work anymore. It used to work with all the older versions before 2.12 aswell.

Code of the Python Node is:

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

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

params = UnwrapElement(IN[0])

pname = list()
pgroup = list()
ptype = list()
isinstance = list()

for param in params:
	if str(param.Definition.BuiltInParameter) == "INVALID":
		pname.append(param.Definition.Name)
		pgroup.append(param.Definition.ParameterGroup)
		ptype.append(param.Definition.ParameterType)
		isinstance.append(param.IsInstance)
	
OUT = pname, ptype, pgroup, isinstance

I figured that the problem is, that now you can’t get the “ParameterType” the way it used to be.

Some research on the forum found that it’s a case of the new Forge/ SpecTyp stuff, so I tried to use that in the python script.

But as I’m not that good at python I simply couldn’t figure out, how to get the parameter types extracted.

Tried this instead of the “ParameterType” one:

...
ptype.append(param.Definition.GetDataType().TypeId)
...

But the “FamilyParameter.Create”-node appears to only accept the parameter types in the correct format.

Like in 2.12:
2023-02-02 16_21_08-Dynamo

Typing them manually as a string, like in the picture above, works.
But I want the ParameterTypes to be read automatically from the parameters of the family.

I also tried to find a node in one of the may packages out there, but couldn’t find anything regarding this topic.

Does anybody know, how to get the ParameterTypes of family parameter on Dynamo 2.16+ in Python? Or a node that does that?

Thank you.

Interesting…

Found this:

Hello.
Thank you for the reply.

I already found that, but sadly that doesn’t help. My Problem is not mentioned there.

It’s written there, that

ptype.append(param.Definition.ParameterType)

in the old version equals

ptype.append(param.Definition.GetDataType())

in the new one.
Which is not true.

As the old one gave me
grafik
as output,

but the new one gives
grafik
which won’t be accepted by the “FamilyParameter.Create” node.

So as I was asking in my initial post:
How do I get same output format as in the older versions?

Hi,

in the API, it is necessary to get a ForgeTypeId type for group

so, try to replace

for param in params:
	if str(param.Definition.BuiltInParameter) == "INVALID":
		pname.append(param.Definition.Name)
		pgroup.append(param.Definition.ParameterGroup)
		ptype.append(param.Definition.ParameterType)
		isinstance.append(param.IsInstance)

by

for param in params:
	if str(param.Definition.BuiltInParameter) == "INVALID":
		pname.append(param.Definition.Name)
		pgroup.append(param.Definition.GetGroupTypeId())
		ptype.append(param.Definition.GetDataType())
		isinstance.append(param.IsInstance)

@c.poupin it will not work, it is a shame how changing things in the API have so much impact on workflows, I am not sure now how to open families in the background and create for instance parameters, the OOTB node for that does not work with the Orchid BackgroundOpen node, maybe I missed something and someone else can make it work as per @dominikleuchter inquiry.

1 Like

Yeah I tested it. @Elie.Trad is right.
It still doesn’t work, as the Orchid node “FamilyParameter.Create” does not support that type of input.
It needs the correct name as string, like I mentioned in my post.

But I think there might be a solution around the corner, as I noticed that @erfajo, the author of Orchid, seems to be aware of that issue and is currently working on a solution, according to his github.
https://github.com/erfajo/OrchidForDynamo/issues/184

So I’d say let’s hope for the best and wait until he got this fixed. (:

2 Likes

Apparently, the problem will not be so easy to solve after all.
But since I need the “FamilyParameter.Create” node working, I have created a temporary fix for the problem.

A custom node that manually translates the SpecTypeIds to the old ParamterTypes.

I know it’s not a perfect solution, but at least it works. Especially if something changes in the SpecTypes in the future, I can’t guarantee that it still works.

But anyway, feel free to use it. :slight_smile:

SpecTypetoParamType.dyf (20.5 KB)

1 Like