Python script in Dynamo only runs once after editing it and clicking Accept Changes

I have a working python script (a simple test script that nudges the bottom edge of a crop box up by a specified amount), but it only runs after I edit it and click Accept Changes. I have to make some “actual” change, i.e. I can’t just open it and click Accept Changes, but simply adding a line break anywhere and doing it will make the script run again - once. To run it another time I have to do the pointless “change” again. Is there something I’m missing, or could this be a bug? I modeled my script after what I see in the Clockwork extension.
(using Revit 2019.1, Dynamo Core 1.3.3.4111, Dynamo Revit 1.3.3.4111, 2.0.1.0)

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

input = UnwrapElement (IN[0])
cb = input.CropBox
cb.Min = XYZ (cb.Min.X, cb.Min.Y + IN[1], cb.Min.Z)

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
input.CropBox = cb
output = input.ToDSType(True)
TransactionManager.Instance.TransactionTaskDone()

OUT = output

Sounds like normal behavior to me. Dynamo will only execute a node once. If you want to re-execute you have to either change the input or the content of the node itself.

Ha! Ok, thanks, this solves my “problem” in practice, but just out of curiosity - my little test script at least was a use case where I might want to simply manually press Run multiple times with the same inputs and contents … how might I approach something like that?

Toggle something up stream, such as a True/False or number slider input input into your python node which does nothing. Just Refresh=IN[2] or something like that should work. Leave the graph on ‘auto and just toggle the value.

Generally speaking it is better to move things precise distance, or repeat an action until a condition occurs or stops occurring.

1 Like

Use Dynamo Player. It’s very helpful when running scripts with Python nodes.