Home Coding, Scripting, Shaders

[Solved][Python - Blender] Hide Boolean Cutters?

polycounter
Offline / Send Message
Justo polycounter
I use a simple toggle wires script to toggle the wireframe of the objects in my viewport on/off. However, I’d like to take this a step further: to any cutters visible in the scene (regular geo with its display type set to WIRE), also them vanish on/off too.



I believe the quickest way would be to toggle the Show in Viewport property of cutter objects (bpy.context.object.hide_viewport = NOT bpy.context.object.hide_viewport), and the way to identify which objects would be by searching the ones with its Display type set to WIRE. Is this a smart and fast way to achieve this? Does anyone know how to smartly & efficiently do this without making the script take a heavy performance toll?

This is the simple script I use:

def wire_toggle(self, context):
   if context.space_data.overlay.show_wireframes:
       context.space_data.overlay.show_wireframes = False
   else:
       context.space_data.overlay.show_wireframes = Truedef execute(self, context):
   self.wire_toggle(context)
   return{'FINISHED'}

Replies

  • Justo
    Offline / Send Message
    Justo polycounter
    ok so, I was able to do it by iterating through all the objects inside the Cutters collection :) Since I use HOps, the addon's boolean ops conveniently sends cutter objects there anyway.

    for obj in bpy.data.collections["Cutters"].all_objects:
        if obj.type == 'MESH' and obj.display_type == 'WIRE': 
            obj.hide_viewport = False
Sign In or Register to comment.