Unable to create new project parameter via Revit API

Hey there!

My idea is to transfer Shared parameters from linked file (doc_link) to the host file (doc = Revit.ActiveDBDocument) in order to be able to make room colour schemes based on the parameters, which were created in the nested file.

The action sequence is following:
1.find out if the parameter i need is shared
2.get it’s definition and GUID
3.create new shared parameter in current shared parameters file (or create temporary shared parameters file as it was made in Rhino.Inside.Revit official repository). If such shared parameter already exists in SharedParametersFile, we are to get it
^^^everything goes great until this moment, the shared parameters are appearing in SharedParametersFile^^^
4.add new shared parameter to Project Parameters
^^^when i’m trying to conduct this transaction i am getting an Error with no description:
22.03.2022_12.35.59_REC
22.03.2022_12.37.25_REC
Here are the most important methods i am using:

categories_set = DB.CategorySet()
binding = DB.InstanceBinding(categories_set)

for cat in categories:
    binding.Categories.Insert(cat)

ex_def = spfg.Definitions.Create(ex_def_opts)

result = doc.ParameterBindings.Insert(ex_def,binding)

The reason why i am not using RIR gh nodes is because there’s no chance to pick certain categories for the parameter to be present in.

What am i doing wrong? Thanks in advance for any attention!

You can modify the Bindings here.

1 Like

Thanks so much!

I’ve got the following question:
how to transfer data properly between RIR nodes and python?

Have you seen the Documentation?, there are python examples

I would also look at how Eshan has in his various Python scripts in the guides and on the forum. It really depends on what you are trying to do.

Of course, i’ve seen the documentation, but there’s nothing about system classes. Now i’m trying to transfer Revit Shared Parameter from the RIR node and proceed working with it in my ghPython script, but the objects from RIR nodes are considered to be strings, not objects.

For instance if i will query all the objects of class DB.SharedParameterElement in first ghpython node and output it through the node-output, i will be able to work with those API objects in another node

It also works with the most of the objects which are coming out of the RIR nodes, but the parameter (and related objects) are not readable and are not recognized by python as programming objects (classes). The are interpreted as strings (text)

It seems like there’s no tool to convert those objects through the API that you’ve provided

Hi @Magda,

You can extract Shared Parameter Guid using ‘Parameter Identity’ and then lookup for it in your document like this.

But what is the reason why it is impossible to transfer pickled object data directly between the nodes?

The reason is that RiR Parameter is wrapping Built-In, Project and SharedParameters.
There is no Revit API type able to represent all them.

May I ask what is missing about parameters that you are trying to implement?

okay, but why i can’t read this RiR parameter in my ghPython?

The thing that is missing – is generally to create a new Shared parameter with specific GUID. For instance, there is a document (file A) which i got from another architectural bureau. I only have a *RVT file, and have no access to their shared parameter file (*TXT). But the shared parameters they have initiated are still working and present. My purpose is to duplicate those shared parameters to my new file (file B).

Usually i do it by going to A-file’s Manage > project parameters and doing “Export”. After that there would be a new Shared parameter in MY shared_parameters_file (*TXT) on my computer. And then i can easily open up my file B and create a new project parameter, using a definition from “Exported parameters” group. This makes possible to apply filters and make schedules (for both objects from file A and file B simultaneously). This becomes possible only when the GUID of corresponding parameters are identical. And there is no RIR functionality for this very case at the moment :smiley:

btw technically it’s very easy to realize:

    ex_def_opts = DB.ExternalDefinitionCreationOptions("Name",DB.ParameterType.......)
    ex_def_opts.GUID = new_guid
    ....
    ex_def = group.Definitions.Create(ex_def_opts)

I see, in this case you can transfer parameters from one document to the other doing this.

‘Query Parameters’ will return you all the parameters in the source document.
We are thinking to add an additional input to filter shared-parameters and don’t need the cluster I used here after it.

but what is it there in a cluster?

I updated it to transfer Instance and Type parameters.

The Cluster is getting the Parameter GUID and skiping those parameters that do not have a GUID.

wow, thanks a lot!
looks and works great

One thing left to transfer are the Categories binding and if it varies across groups on each parameter.
The component ‘Project parameter’ gets and sets those values.

RiR-TransferSharedParameters.gh (35.0 KB)

I never tried but should work with Global Parameters as well.

Hi @Magda,

I changed this for scripting components on v1.7 to return a Revit API type.

Depending on the content you will obtain an:

  • ARDB.BuiltInParameter
  • ARDB.ParameterElement
  • ARDB.ExternalDefinitionCreationOptions
1 Like