I was trying to reference this post’s solution and I want to add a little to it. I want to return all of the nodes as they do and then somehow access if the given node is returning a warning. I can then return this as an output to the user in some form later. Trying very hard to find documentation on the Dynamo API…but to no avail.
I look for Dynamo API stuff… i cant realy find. i would like do costumnodes…
# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('DynamoRevitDS')
import Dynamo
# Die Eingaben für diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
dynamoRevit = Dynamo.Applications.DynamoRevit()
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace
nodeNames = [[],[]]
for i in currentWorkspace.Nodes:
nodeNames[0].append(i.Name)
for j in currentWorkspace.Nodes:
nodeNames[1].append(j.Warning)
OUT = nodeNames
import clr
import sys
import System
from System.IO import Directory, File
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('DynamoCoreWpf')
clr.AddReference('DynamoCore')
clr.AddReference('DynamoRevitDS')
import Dynamo
from Dynamo.Applications.ViewModel import *
from Dynamo.Graph.Workspaces import *
from Dynamo.Models import *
from Dynamo.ViewModels import *
dynamoRevit = Dynamo.Applications.DynamoRevit()
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace
out = []
for i in currentWorkspace.Nodes:
if "Warning" in i.State.ToString():
out.append([i.Name, i.ToolTipText])
OUT = out
You will really need to watch the order that things are executed, because you may want this python node to have every possible avenue of nodes connecting into it.
This will mean that it will not run until after everything else has been run.
I’m inclined to mark this as a solution as it returns Exactly what I need! However, it only works under certain circumstances. I think what is happening is that the entire program needs to run for it to return warnings. And so a lot of times the py script returns a null list even though there are warnings because (what I believe) the program has not yet entirely finished so there are no warnings to return. I have to make a small change to script (like adding a node for example) for the script to run completely again and it will show an output correctly.
Not sure if this all makes sense, but as of now cant get it to return warnings consistently. The ultimate goal being to see a watch node output of the warnings in the dynamo player. Even running in the player 2x in a row doesn’t return anything other than null
@wsayle as @Brendan_Cassidy suggested, you’ll want to force your Python node to execute last. Given that Dynamo gets pretty smart about how to retain output from nodes that have already processed, but not changed, and the subsequent way it bundles up the nodes into a “action sequence” to be run through the Virtual Machine, you’ll need the ensure that the Python node comes last - every time.
Easiest way to do this is connect it into the last node in your graph’s chain of nodes - with a dummy input port.
If you want to work with this node in a live graph, not just with Dynamo Player, you’ll also need to force the Python node to re-execute To do this, you can have a second dummy input of “DateTime.Now” that is an always-updating node, which then always puts new data into the Python node to force it to reexecute and get around the “Smarts” of delta-compute.
@solamour thank you for the detailed response! I appreciate you going into some of that detail. Several dynamo users I have spoken to are looking forward to the added features.
I tried what you said and still getting the same issue unfortunately The python script is at the end with the DateTime.Now input. However when I run the program again (no delta change) the date and time does not change within the editor. The player doesn’t change the py script update either when ran 2x in a row.
I’m using Revit 2022 and the dynamo version is the following. (could never get it to update for some odd reason)
*
import clr
import sys
import System
from System.IO import Directory, File
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('DynamoCoreWpf')
clr.AddReference('DynamoCore')
clr.AddReference('DynamoRevitDS')
import Dynamo
from Dynamo.Applications.ViewModel import *
from Dynamo.Graph.Workspaces import *
from Dynamo.Models import *
from Dynamo.ViewModels import *
dynamoRevit = Dynamo.Applications.DynamoRevit()
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace
dummyInput = IN[0]
forceRexecute = IN[1]
out = []
for i in currentWorkspace.Nodes:
if "Warning" in i.State.ToString():
out.append([i.Name, i.ToolTipText])
OUT = out
*
Delta-compute is essentially when Dynamo chooses to run, or not run certain nodes depending on if they would return a different result
My apologies, I was mistaken. DateTime.Now will update every time you run it, as it queries the system clock, in Periodic mode (Which is also why it will run in Player as the process is similar - essentially start graph from scratch), but not in Manual in Dynamo 2.14.
In order to force your Python node to update, you need to have something change coming into that node. If you try do this with by clicking “+” on the Python node, then running, then clicking “-” again does it work correctly? That is forcing a change in the node.
If you rename any node(eg your original python node) with “*Force” without the quotes of course, it will force that node to be re-run everytime. Though i would always keep the inputs you currently have within it, so it is keeps your original python node running last.
In other news, I did do the api workaround with a macro that does return the errors. Wish I could get it within player. But I think from now on this thread can be more academic. I really appreciate all of the help! Very informative.