Ok I’m having two issues creating a for loop to go through curves in Python. My first issue is I’m getting a warning that the ‘Curve’ object is unsubscriptable. Is it not possible to use curves in Python?
See warning below:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 17, in
TypeError: ‘Curve’ object is unsubscriptable
The second issue (which may be tied to the warning) is I’m trying to cycle through the list IN[0] and output an index value to correspond to the list IN[1]. So I can group the values in list IN[0] to match IN[1].
I’ve been using Python Tutor as a workplace to test my Python instead of running Dynamo over and over. Below is the visual of what I’m trying to do. (I input letters into the list in Python Tutor instead of the curves.) My desired output is shown on the notepad.
Here is my code in the Python Script node:
# Enable Python support and load DesignScript library
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.
intlist = IN[0] #intersecting curve list
correctlist = IN[1] #correct curve layout
corcount = IN[2] #correct curve layout count
intcount = IN[3] #intersecting curve count
newcorcount = corcount - 1
int = intcount
out = []
liscount = [[7],[3]]
#i = 0 #inlist count
#j = 0 #outer correctlist count
#k = 0 #inner correctlist count
for a in intlist:
#a == intlist[0-11]
for b in range(corcount):
#b == first part of correct list either 0 or 1
z = liscount[0][b]
for i in range(z):
#ii = either 7 or 3(in this case)
temp = correctlist[b][i]
if a == temp:
out.append(j) #use append??
OUT = out
With the code part I know I just don’t have it set up right. Just not sure how.
But I don’t want to get it figured out and realize that its not possible to compare two curves in Dynamo/Python.
Or maybe there is a way to do this with nodes that I’m not seeing. I had a similar problem not too long ago that I solved with Python that one I’m struggling.
I appreciate any help or direction that you can give.