Recently I wrote a script that is going to act as a function for a bigger project, when I run this script for some reason it never stops. I was wondering from a sheer coding perspective could someone tell me where exactly my script is continuously looping, and why?
def groupmouths(elist):
edgelist = []
mesh = elist[1]
elist = elist[0]
for i in elist:
used = 0
for e in edgelist:
for f in e:
if i.key[0] in f.key or i.key[1] in f.key:
e.append(i)
used = 1
if used == 0:
edgelist.append([i])
return[edgelist, mesh]
Well… I was hard to figure out what this script really does… :eek:
I think it is to produce a list of adjacent edges in a mesh… If so, there is a better way to do that
Your input parameter seems to contain data for two elements - a mesh and indices of edges of the same mesh… Then, your edgelist is ever growing and after some loops it is also hard to get processed in reasonable time as PKHG mentioned.
hmmm, you are right in thinking that the script is meant to come up with a list of adjacent edges, but why would the list continue growing forever, it only appends i for values in elist, checking if they already exist in edgelist.
And Abidos, my script’s input is a series of edges, the goal is then to group them into sublists of connected edges, for example: edgelist = [[edge1,edge2,edge3,edge4],[edge5,edge6,edge7],[edge8,edge9,edge10,edge11,edge12]]
do you have a solution of how to do this?
One of functions in my modules (see here) is about info on which edges in a mesh are connected at which vertex. Obviously, adjacent edges, right?? Extracted from the module it is:
def Make_vie(me):
vie = dict([(v.index,[]) for v in me.verts])
for ed in me.edges:
for key in ed.key:
vie[key].append(ed.index)
return vie
resulting in a dictionary like this (the result for the default cube):
In the modules I have procs for adjacent faces (fif), verts in each face (fiv), edges in each face (fie) and such… This helps a lot while analyzing a mesh. :spin: