Programmatically adding a shared parameter returns false (C#).

Programmatically adding a shared parameter returns false (C#).

70dog
Explorer Explorer
303 Views
1 Reply
Message 1 of 2

Programmatically adding a shared parameter returns false (C#).

70dog
Explorer
Explorer

Hello everyone, I have a problem with adding a shared parameter to a project via the revit api. I will be grateful if you respond and help me.

 

Problem: doc.ParameterBindings.Insert always return false and I dont understand why. There is my code under the text. Purpose of this code is adding a sharedParameter from plugin`s parameters template. Revit returns false and dont tell why. In documentation there is words that revit can return false if parameter already exist but it doesnt in the testing documents (I also checked the possible match of the guids). I've already run out of ideas on how to find the source of the problem. 

70dog_0-1656910333269.png

 

304 Views
1 Reply
Reply (1)
Message 2 of 2

RPTHOMAS108
Mentor
Mentor

Have you checked Category.AllowsBoundParameters for each category you are adding to the set?

 

I also wouldn't use Linq to add the categories to the set. Just yield the results of 'Categories' into a collection and use a normal for loop on it. Delayed execution may not work that well with NewInstance/TypeBinding methods.