So this will increment a specifically named number node every time the python node has not been run. These two conditions are as follows:
- If the python node has not ran yet (fresh graph open)
- The node is refreshed somehow. (perhaps a phony input)
(In the video below I demo this by using a select model element node to make the node want to run, this can be anything you want)
This workflow isn’t the most perfect, but it is one way to try to do it.
# this is a python script
# it does cool things
# normally people spam this area
# with blatant advertisements for their companies.
# i chose not to do that.
#import standard python libraries
import clr
#reference loaded dynamo revit module
clr.AddReference('DynamoRevitDS')
import Dynamo
#reference dynamo core to update node values
clr.AddReference('DynamoCore')
from Dynamo.Graph import UpdateValueParams
#access to the current Dynamo instance and workspace
dynamoRevit = Dynamo.Applications.DynamoRevit()
engine = dynamoRevit.RevitDynamoModel.EngineController
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace
model = dynamoRevit.RevitDynamoModel
node = []
#find the specific node
for i in currentWorkspace.Nodes:
if i.Name.Equals("COUNTER"):
node.append(i)
#get value to update
value = node[0].GetValue(0,engine).Data + 1
params = UpdateValueParams("Value",value.ToString())
#perform update
OUT = node[0].UpdateValue(params),value
counter.dyn (5.8 KB)