Hi All,
I’m writing a small code block to determine whether an Element is Flipped. I’m basing my code on that contained within the DanEDU.Element.Flipped block, except that I would like the output as a basic Boolean version of the input list.
The Dan.EDU block outputs the actual element IDs into specific lists; but I’d rather avoid the graph gymnastics I would need to do to turn this back into a Boolean list, and just get the Boolean output. All credit to DanEDU for their module!
I’ll just state right here that I have very little experience with Python, and while I can pretty easily follow what a piece of Python code does, I don’t have much idea how to make it do what I want. I’m learning by doing…
The code I have written looks like this:
#Copyright(c) 2014-2016, DanEDU Dynamo
#Erik Falck Jørgensen, Technical University of Denmark (DTU)
#Modified (butchered?) by Adrian Esdaile
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
#Inputs is stored in the IN variable
element = list(UnwrapElement(IN[0]))
#check if element is FacingFlipped
list0 = [ ( True if i.FacingFlipped else False ) for i in element ]
#Assign output to the OUT variable
OUT = list0
This works for one Element, but doesn’t work for a list, and I can’t work out why. I only get one single output, not a list of outputs. I have copied (cargo-cult style) ways of doing this from other Python code, but the way Dynamo obscures what the Python is or isn’t doing makes working out what I’m doing wrong very difficult.
Could someone please point out what I’m doing wrong here?
Addendum:
I read the suggested similar topic which had another method of building a list, and wrote the following code based on that example. it works even worse; the output is null. I can’t work out why, because the code I based it on does work.
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
#Inputs is stored in the IN variable
element = list(UnwrapElement(IN[0]))
list0 = []
for i in element
if i.FacingFlipped == True
list0.append(True)
else
list0.append(False)
#Assign output to the OUT variable
OUT = list0
Inlcuded DYN file: Is_It_Flipped.dyn (3.6 KB)