Python script node in manual only, input prior to run

Hi … The following python runs correctly when the graph run mode is set to automatic. I need it to run in Manual. It should work like this … user click on the node and the user is prompted to select an entity. If the entity is nested , then the output will be a container of objectid’s - providing the nested structure. Obviously I will not leave it like that. I just dont know how to get this node to work in a Manual graph.
Thanks for your patience.

import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

rs = editor.GetNestedEntity('\nSelect nested entity: ')
objIds = rs.GetContainers()

# Assign your output to the OUT variable.
OUT = objIds

Hi @kbzawork,

This actually does work when the run mode is set to Manual. The issue you’re likely seeing is that you’ve already run the graph once in Automatic mode, and then switching to Manual mode doesn’t cause the graph to run again. If you start out in Manual mode and run it for the first time, then it works as expected. Here’s why…

When you run a graph, Dynamo caches data about each node to compare with the next time the graph is run. If there are no changes to the graph, then Dynamo knows that it doesn’t need to re-run everything. Every time you make a change to your graph, the nodes that you change are marked as “dirty” so that Dynamo knows it needs to re-run them. And conversely, if you don’t change anything, then Dynamo assumes that a re-run is not necessary. The benefit of this mechanism is a performance boost from not running through the same operations repeatedly if the inputs haven’t changed.

So that is what’s going on with your Python script. It runs once in Automatic mode, then you switch to Manual mode and try to re-run it but the node isn’t marked as “dirty” and is not executed. There’s a couple ways you can get around it by forcing the node to be marked as “dirty”:

  1. Toggle the +/- buttons on the node to add/remove an input port
  2. Add a boolean toggle, as shown in this example
  3. Run the graph via Dynamo Player
1 Like

Thank You

Thx Zachri … adding the boolean helps … how would the python script node be changed to immediately doing the script when the user clicks on the node? Like … Civil3DToolkit Pick Point.

Something like that would require building a custom node, which means you’d have dive pretty deep into C# and WPF. I would just run the script through Dynamo Player.