ParameterBindings lose value after ReInsert

ParameterBindings lose value after ReInsert

dorer69044
Contributor Contributor
772 Views
3 Replies
Message 1 of 4

ParameterBindings lose value after ReInsert

dorer69044
Contributor
Contributor

My Add-in creates an assembly for the selected items.
And for each creation of assembly, I run ParameterBindings.Insert and if I get false, I try ParameterBindings.ReInsert.
After the second time I create, when I check my first assembly, I see that I lose the parameter value after ReInsert.

 

This only happens if I have a project for Revit 2021 and I update it to Revit 2023.
And run the Add-in for the updated project in Revit 2023.

Does anyone have any idea how I can save the parameter value after ResInsert?

 

773 Views
3 Replies
Replies (3)
Message 2 of 4

TripleM-Dev.net
Advisor
Advisor

Hi @dorer69044 

 

See documentation of ReInsert: ReInsert Method (Definition, Binding) 

"Removes an existing parameter and creates a new binding for a given parameter."

The values are lost because the parameter was deleted by ReInsert.

 

Best to add the parameter if it didn't exist to begin with, if it does and doesn't have the correct Categories attached supply a warning to User to add Category X to Project Parameter Y.. (as a initialization check maybe)

 

Also see post: Adding a category to a project parameter 

Note: Above post could be a issue for elements in groups if the parameter is group bound

 

- Michel

Message 3 of 4

dorer69044
Contributor
Contributor

Thank you for your reply.
In practice it doesn't work the way you said. For some projects I have the value all the time, and for some it is lost after ReInsert.

Message 4 of 4

dorer69044
Contributor
Contributor

@jeremy_tammik
Do you have any idea how I can save the parameter value after ResInsert?
Thank you!