Hello everybody,
this is my problem: “Revit failed to execute TESTSMACRO” - it appears when I try to launch python macro by Macro Manager, but only if Dynamo isn’t opened in a background window. When Dynamo is opened at the same time as I use Macro Manger it’s all OK. How could I make this work without launching Dynamo in a background?
This is the macro from SharpDevelop:
import clr
import System
clr.AddReferenceByName(“RevitAPI.dll”);
clr.AddReferenceByName(“RevitAPIUI.dll”);
from Autodesk.Revit import *
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Macros import *
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import *
from System.Collections.Generic import *
from System.Collections import *
from System import *
from math import *
def TESTMACRO(self)
…clr.AddReference(“RevitServices”)
…import RevitServices
…from RevitServices.Persistence import DocumentManager
…from RevitServices.Transactions import TransactionManager
…doc = DocumentManager.Instance.CurrentDBDocument
…collector
= FilteredElementCollector (doc) collector.OfCategory (BuiltInCategory.OST_DuctCurves).WhereElementIsNotElementType ().ToElements()
… # starting transaction:
…t = Transaction(doc, “DuctNaming”)
…t.Start()
…
…[doing some stuff with ducts here]…
…
…t.Commit()
And this is some text from a failure window:
"Revit failed to execute TESTMACRO
A problem has been detected.
Autodesk.Revit.Exceptionms.ArgumentNullException: The input argument “document” of function ‘anonumous-namespace’::FilteredElementCollector_constructor or one item in the collection is null at line 326 of file
d:: …bla-bla-bla…"
Help please, can’t really understand what the hell is that. Thank you!