Similar to this post UI Node Extra Output Ports I have an issue whereby whenever I save and reopen a script the output ports for the dropdowns are duplicated.
I am using the suggest JsonConstructor without success. I have even duplicated the dropdown example (from DynamoSamples/DropDown.cs at master · DynamoDS/DynamoSamples · GitHub) within my library which doesn’t resolve the issue.
This only occurs with my library, and doesn’t appear to occur with other packages containing dropdowns.
The log, and console don’t show anything out of the ordinary.
I’m currently testing in Revit 2022 with Dynamo 2.12. Any thoughts or ideas are welcome.
It occurs because the constructor of your nodeModel is called, and that constructor likely adds new ports, either with port attributes or directly by creating portmodel data objects, instead you need to add another constructor to be used when opening that graph, that does not create new ports but uses the deserialized ones from the file.
so:
debug your code and check which constructor is being called on file open.
It’s also possible that if more than one version of newtonsoft json is loaded into the process that the json attributes won’t evaluate correctly and newtonsoft will not find your new constructor -
you can check for this with the modules window in visual studio (look for json or newtonsoft etc loaded from multiple locations)
4 Likes
Hi Michael,
Thanks for your reply. The Constructor below was called at both node creation and reopening the graph. The JsonConstructor taking the inPort and outPort is never called.
DropDownExample() : base("item") { }
After trying many things, I removed my Nuget version of Newtonsoft.Json
(this wasn’t copied locally) and instead referenced the version in DynamoForRevit folder. This resolved the issue.
Looking at the module window it was loading the PnID version of Newtonsoft.Json
as well as the one in the main Revit folder. This must have caused the conflict.
After reading the thread I referenced, I can see the notes regarding Nuget packages now.
Thanks for your help.
2 Likes