It would be nice if IfcAnnotation was easier to select.

A lot of times, when you're in drawings, and trying to select an IfcAnnotation, it selects the objects behind the annotation. A lot of times, you have to alt+click to see a menu of overlapping things--and then select the annotation.

To speed up the process, I wonder if there was a way to 'bias' IfcAnnotation so it was easier to select the first time.

AI braindump...
https://chatgpt.com/share/6824f281-90cc-8013-8d89-b41a914aa8a6

carlopav

Comments

  • edited May 14

    One could ask whether in "Drawing mode" you should be selecting/editing the underlying elements at all!

  • oh man, that's crazy talk. ;) I model in drawing mode all the time.

    sjb007
  • Might be nice as an enhancement though. Maybe an option to disable selection of non-annotation related elements, while still allowing snapping. Would make editing annotations a smoother experience.

    JanF
  • As far as I know the selection order when several objects overlap is driven by the order in which they were created. Maybe that might help, although I think any solution using this as a workaround will be inherently hacky. I think it would be better to make some objects dynamically unselectable depending on the context.

    Massimo
  • edited May 15

    @Gorgious what's your thoughts about using Raycast--something like the following AI suggestion?
    https://chatgpt.com/share/6824f281-90cc-8013-8d89-b41a914aa8a6

    import bpy
    from bpy.types import Operator
    from bpy_extras import view3d_utils
    
    class BIM_OT_priority_select_annotation(Operator):
        bl_idname = "view3d.priority_select_annotation"
        bl_label = "Priority IFC Annotation Select"
        bl_description = "Click to select IFC Annotations first when overlapped"
        bl_options = {'REGISTER'}
    
        def modal(self, context, event):
            if event.type in {'ESC'}:
                return {'CANCELLED'}
    
            if event.type == 'LEFTMOUSE' and event.value == 'PRESS':
                region = context.region
                rv3d = context.space_data.region_3d
                coord = (event.mouse_region_x, event.mouse_region_y)
    
                # Ray origin and direction
                ray_origin = view3d_utils.region_2d_to_origin_3d(region, rv3d, coord)
                ray_direction = view3d_utils.region_2d_to_vector_3d(region, rv3d, coord)
    
                depsgraph = context.evaluated_depsgraph_get()
                result, location, normal, index, obj, matrix = context.scene.ray_cast(
                    depsgraph, ray_origin, ray_direction
                )
    
                if result and obj:
                    # Check if it's an IFC object and of type IfcAnnotation
                    if hasattr(obj, "bim_data") and obj.bim_data.ifc_definition:
                        if obj.bim_data.ifc_definition.is_a("IfcAnnotation"):
                            bpy.ops.object.select_all(action='DESELECT')
                            obj.select_set(True)
                            context.view_layer.objects.active = obj
                            self.report({'INFO'}, f"Selected priority IfcAnnotation: {obj.name}")
                            return {'RUNNING_MODAL'}
                        else:
                            self.report({'INFO'}, f"Hit object is not an IfcAnnotation: {obj.name}")
                    else:
                        self.report({'INFO'}, f"Hit object has no IFC data: {obj.name}")
    
            return {'PASS_THROUGH'}
    
        def invoke(self, context, event):
            context.window_manager.modal_handler_add(self)
            self.report({'INFO'}, "Priority IFC Annotation Selector Active (ESC to quit)")
            return {'RUNNING_MODAL'}
    
    def register():
        bpy.utils.register_class(BIM_OT_priority_select_annotation)
    
    def unregister():
        bpy.utils.unregister_class(BIM_OT_priority_select_annotation)
    
    if __name__ == "__main__":
        register()
    
    
  • Hehe looks like a good idea but I don't think it actually is... I think it's a bit overkill, I'd rather add a button in the interface to toggle selectability of every non annotation object than using a modal operator for it. Besides raycast only works with polygons Afaik so it would rather need to be a kdtree implementation. Also I would be cautious with overriding common features such as left click, bonsai already does a lot of this and these functions are usually several hundred lines of code because of all the edge cases. And what about the fact that constantly running modal operators disables autosave 😅 Cheers

    theoryshawduarteframos
Sign In or Register to comment.