Set Assembly Code file - Dynamo

Set Assembly Code file - Dynamo:

# Default imports import clr clr.AddReference("RevitAPI") clr.AddReference("RevitNodes") from Autodesk.Revit.DB import * ################################# import Revit ################################# clr.ImportExtensions(Revit.GeometryConversion) ################################# clr.ImportExtensions(Revit.Elements) ################################# # Import DocumentManager and TransactionManager################################## clr.AddReference('RevitServices') ################################# import RevitServices ################################# from RevitServices.Persistence import DocumentManager ######################### from RevitServices.Transactions import TransactionManager ##################### doc = DocumentManager.Instance.CurrentDBDocument ############################# elements = IN[0] ##Elements in the model ##EXPECTS STRINGS FROM EXCEL TO START headers = IN[1] ##Headers for reference data = IN[2] ##Data ###Initialize out=[] outMain=[] outSub=[] found=0 ##Find "MARK" Position from headers for markPos, mark in enumerate(headers): if mark=='Mark': ##Found mark in headers proceed found=1 break ##BREAK loop with current header index if found==1: ##Consider adding additional parameters to key-in on other than mark for element in elements: emark=element.GetParameterValueByName('Mark') for dat in data: if dat[markPos]==emark: outMain=[] for hI, param in enumerate(headers): ##hI count based on header to corresponding data For parameters that are headers in the file outSub=[] try: outSub.append(param) ###ADD PARAMS TO Output list outSub.append(dat[hI]) ###ADD TABS + Data to output list if param == 'ASSET_CONDITION': ###NEED TO LOOK AT TARGET PARAMETERS IN REVIT AND RESET THE TYPE ACCORDING TO THE TARGET PARAMETER DATA TYPE, INT, TXT, etc. element.SetParameterByName(param,int(dat[hI])) ###Attempt set data header/param name, dat[i] corresponding data at index outSub.insert(0,"Success!(INT)") ###If it succeedes report it else: element.SetParameterByName(param,dat[hI]) ###Attempt set data header/param name, dat[i] corresponding data at index outSub.insert(0,"Success!(TXT)") ###If it succeedes report it except: ### If if failed...################################################ if param == "Assembly Code": ##SPECIAL ODD-BALL CASE for SYSTEM TYPE PARAM (Assembly Code)#### try: ##################################Assembly Code = Unifromat scan ele=UnwrapElement(element) ########## #Get the type ###################### (UNIFORMAT TYPE param) elementType = doc.GetElement(ele.GetTypeId()) ###################### # Get the parameter################### parameter = elementType.get_Parameter(BuiltInParameter.UNIFORMAT_CODE) #Set the parameter in a Transaction### TransactionManager.Instance.EnsureInTransaction(doc) parameter.Set(str(dat[hI])) ##FROM THE current DAT line of DATA return the data from the hI Index position in the list #Set the parameter end Transaction### TransactionManager.Instance.TransactionTaskDone() outSub.insert(0,"Success!(UNI)") except: outSub.insert(0,"Failed! (ALL)") outMain.append(outSub) ##Append Parameters success/fail out.append(outMain) out.insert(0,[["****Tab must be 'Sheet1'***************\n****'Mark' in row 1 must be defined****"]]) OUT=out

Comments

Popular posts from this blog

Powerpoint countdown and current time in slides VBA

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