Get list project Parameter (the "ID", not the name)

Hello,

I would like to find a way to get project parameter “Id”.

With Document.ProjectParameters (from clockwork), I have project parameters list but it’s a string list.

How can I custom this node to get the parameter “id”, and without selecting element ?

You can find with my capture what I’m looking when I get parameter from element.

Thanks,

Are you looking for the ElementId of the parameter or the element?
You can modify the Clockwork node to return the Id as well as the name and category.

I’am looking for the Id of the parameter, wich Element ID is an project parameter.

To get an other exemple, I’m looking for the Id of “Parameter_crane”.

image

Why ? Because the node “FilterRule.ByeRuleType” wait a parameter.

image

The only way to get a parameter I found, is to have an element, and I don’t want to get parameter with element.

@Nick_Boyts, I don’t have any experience with Python script :frowning:

You can still choose to use existing nodes or start to learn…

A good way to learn Python is to just look at other people’s code and try to modify it in small pieces to get what you want.

Here is the code from Document.ProjectParameters.
image
You can see in line 19 we take the Name of each Key and append it to the list we named params.
You basically want to do this exact same process but with the Id instead of name. All you need to do is create a new empty list for our Ids after line 16.
ids = []
Then we can duplicate the line for getting names and change the pieces we need to instead append the Id to list ids that we just created.
ids.append(iterator.Key.Id)
Then just be sure to add our list ids to the output at the end of the code.

3 Likes

I Tried to change the script but the node didn’t work.

“key” needs to be capitalized in line 21. You might also have to reload your graph before running.

I would take the Python script out of the custom node and insert it in its own Python script node, that way you can see what error you are getting when running the code:

Side note… I think you may have to close out Dynamo and the Revit document, and reopen both.

@Nick_Boyts Maybe you could see if you can reproduce the same thing, but when I was playing around with this, if I ran the code with an error in it, neither the Clockwork Document.ProjectParameters node nor the edited Python code would work until closing and reopening both the Dynamo file and the Revit document. The Python code would return an error saying “The managed object is not valid” and the Clockwork node would return all nulls.

1 Like

I did have the same issue. I don’t know if there’s a way to force that method to reevaluate besides closing the Revit project unfortunately.

Yes, I didn’t see the mistake.

The Id works.

Unfortunately, It was not what I’m looking for, sorry.

When I get the element with “Element.ById”, I got SharedParemeterElement, or ParameterElement, not “Element Id :”.

It’s maybe not possible to get the parameter without Element.

Using Element.ByID is giving you the parameter element of the parameter “Element ID”, so you are getting your parameter. Run the element through an Element.Name or a Parameter.Name node and you can see the name to verify. What is the error you are getting on the FilterRule.ByRuleType node?

1 Like

Actually something in this isn’t working. Maybe something to do with how the Element.ByID node works, but the returned object type is an UnknownElement rather than a Parameter.

I’m not sure but Filter rule by rule type wait a parameter.

The probleme is parameter.id give me an id, parameter.name give me a string, not the parameter.

If you want the parameter object itself, this simple line should give it:
defs.append(iterator.Key)
Think also to check that your packages are up-to-date…
Additional info on this topic:
https://forums.autodesk.com/t5/revit-api-forum/reporting-on-project-parameter-definitions-need-guids/m-p/4684297

1 Like

how can I get the parameter entity itself by from the ID of it? for example builtinparameters/project parameters/global parameters. I want to ask properties of the parameters later with OOTB nodes