Hello,
I created a simple dynamo for checking intersection which is the first watch node in the screen capture. And I want to simplify the result to the second watch node. For this I
wrote a script to do it which is successful as shown.
However, when I tried to integrated the second part into the first part of the Python script. It simply doesn’t work and I cannot figure out the reason.
Could anyone tell me why it cannot work?
Here is the script I used in the first python node:
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
geo1 = IN[0] #Geometry 1
geo2 = IN[1] #Geometry 2
def intersection(in1):
x = []
for a in geo2:
x.append(in1.Intersect(a))
return x
result = list(map(intersection, geo1))
temp = []
output = []
def flatsub(data):
for item in data:
if isinstance(item, list):
if not len(item):
temp.append(0)
else:
flatsub(item)
else:
temp.append(item)
for element in result:
if isinstance(element, list):
flatsub(element)
output.append(temp)
temp = []
else:
output.append(element)
# Assign your output to the OUT variable.
OUT = output
And here is the second one which is the same of the lower part of the first python script:
# 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.
dataEnteringNode = IN
# Place your code below this line
result = IN[0]
temp = []
output = []
def flatsub(data):
for item in data:
if isinstance(item, list):
if not len(item):
temp.append(0)
else:
flatsub(item)
else:
temp.append(item)
for element in result:
if isinstance(element, list):
flatsub(element)
output.append(temp)
temp = []
else:
output.append(element)
# Assign your output to the OUT variable.
OUT = output
Thanks.
Austin