I am new to Python, and I feel like I am missing something basic. Forgive me if that is true, but please point me toward something that explains the concept because I have been trying to work around this for a while and I am out of ideas.
I have some surfaces and I want to use them to split each other. I am using the SplitBreps method. It seems to work, generally. The code below splits a brep: segSurfs contains two surfaces. I ignore the first and keep the second as my remainder.
Inside the for loop, I want the first element of remainder to be saved to TTops and save the second as my remainder for the next loop.
But when I attempt this, it will not let me get at the elements inside segSurfs. I have tried the for loop below- for j in segSurfs- and I have tried segSurfs[0], segSurfs[1]. These work fine outside the ‘for i in range(TFaces.Count):’ loop, but not inside it. I am, however, able to print the ObjectType of segSurfs[0] from within the loop.
That’s the problem in a nutshell- the split happens and I can access it if I do it once. As soon as I set it inside a for loop, I cannot.
I get a runtime error saying segSurfs is not subscriptable or that it is “iteration over non-sequence type None Type”
segSurfs = []
TBreps = []
TVBreps = rs.coercebrep(TVSurf[0])
TTops =[]
tTop = []
TBreps.Add(rs.coercebrep(TFaces[0]))
segSurfs = rs.SplitBrep(TVBreps,TBreps[0],False)
for i in segSurfs:
if i == 0:
continue
remainder = i
for i in range(TFaces.Count):
if i == 0: #skip the first iteration
continue
TBreps.Add(rs.coercebrep(TFaces[i]))
segSurfs = rs.SplitBrep(remainder,TBreps[i],False)
tops.Add(rs.coerceguid(segSurfs))
for j in segSurfs:
if j == 0:
TTops.Add(j)
remainder = j
Thanks for any help
7 posts - 3 participants