Sun position: remove unused prop in HDRI mode
[blender-addons.git] / curve_tools / auto_loft.py
blobc0711196ad8ff308babb0885b9290aa99d9c4c2f
1 import bpy
2 from bpy.props import BoolProperty
3 from bpy.types import Operator, Panel
4 from . import surfaces
5 from . import curves
6 from . import util
9 class OperatorAutoLoftCurves(Operator):
10 bl_idname = "curvetools.create_auto_loft"
11 bl_label = "Loft"
12 bl_description = "Lofts selected curves"
14 @classmethod
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"] = {
36 "name": "Auto Loft",
37 "description": "Auto loft from %s to %s" % (curve0.name, curve1.name),
38 "curve0": curve0.name,
39 "curve1": curve1.name}
41 return {'FINISHED'}
43 class AutoLoftModalOperator(Operator):
44 """Auto Loft"""
45 bl_idname = "curvetools.update_auto_loft_curves"
46 bl_label = "Update Auto Loft"
47 bl_description = "Update Lofts selected curves"
49 _timer = None
50 @classmethod
51 def poll(cls, context):
52 # two curves selected.
53 return True
55 def execute(self, context):
56 scene = context.scene
57 lofters = [o for o in scene.objects if "autoloft" in o.keys()]
58 # quick hack
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"])
65 if curve0 and curve1:
66 ls = surfaces.LoftedSurface(curves.Curve(curve0), curves.Curve(curve1), loftmesh.name)
67 ls.bMesh.to_mesh(loftmesh.data)
68 return {'FINISHED'}
70 def register():
71 bpy.utils.register_class(AutoLoftModalOperator)
72 bpy.utils.register_class(OperatorAutoLoftCurves)
73 bpy.types.WindowManager.auto_loft = BoolProperty(default=False,
74 name="Auto Loft")
75 bpy.context.window_manager.auto_loft = False
77 def unregister():
78 bpy.utils.unregister_class(AutoLoftModalOperator)
79 bpy.utils.unregister_class(OperatorAutoLoftCurves)
81 if __name__ == "__main__":
82 register()