I have problem with this loop and if statement in dynamo (python scripts)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am beginner in writing python scripts in revit dynamo. I really need to used both for loop and if else statement together in one node to identify rebar size but when I run these code
import clr
import math
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import*
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
#The inputs to this node will be stored as a list in the IN variables.
Size = IN[0]
Bartype = []
for i in Size:
p = []
if Size == "9":
p = "RB-9"
elif Size == "12":
p = "DB-12"
elif Size == "16":
p = "DB-16"
elif Size == "20":
p = "DB-20"
elif Size == "25":
p = "DB-25"
elif Size == "28":
p = "DB-28"
elif Size == "32":
p = "DB-32"
elif Size == "40":
p = "DB-40"
else:
p = "n/a"
Bartype.append(p)
#Assign your output to the OUT variable.
OUT = Bartype
I obtain only n/a, while my input data have those numbers (my data is import from excel)