def sculptify_scene(): scene = Blender.Scene.GetCurrent() for ob in scene.objects.selected: if not sculpty.sculptify(ob, fromObjFile=True): Blender.Draw.PupBlock("Sculptie Import Error", ["Unable to determine map size", "Please check your UVs"]) else: if ob.type == 'Mesh': scene.objects.active = ob
def sculptify_scene(): scene = Blender.Scene.GetCurrent() for ob in scene.objects.selected: if not sculpty.sculptify(ob, fromObjFile=True): Blender.Draw.PupBlock( "Sculptie Import Error", ["Unable to determine map size", "Please check your UVs"]) else: if ob.type == 'Mesh': scene.objects.active = ob
def assign_new_image(ob, could_be_mirror=False): mesh = ob.getData(False, True) name = ob.getName() activeUV = mesh.activeUVLayer mesh.activeUVLayer = "sculptie" image = mesh.faces[0].image try: width = image.getSize()[0] height = image.getSize()[1] except: if image == None: print "No image data available for object", name else: print "Can not get image data from object", name,"image",image.getName() print "Need to Resculptify object ..." sculptify(ob, force_new_image=True) mesh = ob.getData(False, True) image = mesh.faces[0].image #print "image",sel.name,"is assigned to ", ob.getName() #print "Resculptify created image", image.name, "of type", image.source if could_be_mirror: adjust_image_name(ob,image) return image object_name = ob.getName().split(os.sep)[-1] new_image = create_new_image(object_name, width, height, 32) selected_verts = mesh.verts.selected() mesh.sel = True set_map(mesh, new_image) mesh.sel = False for i in selected_verts: mesh.verts[i].sel=1 mesh.update() mesh.activeUVLayer = activeUV if could_be_mirror: adjust_image_name(ob,new_image) print "assign_new_image()ob.name:",ob.name,"new_image:",new_image.name return new_image
def main(): scene = Blender.Scene.GetCurrent() success = False Blender.Window.WaitCursor(1) Blender.SaveUndoState("Sculptify") for ob in scene.objects.selected: if sculptify(ob): success = True #Blender.Window.WaitCursor(0) if not success: Blender.Draw.PupBlock("Conversion Error", ["No suitable objects", "are selected"]) Blender.Redraw()