def execute(self, context): #print("### TODO: OperatorLoftCurves.execute()") mesh = bpy.data.meshes.new("LoftMesh") curve0 = context.selected_objects[0] curve1 = context.selected_objects[1] ls = LoftedSurface(Curve(curve0), Curve(curve1), "AutoLoft") ls.bMesh.to_mesh(mesh) loftobj = bpy.data.objects.new(self.name, mesh) context.collection.objects.link(loftobj) loftobj["autoloft"] = True if loftobj.get('_RNA_UI') is None: loftobj['_RNA_UI'] = {} loftobj['_RNA_UI']["autoloft"] = { "name": "Auto Loft", "description": "Auto loft from %s to %s" % (curve0.name, curve1.name), "curve0": curve0.name, "curve1": curve1.name } #print(loftobj['_RNA_UI'].to_dict()) #self.report({'INFO'}, "OperatorAutoLoftCurves.execute()") return {'FINISHED'}
def modal(self, context, event): scene = context.scene wm = context.window_manager if event.type in {'ESC'}: wm.auto_loft = False if not wm.auto_loft: self.cancel(context) return {'CANCELLED'} if event.type == 'TIMER': lofters = [o for o in scene.objects if "autoloft" in o.keys()] # quick hack #print("TIMER", lofters) for loftmesh in lofters: loftmesh.hide_select = True rna = loftmesh['_RNA_UI']["autoloft"].to_dict() curve0 = scene.objects.get(rna["curve0"]) curve1 = scene.objects.get(rna["curve1"]) if curve0 and curve1: ls = LoftedSurface(Curve(curve0), Curve(curve1), loftmesh.name) ls.bMesh.to_mesh(loftmesh.data) return {'PASS_THROUGH'}
def execute(self, context): scene = context.scene lofters = [o for o in scene.objects if "autoloft" in o.keys()] # quick hack #print("TIMER", lofters) for loftmesh in lofters: #loftmesh.hide_select = True rna = loftmesh['_RNA_UI']["autoloft"].to_dict() curve0 = scene.objects.get(rna["curve0"]) curve1 = scene.objects.get(rna["curve1"]) if curve0 and curve1: ls = LoftedSurface(Curve(curve0), Curve(curve1), loftmesh.name) ls.bMesh.to_mesh(loftmesh.data) return {'FINISHED'}