def execute(self, context): # this is almost same as getobjectoutline, just without the need of operation data ob = bpy.context.active_object self.silh = utils.getObjectSilhouete("OBJECTS", objects=bpy.context.selected_objects) poly = Polygon.Polygon() for p in self.silh: for ci in range(0, len(p)): poly.addContour(p[ci]) bpy.context.scene.cursor_location = (0, 0, 0) polygon_utils_cam.polyToMesh(ob.name + "_silhouette", poly, 0) # bpy.ops.object.convert(target="CURVE") bpy.context.scene.cursor_location = ob.location bpy.ops.object.origin_set(type="ORIGIN_CURSOR") return {"FINISHED"}
def execute(self, context):#this is almost same as getobjectoutline, just without the need of operation data ob=bpy.context.active_object self.silh=utils.getObjectSilhouete('OBJECTS', objects=bpy.context.selected_objects) poly=Polygon.Polygon() for p in self.silh: for ci in range(0,len(p)): poly.addContour(p[ci]) bpy.context.scene.cursor_location=(0,0,0) polygon_utils_cam.polyToMesh(ob.name+'_silhouette',poly,0)# bpy.ops.object.convert(target='CURVE') bpy.context.scene.cursor_location=ob.location bpy.ops.object.origin_set(type='ORIGIN_CURSOR') return {'FINISHED'}
def sliceObject(ob): settings=bpy.context.scene.cam_slice layers = getSlices(ob, settings.slice_distance) #print(layers) sliceobjects=[] i=1 for layer in layers: pi=1 layerpolys=[] for slicechunk in layer: #these functions here are totally useless conversions, could generate slices more directly, just lazy to write new functions #print (slicechunk) nchp=[] for p in slicechunk: nchp.append((p[0],p[1])) #print(slicechunk) ch = chunk.camPathChunk(nchp) #print(ch) pslices=chunk.chunksToPolys([ch]) #p1=outlinePoly(pslice,o.dist_between_paths,o.circle_detail,o.optimize,o.optimize_threshold,False) #print(pslices) for pslice in pslices: p = pslice#-p1 #print(p) text = '%i - %i' % (i,pi) bpy.ops.object.text_add() textob = bpy.context.active_object textob.data.size = 0.0035 textob.data.body = text textob.data.align = 'CENTER' #print(len(ch.points)) sliceobject = polygon_utils_cam.polyToMesh('slice',p,slicechunk[0][2]) textob.location=(0,0,0) textob.parent=sliceobject sliceobject.data.extrude = settings.slice_distance/2 sliceobject.data.dimensions = '2D' sliceobjects.append(sliceobject) pi+=1 #FIXME: the polys on same layer which are hollow are not joined by now, this prevents doing hollow surfaces :( #for p in layerpolys: #for p1 in layerpolys: i+=1 for o in sliceobjects: o.select=True bpy.ops.group.create(name='slices')