Hi, is there someway I can get FamilyInstance.GetHost to handle empty lists to use the list structure further down the track to tag elements in different views? Messing around it dosn’t handle nulls either. I could replace the empty with something else from the model. But this relies on that element being in the model
Is there a reason why retaining the list structure important in this instance?
I would be either ‘cleaning’ my list structure before FamilyInstance.GetHost
or
deconstruct the list, pump one list into FamilyInstance.GetHost and reconstruct the list after.
Hi, to make sure the right elements are tagged on the right view. How would you reconstruct the list after?
Find lists that are not empty, apply the function to those lists, then reconstruct after with this code
# Load the Python Standard and DesignScript Libraries
import sys
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.
ogList = IN[0]
indices = IN[1]
newList = IN[2]
# Place your code below this line
newListInd = 0
for ind, nList in zip(indices, newList):
ogList[ind] = newList[newListInd]
newListInd + 1
# Assign your output to the OUT variable.
OUT = ogList
ApplyFunctionAndReconstructList.dyn (16.3 KB)
In this instance, I didnt write the Reconstruct List Python Node to take into consideration single items.
To remedy this you’d have to modify to firstly check if items are lists or not.
See here
and if not, turn them into a list with
if isinstance(IN[0], list):
var1 = (IN[0])
else:
var1 = [(IN[0])]
Thanks this is great. I might need to try make a node out of it. There’s just a contentious problem of each node after needing to be reconstructed. Its actually crazy. So many cant handle empties and maintaining list structure can be so important
Your response to the other person. Is that extra code to make your python code more robust? Where would it be inserted?
Actually… just had to run the fixed bit through and reconstruct at the end
hi @andy.leong I did that same theory as above for something else. But its reconstructing the list missing elements. Cant work out why. Seems to stop at 6 indices.
I need to see the code in your python node.
And also what you’re feeding into it.
The code is the same as yours above. It worked fine with the windows, Did same theory with walls but get this result of the list constructing to 6
# Load the Python Standard and DesignScript Libraries
import sys
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.
ogList = IN[0]
indices = IN[1]
newList = IN[2]
# Place your code below this line
newListInd = 0
for ind, nList in zip(indices, newList):
ogList[ind] = newList[newListInd]
newListInd + 1
# Assign your output to the OUT variable.
OUT = ogList
your screenshot shows that none of the lists are empty
therefore whatever function you are applying is applying to all the lists and then replacing the original ones with the new ones.
check what you are doing with the lists when the function is applied (its offscreen so i can’t see it)
this list should match the original one in terms of number of items.
It’s the same structure, that list is matching the other. For some reason its reducing elements. Sorry more clearer whats going on if you couldn’t see it
are you sure there are 9 items in this list boxed in red? i cant see…
its really hard to troubleshoot something without having access to the entire script/ file.
For sure. It’s dynamo 1.3 if your keen to look
Tag CurtainWallsDoorsRoomsWindows By Selected View.dyn (218.5 KB)
I think my previous code was written incorrectly.
Wasn’t using a zip function properly. Try this.
# Load the Python Standard and DesignScript Libraries
import sys
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.
ogList = IN[0]
indices = IN[1]
newList = IN[2]
# Place your code below this line
for ind, nList in zip(indices, newList):
ogList[ind] = nList
# Assign your output to the OUT variable.
OUT = ogList
boom! works thanks mate