so i guess the bpy.ops command is working also but did not test it
need also to enter in edit and edge mode !
but i would like to see this sript for edges non manifold work again
it could be use for other things also
have you translated the concave to convex script from 2.49
you could re issue this one in forum it might be usefull for other people!
anyway let me know if you do it
I’m struggling on how to set the curve mode via script, the data path says ‘dimensions’, but that is a vector doing something like bounding box dimensions…
I know it’s going to be something simple and obvious, but…
import bpy
def fill_poly_tri(o):
# MAKE SURE OBJECT IS SELECTED
bpy.ops.object.select_all(action="DESELECT")
bpy.context.scene.objects.active=o
o.select=True
# SET MODE
m=bpy.context.mode
if bpy.context.mode!='OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
# DUPLICATE
bpy.ops.object.duplicate()
# MAKE SURE OBJECT IS SELECTED
oo=bpy.context.scene.objects.active
#bpy.ops.object.select_all(action="DESELECT")
#bpy.context.scene.objects.active=oo
o.select=False
oo.select=True
# CONVERT, SET AND RECONVERT
bpy.ops.object.convert(target='CURVE')
bpy.context.active_object.data.dimensions='2D'
#bpy.context.object.data.dimensions='2D'
bpy.ops.object.convert(target='MESH')
# RE-SET MODE
if bpy.context.mode!=m:
bpy.ops.object.mode_set(mode=m)
return oo
def build_face_list(o):
fl=[]
for f in o.data.faces:
#print("f:",f.index)
fl.append(f.index)
return fl
def edit_deselect(o):
bpy.context.tool_settings.mesh_select_mode=[True,False,False]
for v in o.data.vertices:
v.select=False
bpy.context.tool_settings.mesh_select_mode=[False,True,False]
for v in o.data.edges:
v.select=False
bpy.context.tool_settings.mesh_select_mode=[False,False,True]
for v in o.data.faces:
v.select=False
return
def linked_faces(o,i):
print("In LINKED_FACES")
edit_deselect(o)
bpy.ops.object.mode_set(mode='OBJECT')
o.data.faces[i].select=True
bpy.ops.object.mode_set(mode='EDIT')
bpy.context.tool_settings.mesh_select_mode=[False,False,True]
bpy.ops.mesh.select_linked()
bpy.ops.object.editmode_toggle()
bpy.ops.object.editmode_toggle()
l=[]
for f in o.data.faces:
if f.select==True:
l.append(f.index)
return l
def intersect(e,ee): # sub e from ee
e=set(e)
ee=set(ee)
#e=e-ee
e=ee-e
e=set(e)
ret=[]
for i in e:
ret.append(i)
return ret
def group_faces(o):
fl=build_face_list(o)
fl2=fl
# SET MODE
m=bpy.context.mode
if bpy.context.mode!='EDIT':
bpy.ops.object.mode_set(mode='EDIT')
# TAKE FIRST FACE INDEX
sfl=[]
tot=len(fl2)
while tot>0:
i=fl2[0]
l=linked_faces(o,i)
#print("l:",l)
sfl.append(l)
fl2=intersect(l,fl2) # sub e from ee
tot=len(fl2)
#print("fl2:",fl2)
# RE-SET MODES
bpy.context.tool_settings.mesh_select_mode=[True,False,False]
if bpy.context.mode!=m:
bpy.ops.object.mode_set(mode=m)
return sfl
o=bpy.context.object
oo=fill_poly_tri(o)
sfl=group_faces(oo)
for fl in sfl:
print("fl:",fl)
If you create a mesh and put in it two closed polylines. Then with it selected you run the script, for some reason the second group of faces also includes the first!!!
I think it’ll be somewhere in linked_faces(), but just can’t see it as such, l[] is reset and everything should be deselected, but i’m thinking it’s to do with the deselect…
Your code is very dense to read, with highly undescriptive names for variables and objects I’m going to sound old and cranky but that’s a bad habit you best break early, especially if you write a lot of code.
Some may say, “too late was the cry”, but I know what you mean, TBH it’s with scripts that I tend to do it, in C and such I don’t, I comment more, use larger and more descriptive variables.
Also, I taught myself, so i’ve never had anybody forcing me and when I do freehand notes it’s like maths with single character notation. Kernighan is the biggest influence probably in style terms.
Again, TBH, there’s more comments in there than normal with my Python… :rolleyes: