finish rail section operator
This commit is contained in:
parent
79a04f1496
commit
0af7f204dc
@ -55,7 +55,7 @@ class BALLANCE_OT_add_elements(bpy.types.Operator):
|
|||||||
class BALLANCE_OT_add_rail(bpy.types.Operator):
|
class BALLANCE_OT_add_rail(bpy.types.Operator):
|
||||||
"""Add rail"""
|
"""Add rail"""
|
||||||
bl_idname = "ballance.add_rail"
|
bl_idname = "ballance.add_rail"
|
||||||
bl_label = "Add unique elements"
|
bl_label = "Add rail section"
|
||||||
bl_options = {'UNDO'}
|
bl_options = {'UNDO'}
|
||||||
|
|
||||||
rail_type: bpy.props.EnumProperty(
|
rail_type: bpy.props.EnumProperty(
|
||||||
@ -79,6 +79,40 @@ class BALLANCE_OT_add_rail(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
# create one first
|
||||||
|
bpy.ops.mesh.primitive_circle_add(vertices=8,
|
||||||
|
radius=self.rail_radius,
|
||||||
|
fill_type='NOTHING',
|
||||||
|
calc_uvs=False,
|
||||||
|
enter_editmode=False,
|
||||||
|
align='WORLD',
|
||||||
|
location=(0.0, 0.0, 0.0))
|
||||||
|
|
||||||
|
firstObj = bpy.context.selected_objects[0]
|
||||||
|
|
||||||
|
# for double rail
|
||||||
|
if self.rail_type == 'DOUBLE':
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
bpy.ops.mesh.primitive_circle_add(vertices=8,
|
||||||
|
radius=self.rail_radius,
|
||||||
|
fill_type='NOTHING',
|
||||||
|
calc_uvs=False,
|
||||||
|
enter_editmode=False,
|
||||||
|
align='WORLD',
|
||||||
|
location=(self.rail_span, 0.0, 0.0))
|
||||||
|
secondObj = bpy.context.selected_objects[0]
|
||||||
|
|
||||||
|
# merge
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
bpy.context.view_layer.objects.active = firstObj
|
||||||
|
firstObj.select_set(True)
|
||||||
|
secondObj.select_set(True)
|
||||||
|
bpy.ops.object.join()
|
||||||
|
|
||||||
|
# apply 3d cursor
|
||||||
|
firstObj.matrix_world = bpy.context.scene.cursor.matrix
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
@ -89,6 +123,7 @@ class BALLANCE_OT_add_rail(bpy.types.Operator):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.prop(self, "rail_type")
|
layout.prop(self, "rail_type")
|
||||||
layout.prop(self, "rail_radius")
|
layout.prop(self, "rail_radius")
|
||||||
|
if self.rail_type == 'DOUBLE':
|
||||||
layout.prop(self, "rail_span")
|
layout.prop(self, "rail_span")
|
||||||
|
|
||||||
def addSceneAndChangePos(obj):
|
def addSceneAndChangePos(obj):
|
||||||
|
Loading…
Reference in New Issue
Block a user