But to access the ‘Script’ property I need to cust the nodes ad PythonNode that is a class in the PythonNodeModels.dll that is not provided by the different Dynamo packages.
You could say, just reference that dll from the folder nodes inside Dynamo, but this means I need to remember to change this manually, all the time I am going to update the NuGet packages.
So, I am thinking if there is another way that I don’t see to access this component.
I am sure @john_pierson, you will have some good advice
I was aware of this solution, but I have not considered it because I should provide the file in a shared folder and ask to do the steps, even if are simple, to a very large group, and having the file in a shared folder is not ideal.
I have a .py file with the boilerplate that is read and passed to the property.
I tested saving the definition and re-open it and no problems with overwriting.
In this way, I’ll leave to the user the decision of using the boilerplate when needed.
from Dynamo.Graph.Workspaces import *
from Dynamo.Graph.Nodes import *
#access to the current Dynamo instance and workspace
dynamoRevit = Dynamo.Applications.DynamoRevit()
engine = dynamoRevit.RevitDynamoModel.EngineController
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace
from PythonNodeModels import *
boilerPlate = IN
#find the specific node
for node in currentWorkspace.Nodes:
if "Test" in node.Name and node.NodeType == "PythonScriptNode":
node.IsFrozen = True
node.Script = boilerPlate
Yeah, true only difference is that I am calling an event via a custom toolbar menu, so to access the node, or I use reflection or I need to reference the .dll as I mentioned previously.
Writing in C# and using reflection I did exactly what you did using IronPython
Thanks for your message.