I am currently working on a Dynamo script that checks if an element have a parameter and if that parameter is filled correctly. If the element doesn’t have the parameter, but the parameter exist for other elements, I want Dynamo to add the category of my element to the list of categories that the parameter is created for.
An example could be if the parameter “BIM7AATypecode” was set to columns (see picture) but not ceilings, because the creator of the revit file have forgotten to check the box, then I want Dynamo to “check” the box.
@krbr I believe what you are trying to achieve is to add a category to a shared parameter, which is a project parameter, correct?
I did some digging into the API and used your code as an inspiration. FORUM_ADDCAT2PROJPARAM.dyn (11.1 KB)
My code seems to work, but I have only attempted to add one category and for a single parameter.
But I hope you will have a look at it and maybe it can help you to move forward
By the way, I am using Dynamo 2.0 which I now realize might have been silly…
My approach is:
Get the external definition from the SharedParameterFile
Loop through the ParameterBindings
Insert the missing category into the binding
ReInsert the binding into the external definition.
@krbr Can you check the Application.SharedParametersFilename property? Perhaps setting it manually before attempting the app.OpenSharedParameterFile() method could fix it. I will look into it later, unless someone else comes up with a fix.
@krbr I tried to add a function, that should set the path of your sharedparameterfile based on a filepath node. It currently only does so, if the path is null. I guess one could just always overwrite the path, unless you change it frequently. However, I do not know if it solves the problem as I am not able to reproduce it. FORUM_ADDCAT2PROJPARAM.dyn (13.2 KB)
@krbr the filepath is leading to your SharedParameterFile. Basically, my idea was to exchange your SharedParameterFile with itself, since you said app.OpenSharedParameterFile returns null. I dont know if it works, but thought it might be worth a shot.
It’s a .txt file, probably located somewhere on your network drive or maybe locally. You should be able to find that path under “Manage” -> “Shared Parameters”.
Hey again, thanks for all the help, it is much appreciated!
Unfortunately I haven’t been able to work out how to fix the problem, but I am confident that your solution is the solution to the original problem.