i did a simple list.append in python and it works for a define liste inside python. But when im trying to add a input for Dynamo use, it seems i had an issue.
here the code :
layer = IN[0]
styles=[]
for i in layer[]:
if i == red :
styles.append("0.13mm")
elif i == yellow:
styles.append ("0.18mm")
else :
styles.append ("0.13mm")
OUT = styles
im sure it an noob question, but help will be appreciate.
layer = IN[0]
styles=[]
for i in layer:
if i == "red" :
styles.append("0.13mm")
elif i == "yellow":
styles.append ("0.18mm")
else :
styles.append ("0.13mm")
OUT = styles
i’ll show you later the result, the main goal is to select all line style from Autocad (which is by color or layer) and transfert them to Revit line style.
Couple of housekeeping comments. First and foremost, please format code posted using the “```” so that its displayed properly. Secondly please write a clear and concise description in the title of the post. “Python input” is not exactly descriptive.
Some further knowledge for you is that you could do the following to your code so it can adapt without modification to a increased amount of checks in the future(code and image show below).
Code:
#modified by Brendan Cassidy
styles=[]
#loop for main input list
for i in IN[0]:
temp_list=[]
#loop for the comparison
for b in IN[1]:
if i == b[0]:
temp_list=b[1]
#Checks if list is empty if yes adds 0.00mm to element
if temp_list:
styles.append(temp_list)
else :
styles.append("0.00mm")
OUT = styles