I try to build a script that create something like a journal after run the script.
Thanks to @c.poupin this solution works:
This code works fine in a new script with a few nodes but when I try to use it in a older script it doesn’t work. (big script)
Does someone know how I can control this?
import clr #.NET Laden
import sys #sys is de fundamentele Python bibliotheek
import os.path
import datetime
from System import EventHandler, Uri, Environment
from System.Collections.Generic import List
clr.AddReference('DynamoCoreWpf')
clr.AddReference('DynamoCore')
clr.AddReference('DynamoRevitDS')
clr.AddReference('DynamoServices')
clr.AddReference('DSCoreNodes')
from DSCore import *
import Dynamo
from Dynamo.Graph.Workspaces import *
from Dynamo.Graph.Nodes import *
from Dynamo.Models import *
username = Environment.UserName
my_path = "Y:\\Dynamo\\Journal files\\" + username
def EventResumeNodes(sender, e):
try:
ResumeNodes()
except Exception as ex:
print('ERROR TRACEBACK' + str(ex))
def ResumeNodes():
global dynamoRevit
global currentWorkspace
resume_file_path = my_path + ".txt"
lstError = []
for i in currentWorkspace.Nodes:
if i.State == ElementState.Warning:
lstError.append("###############################")
lstError.append("Node : {}".format(i.Name))
lstError.append("Error : {}".format(i.ToolTipText))
with open(resume_file_path, 'w') as f:
for line in lstError:
f.write("{}\n".format(line))
dynamoRevit.RevitDynamoModel.EvaluationCompleted -= EventHandler[EvaluationCompletedEventArgs](EventResumeNodes)
dynamoRevit = Dynamo.Applications.DynamoRevit()
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace
dynamoRevit.RevitDynamoModel.EvaluationCompleted += EventHandler[EvaluationCompletedEventArgs](EventResumeNodes)
OUT = my_path