0
$\begingroup$

I have imported a large IFC-file using BlendeBIM and want to select all objects with some transparency (viewport display color alpha > 0) and wonder how to do this with a python script? Any ideas?

$\endgroup$

1 Answer 1

3
$\begingroup$

The viewport color can be accessed with bpy.types.Object.color and the alpha is the fourth element of the color iterator : $(Red, Green, Blue, Alpha)$.

import bpy

for obj in bpy.context.selectable_objects:
    obj.select_set(obj.color[3] < 1)
    
# Not mandatory : Change active object
bpy.context.view_layer.objects.active = bpy.context.selected_objects[0]
$\endgroup$
2
  • $\begingroup$ Thanks a lot. In this case most of the window objects consists of solid and transparent parts. I need to separate the glazed/transparent part for each object into a new object with only transparent content and wonder how to do this, so far I have separated each trasparent object into a separate object and that is not very practical for windows with multiple panes. $\endgroup$ Jul 19, 2022 at 17:36
  • $\begingroup$ @user2404987 You can easily separate objects by material with P (in edit mode) > By Material. It works with multiple objects selected at the same time $\endgroup$
    – Gorgious
    Jul 19, 2022 at 17:44

You must log in to answer this question.

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