BuiltInParameterGroup String to Enumeration

BuiltInParameterGroup String to Enumeration

Anonymous
Not applicable
1,942 Views
3 Replies
Message 1 of 4

BuiltInParameterGroup String to Enumeration

Anonymous
Not applicable

I am trying to create parameters from a list of parameters but I am running into an issue with the BuiltInParameterGroup.

 

I currently have the BuiltInParameterGroup as a string such as PG_CONSTRAINTS, but obviously that isn't working because the FamilyManager.AddParameter() function requriest a BuiltInParameterGroup and not a String.

 

Is there an easy way to convert that string into the BuiltInParameterGroup enumeration? I'm working in Python, so if anyone has any idea specific to python that would be awesome, but I can also try to figure it out if it's in C#.

 

Thanks!

0 Likes
Accepted solutions (1)
1,943 Views
3 Replies
Replies (3)
Message 2 of 4

MarryTookMyCoffe
Collaborator
Collaborator

C#
http://lmgtfy.com/?q=c%23+how+change+string+to+enum
Phyton
http://lmgtfy.com/?q=Phyton+how+change+string+to+enum

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 3 of 4

jeremytammik
Autodesk
Autodesk

Exactly!

 

Also:

 

https://duckduckgo.com/?q=string+to+enumeration+.net

 

🙂

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

That was definitely the first thing I did. I also made sure to search all of the forums for a Revit specific solution.

 

As I am fairly new to coding, the conversion to Enum is a bit confusing. 

 

If I have a list of strings that point to the string version of a BuiltInParameterGroup such as ["PG_GRAPHICS", "PG_IDENTITY_DATA", "PG_CONSTRAINTS"] how do I link it to the integer value that is associated with the Enumeration? Is this a task where I need to define the conversion for each BuiltInParameterGroup?

 

Sorry if this is a stupid question, I can try approaching it from a different direction if this doesn't make sense.

 

EDIT:

Sorry if my question was confusing/elementary. 

For anyone working in python that might run into this in the future, this is how I was able to solve it:

 

exec("parameterGroup = BuiltInParameterGroup.%s" % pg)