1
$\begingroup$

The following code separates unconnected splines into individual curve objects just fine (as far as I can tell).

curve = bpy.context.object

if len(curve.data.splines) > 1:

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.curve.select_all(action='DESELECT')

while len(curve.data.splines) > 1:

    for point in curve.data.splines[0].bezier_points:
        point.select_control_point = True

    bpy.ops.curve.separate()
    
bpy.ops.object.mode_set(mode='OBJECT')

This code snippet is part of a much larger addon and I make a habit of avoiding bpy.ops so I don't have to worry about context or changing the active object.

Is there a relatively simple way of doing the same thing without bpy.ops or should I just stick to bpy.ops.curve.separate() for it's simplicity?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.