Force Run Python

Hello all,

@john_pierson shoes an example in the below post of a python node updating as things are changed. Do any of you know how he accomplished this?

I don’t know how he did it. :grin:

Here is the python code. *NOTE: it requires you python node to have the name *Force in it, and it only updates when a node is added or removed right now. Also, this will only work in Dynamo for Revit.

import clr
import datetime
from Autodesk.DesignScript.Geometry import *

import Dynamo
#access to the current Dynamo instance and workspace
dynamoRevit = Dynamo.Applications.DynamoRevit()
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace

#custom definition to mark the node as changed

def nodesAdded(obj):
    for i in currentWorkspace.Nodes:
        if i.NickName.StartsWith("*Force"):
#the handlers for a node being added or removed
currentWorkspace.NodeAdded += nodesAdded
currentWorkspace.NodeRemoved += nodesAdded

#usind the current time for the output as an example

I imagine you can take this further since it is demonstrating how to use the Dynamo API within the current workspace.


Thanks John,

This is perfect. We are trying to track Dynamo script usage in our office and want parts of the graph to rerun if changes were made. This is a great starting place.