Code:
class CurveCreate(bpy.types.Operator):
bl_idname = "curve.create_operator"
bl_label = "Curvecreate"
bl_description = "Duplicates the selected edges and converts them into curves"
bl_options = {"REGISTER"}
def execute(self, context):
bpy.ops.mesh.duplicate_move(MESH_OT_duplicate={"mode":1}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((0, 0, 0), (0, 0, 0), (0, 0, 0)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":False, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False})
bpy.ops.mesh.separate(type='SELECTED')
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.convert(target='CURVE')
bpy.context.object.data.fill_mode = 'FULL'
bpy.context.object.data.bevel_depth = 0.15
bpy.context.object.data.bevel_resolution = 3
bpy.context.object.data.splines[0].use_smooth = True
self.report({'INFO'}, "Curve Created !")
return {"FINISHED"}
Question:
This is what I want to do:
What I want the code to do:
- Duplicate the selected edges.
- Separate the selected edges.
- Go back to object mode.
- Select the newly separated edges (this is what I cant do).
- Convert the selected separated edges into curve.
- Adjust some curve settings.
Now the problem is that when Step 3 has been executed that is, going back to object mode I find that the Active object is actually the cube and not the separated edges. Hence the remaining steps get applied to the cube instead. Both the cube and separated edges are already selected when returning to object mode but the cube is the actual Active object.
How do I set the newly separated edges as the Active object in this case?