py. pair objects by assembly code to workset


import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * #The inputs to this node will be stored as a list in the IN variables. Worksets_all= IN[0] Elements = IN[1] ##Regex to get the worksets matching the assembly criteria ##https://stackoverflow.com/questions/7014674/in-python-how-do-i-remove-from-a-list-any-element-containing-certain-kinds-of-c import re ##NOTE This is REgular EXpressions - a powerful pattern matching language regex = re.compile(r"([abcdefglABCDEFGL]\d{2})|([Ww]orkset 1)",re.IGNORECASE) ## ABCD follow by 2 numbers #L added for airport special ##Iteration over list i[0] is NAME to comare #Worksets = filter(lambda i: regex.search(i[0]), Worksets_all) ##Also works Worksets = [i for i in Worksets_all if regex.search(i[0])] ##Each list item [0] soud be name stdout=list() for element in Elements: ##Iterate element list for workset in Worksets: ##iterate workset list if element[0][:3] == workset[0][:3] : ##First 3 characters match between workset and assembly code we have a match, [0] is index in list[:3] is first three letters of string which is treated like an array stdout.append([element[1],workset]) ##workset[1],workset[0],workset]) break #Assign your output to the OUT variable. OUT = stdout

Comments

Popular posts from this blog

Revit area plans adding new types and references (Gross and rentable)

Powerpoint countdown and current time in slides VBA

Revit Python in Visual Studio Revit Stubs 2022 for Python Revit Intellisense