Newer
Older
description="Degrees or radians",
items=Angle_types
)
name="Width",
default=2.0,
min=0.0, soft_min=0,
unit='LENGTH',
description="Width"
)
name="Length",
default=2.0,
min=0.0, soft_min=0.0,
unit='LENGTH',
description="Length"
)
Simple_rounded : FloatProperty(
name="Rounded",
default=0.0,
min=0.0, soft_min=0.0,
unit='LENGTH',
description="Rounded corners"
)
# Curve Options
shapeItems = [
('2D', "2D", "2D shape Curve"),
('3D', "3D", "3D shape Curve")]
name="2D / 3D",
items=shapeItems,
description="2D or 3D Curve"
)
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
outputType : EnumProperty(
name="Output splines",
description="Type of splines to output",
items=[
('POLY', "Poly", "Poly Spline type"),
('NURBS', "Nurbs", "Nurbs Spline type"),
('BEZIER', "Bezier", "Bezier Spline type")],
default='BEZIER'
)
use_cyclic_u : BoolProperty(
name="Cyclic",
default=True,
description="make curve closed"
)
endp_u : BoolProperty(
name="Use endpoint u",
default=True,
description="stretch to endpoints"
)
order_u : IntProperty(
name="Order u",
default=4,
min=2, soft_min=2,
max=6, soft_max=6,
description="Order of nurbs spline"
)
handleType : EnumProperty(
name="Handle type",
default='VECTOR',
description="Bezier handles type",
items=[
('VECTOR', "Vector", "Vector type Bezier handles"),
('AUTO', "Auto", "Automatic type Bezier handles")]
)
def draw(self, context):
layout = self.layout
# general options
col = layout.column()
col.prop(self, "Simple_Type")
l = 0
s = 0
if self.Simple_Type == 'Line':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_endlocation")
v = Vector(self.Simple_endlocation) - Vector(self.Simple_startlocation)
l = v.length
if self.Simple_Type == 'Distance':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_length")
col.prop(self, "Simple_center")
l = self.Simple_length
if self.Simple_Type == 'Angle':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_length")
col.prop(self, "Simple_angle")
#row = layout.row()
#row.prop(self, "Simple_degrees_or_radians", expand=True)
if self.Simple_Type == 'Circle':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_sides")
col.prop(self, "Simple_radius")
l = 2 * pi * abs(self.Simple_radius)
s = pi * self.Simple_radius * self.Simple_radius
if self.Simple_Type == 'Ellipse':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_a", text="Radius a")
col.prop(self, "Simple_b", text="Radius b")
l = pi * (3 * (self.Simple_a + self.Simple_b) -
sqrt((3 * self.Simple_a + self.Simple_b) *
(self.Simple_a + 3 * self.Simple_b)))
s = pi * abs(self.Simple_b) * abs(self.Simple_a)
if self.Simple_Type == 'Arc':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_sides")
col.prop(self, "Simple_radius")
col = box.column(align=True)
col.prop(self, "Simple_startangle")
col.prop(self, "Simple_endangle")
#row = layout.row()
#row.prop(self, "Simple_degrees_or_radians", expand=True)
l = abs(pi * self.Simple_radius * (self.Simple_endangle - self.Simple_startangle) / 180)
if self.Simple_Type == 'Sector':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_sides")
col.prop(self, "Simple_radius")
col = box.column(align=True)
col.prop(self, "Simple_startangle")
col.prop(self, "Simple_endangle")
#row = layout.row()
#row.prop(self, "Simple_degrees_or_radians", expand=True)
l = abs(pi * self.Simple_radius *
(self.Simple_endangle - self.Simple_startangle) / 180) + self.Simple_radius * 2
s = pi * self.Simple_radius * self.Simple_radius * \
abs(self.Simple_endangle - self.Simple_startangle) / 360
if self.Simple_Type == 'Segment':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_sides")
col.prop(self, "Simple_a", text="Radius a")
col.prop(self, "Simple_b", text="Radius b")
col = box.column(align=True)
col.prop(self, "Simple_startangle")
col.prop(self, "Simple_endangle")
#row = layout.row()
#row.prop(self, "Simple_degrees_or_radians", expand=True)
la = abs(pi * self.Simple_a * (self.Simple_endangle - self.Simple_startangle) / 180)
lb = abs(pi * self.Simple_b * (self.Simple_endangle - self.Simple_startangle) / 180)
l = abs(self.Simple_a - self.Simple_b) * 2 + la + lb
sa = pi * self.Simple_a * self.Simple_a * \
abs(self.Simple_endangle - self.Simple_startangle) / 360
sb = pi * self.Simple_b * self.Simple_b * \
abs(self.Simple_endangle - self.Simple_startangle) / 360
s = abs(sa - sb)
if self.Simple_Type == 'Rectangle':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_width")
col.prop(self, "Simple_length")
col.prop(self, "Simple_rounded")
box.prop(self, "Simple_center")
l = 2 * abs(self.Simple_width) + 2 * abs(self.Simple_length)
s = abs(self.Simple_width) * abs(self.Simple_length)
if self.Simple_Type == 'Rhomb':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_width")
col.prop(self, "Simple_length")
col.prop(self, "Simple_center")
g = hypot(self.Simple_width / 2, self.Simple_length / 2)
l = 4 * g
s = self.Simple_width * self.Simple_length / 2
if self.Simple_Type == 'Polygon':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_sides")
col.prop(self, "Simple_radius")
if self.Simple_Type == 'Polygon_ab':
box = layout.box()
col = box.column(align=True)
col.label(text="Polygon ab Options:")
col.prop(self, "Simple_sides")
col.prop(self, "Simple_a")
col.prop(self, "Simple_b")
if self.Simple_Type == 'Trapezoid':
box = layout.box()
col = box.column(align=True)
col.label(text=self.Simple_Type + " Options:")
col.prop(self, "Simple_a")
col.prop(self, "Simple_b")
col.prop(self, "Simple_h")
box.prop(self, "Simple_center")
g = hypot(self.Simple_h, (self.Simple_a - self.Simple_b) / 2)
l = self.Simple_a + self.Simple_b + g * 2
s = (abs(self.Simple_a) + abs(self.Simple_b)) / 2 * self.Simple_h
row = layout.row()
row.prop(self, "shape", expand=True)
# output options
col = layout.column()
col.label(text="Output Curve Type:")
col.row().prop(self, "outputType", expand=True)
if self.outputType == 'NURBS':
col.prop(self, "order_u")
elif self.outputType == 'BEZIER':
col.row().prop(self, 'handleType', expand=True)
col = layout.column()
col.row().prop(self, "use_cyclic_u", expand=True)
box.prop(self, "Simple_startlocation")
box.prop(self, "Simple_rotation_euler")
if l != 0 or s != 0:
box = layout.box()
box.label(text="Statistics:", icon="INFO")
if l != 0:
l_str = str(round(l, 4))
box.label(text="Length: " + l_str)
if s != 0:
s_str = str(round(s, 4))
box.label(text="Area: " + s_str)
@classmethod
def poll(cls, context):
return context.scene is not None
def execute(self, context):
# turn off 'Enter Edit Mode'
use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode
bpy.context.preferences.edit.use_enter_edit_mode = False
# main function
self.align_matrix = align_matrix(context, self.Simple_startlocation)
main(context, self, self.align_matrix, use_enter_edit_mode)
if use_enter_edit_mode:
bpy.ops.object.mode_set(mode = 'EDIT')
# restore pre operator state
bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode
return {'FINISHED'}
classes = [
Simple,
]
from bpy.utils import register_class
for cls in classes:
register_class(cls)
bpy.types.VIEW3D_MT_curve_add.append(menu)
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
bpy.types.VIEW3D_MT_curve_add.remove(menu)
if __name__ == "__main__":
register()