Hi,
Im having an issue with some python code in my dynamo node.
Its a rather simple script that aims to remove imported line patterns, and yesterday it was working fine. Then i asked som coworkers to try it out and all of a sudden it stopped working.
It gives me an AttributeError stating that the ‘.Name’ attribute does not exist. Although im sure it does since it has worked before. What am i missing? Depending on revit version and file im testing it in it sometimes gives me an SystemError about an built-in-function import returning an error set. And as i said it all worked fine earlier so im not sure what i messed up.
Heres the code:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
import Revit
import RevitServices
from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#importlib.reload(sys)
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Place your code below this line
doc = DocumentManager.Instance.CurrentDBDocument
linepatternelements = IN[0]
uw_linepatternelements = UnwrapElement(IN[0])
removed_linepatterns = []
if len(linepatternelements) == 0:
OUT = "No Line Patterns to remove."
else:
TransactionManager.Instance.EnsureInTransaction(doc)
for linepatternelement in uw_linepatternelements:
removed_linepatterns.append(linepatternelement.Name)
doc.Delete(linepatternelement.Id)
TransactionManager.Instance.TransactionTaskDone()
OUT = removed_linepatterns
# Assign your output to the OUT variable.
The input is a list of all LinePatternElements whos names contain ‘IMPORT’.
I know i basically could use the element.delete node to remove these line patterns. But im trying to impove my understanding of python and the Revit API so thats why im going this route.