Control Freeze Node

Hi

I refer on Forum run branch node based Freeze Node Control.
But seem like need run 2 time (double run) so the firstime run return “null”
How to solve that issue
Thank advance!

# let's see if we can break some stuff

#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')

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

branch1 = None
branch2 = None

#find the branch nodes
for i in currentWorkspace.Nodes:
	if i.Name == "1":
		branch1 = i
	elif i.Name == "2":
		branch2 = i	
	
#freeze/unfreeze branch nodes
if IN[0]:
	branch1.IsFrozen = False
	branch2.IsFrozen = True
	out = "Running Branch 1."
else:
	branch1.IsFrozen = True
	branch2.IsFrozen = False
	out = "Running Branch 2."

#return confirmation
OUT = out

1 Like

Works perfectly for me.
only difference i can see is this.

image

1 Like

I assume you got this from the original thread or one referencing it, but this is somewhat explained in conversation there. This is similar to how ScopeIf works in graph.

1 Like

Yeah, like @Nick_Boyts states, ScopeIf or codeblock would be much easier. But it is cool what you are trying to do with code.

1 Like

The bigger question is “Why are you wanting to freeze nodes during execution?” This is poor practice as it will usually cause a lot of problems.

2 Likes