I am developing a NodeModel node with custom UI in C# and I would like it to be run every time user clicks Run button, even though there haven’t been any changes in UI.
Is there a way to force a NodeModel node to always run?
You’ll have to work this out for ‘how’, but this should illustrate ‘how’ to get the workspace info via the API (although in pyhton instead of C#).
That said, your node should trigger a re-execution any time the UI is altered. Are you trying instead to trigger a UI as a standalone window? In which case you can circumvent the node model stuff and just run a standard node with any manor of file update causing the node to retrigger. If something else, it might help to understand your UI components to get better info.
The Python example illustrates how to get the current workspace in Revit as the Python script is written inside of the Dynamo UI run in Revit, but while developing a NodeModel node in C#, one does not have the same access to the current workspace as when writing a Python script.
My node is performing some tasks based on settings chosen by the user in the node UI. On subsequent runs of the Dynamo script, the task is not performed unless the UI is modified manually by the user, which I am trying to avoid. I tried to change the UI programmatically whenever the BuildOutputAst method is called. The UI gets successfully changed programmatically, but the logic that the node needs to perform is not executed the second time (the function call inside the BuildOutputAst method does not get called).
Which other ways of causing the node to retrigger do you know of?
Certainly can be made to work with C# - what have you tried so far? Can you point me at an openly accessible GitHub repo for the project?
So the issue isn’t that you want the node to trigger the UI, but that you want the node after it to execute every time someone hit’s “run”? You could put a File From Path node on the canvas and have it get a text document in the user’s temp directory. You cant hen wire that into a waitfor method that passes the UI. Then at the end of your graph just write a random GUID to the text file. The File From Path node will see that the file changed since last executed, and will re-execute itself, causing the waitfor to execute, and everything until the write to text at the very end. THis will mean that everything other than the UI will re-execute each time.
You can also leverage this in your own ZT node or even have your Node Model node take the file path as an input that does nothing. But typically I recommend the file from path node be used as is instead as it’s maintained by the team instead of by you.
Unsure what you have tried so far, and without you posting anything. But to give you a little bit of guidance have a lo
ok at the following.
Look into creating a Dynamo View Extension, Look into setting up events and also tapping onto the OnEvaluationComplete event. Though unsure in later versions if this is the right way.
You may need to place the dynamoviewmodel into a event and have that stored some how then once you have this you could then get the currentworkspace from this object.
This is a very limited section of code, there is other steps and areas to be implemented before you can get to this!
Thank you for the proposal, but I believe you are right. This is available only in View Extension.
In order to create instance of the view model, ViewLoadParams need to be required, and TuneUp is requiring them from Loaded overloaded method of ViewExtensionBase class that is part of View Extension.