2
$\begingroup$

I need to select all curve objects in my scene that have their bevel geometry set to OBJECT and share the same “profile object” (bevel object):

bpy.context.object.data.bevel_object = bpy.data.objects["MY EXTRUSION OBJECT"]

Or do it in the “reversed” way - first select a curve object that is shared between multiple curve objects as their profile, and then select those objects. Either of the above will satisfy me.

I guess that would be some simple script? Can you help?

$\endgroup$
0

2 Answers 2

4
+50
$\begingroup$

Using the second method that can be this script:

import bpy

# get the bevel object as the active one
bevel_object = bpy.context.active_object
# or get it by its name
#bevel_object = bpy.context.scene.objects["bevel object name"]

# loop over all objects in the scene
for obj in bpy.context.scene.objects:
    # select flag: 
    # a curve 
    # in object bevel mode 
    # that has the bevel object we want
    select = obj.type == 'CURVE' \
            and obj.data.bevel_mode == 'OBJECT' \
            and obj.data.bevel_object == bevel_object
    
    # select if yes / unselect if no
    obj.select_set(select)

For the first method, if you have several bevel objects in use the selection may mix everyone... so I don't think this is easier.

$\endgroup$
1
  • 1
    $\begingroup$ I dared to use my lack of coding skill and even simplified the code a little. Anyway, thank you very much for your input. This is exactly what I needed :) $\endgroup$
    – michalpe
    Commented May 4, 2023 at 16:22
1
$\begingroup$

That's the slightly simplified version:

import bpy
for obj in bpy.context.scene.objects:
    select = obj.type == 'CURVE' \
        and obj.data.bevel_mode == 'OBJECT' \
        and obj.data.bevel_object == bpy.context.active_object
    obj.select_set(select)
$\endgroup$
1
  • 2
    $\begingroup$ The "simplification" here is resigning from bevel_object name and just using its value directly in the following code, plus removing comments. If you really want to code golf the shit out of this, try from bpy import context as C;for o in C.scene.objects:o.select_set(o.type=='CURVE'and o.data.bevel_mode=='BEVEL'and o.data.bevel_object==C.object) $\endgroup$ Commented May 6, 2023 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .