2 from bpy
.props
import BoolProperty
3 from bpy
.types
import Operator
, Panel
9 class OperatorAutoLoftCurves(Operator
):
10 bl_idname
= "curvetools.create_auto_loft"
12 bl_description
= "Lofts selected curves"
15 def poll(cls
, context
):
16 return util
.Selected2Curves()
18 def execute(self
, context
):
19 #print("### TODO: OperatorLoftcurves.execute()")
20 mesh
= bpy
.data
.meshes
.new("LoftMesh")
22 curve0
= context
.selected_objects
[0]
23 curve1
= context
.selected_objects
[1]
25 ls
= surfaces
.LoftedSurface(curves
.Curve(curve0
), curves
.Curve(curve1
), "AutoLoft")
27 ls
.bMesh
.to_mesh(mesh
)
29 loftobj
= bpy
.data
.objects
.new(self
.name
, mesh
)
31 context
.collection
.objects
.link(loftobj
)
32 loftobj
["autoloft"] = True
33 if loftobj
.get('_RNA_UI') is None:
34 loftobj
['_RNA_UI'] = {}
35 loftobj
['_RNA_UI']["autoloft"] = {
37 "description": "Auto loft from %s to %s" % (curve0
.name
, curve1
.name
),
38 "curve0": curve0
.name
,
39 "curve1": curve1
.name
}
43 class AutoLoftModalOperator(Operator
):
45 bl_idname
= "curvetools.update_auto_loft_curves"
46 bl_label
= "Update Auto Loft"
47 bl_description
= "Update Lofts selected curves"
51 def poll(cls
, context
):
52 # two curves selected.
55 def execute(self
, context
):
57 lofters
= [o
for o
in scene
.objects
if "autoloft" in o
.keys()]
59 #print("TIMER", lofters)
61 for loftmesh
in lofters
:
62 rna
= loftmesh
['_RNA_UI']["autoloft"].to_dict()
63 curve0
= scene
.objects
.get(rna
["curve0"])
64 curve1
= scene
.objects
.get(rna
["curve1"])
66 ls
= surfaces
.LoftedSurface(curves
.Curve(curve0
), curves
.Curve(curve1
), loftmesh
.name
)
67 ls
.bMesh
.to_mesh(loftmesh
.data
)
71 bpy
.utils
.register_class(AutoLoftModalOperator
)
72 bpy
.utils
.register_class(OperatorAutoLoftCurves
)
73 bpy
.types
.WindowManager
.auto_loft
= BoolProperty(default
=False,
75 bpy
.context
.window_manager
.auto_loft
= False
78 bpy
.utils
.unregister_class(AutoLoftModalOperator
)
79 bpy
.utils
.unregister_class(OperatorAutoLoftCurves
)
81 if __name__
== "__main__":