Preferably not using selection, tried
bpy.data.meshes.remove don't works for it
Something like this,
- First remove the Object that uses the Curve
- Then remove the Curve data
curves = bpy.data.curves objects = bpy.data.objects scene = bpy.context.scene # remove the object obj = bpy.data.objects[object_name] cu = obj.data # the curve scene.objects.unlink(obj) objects.remove(obj) # remove the associated curve, if you need to and it doesn't have other users. curves.remove(cu)
You won't be able to remove Curve data if there are remaining Objects associated with that Curve data.
cu.users will tell you how many users the Curve has, if that returns
0, the curve data can be removed with no other steps, but if it's more than
0 then other Objects are referencing the curve and you need to clear those references first.