Remove [SECTION] and [ClickDim] debug print statements

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ryan Schultz
2026-08-15 11:37:57 -05:00
parent 8c3bc3b1ca
commit 6cae194610
4 changed files with 0 additions and 37 deletions
@@ -2705,18 +2705,12 @@ class ActivateDrawingBase(tool.Ifc.Operator):
assert camera
# Update SECTION annotation endpoints for this drawing
print(f"[SECTION] ActivateDrawing: camera={camera.name}, drawing id={self.drawing}")
drawing_element = tool.Ifc.get().by_id(self.drawing)
drawing_camera_element = tool.Ifc.get_entity(camera)
print(f"[SECTION] drawing_element={drawing_element}, camera_element={drawing_camera_element}")
group = tool.Drawing.get_drawing_group(drawing_element)
print(f"[SECTION] group={group}")
if group:
for annotation in tool.Drawing.get_group_elements(group) or []:
print(f"[SECTION] group member: {annotation.is_a()} id={annotation.id()}")
if annotation.is_a("IfcAnnotation") and ifcopenshell.util.element.get_predefined_type(annotation) == "SECTION":
ann_obj = tool.Ifc.get_object(annotation)
print(f"[SECTION] found SECTION annotation obj={ann_obj}")
if ann_obj:
tool.Drawing.update_section_endpoints(ann_obj, camera)
camera_props = tool.Drawing.get_camera_props(camera)
@@ -8870,25 +8864,20 @@ class ClickNearestDimensionAnchor(bpy.types.Operator):
best_move_end = 0 if t < 0.5 else 1
if best_obj is None:
print(f"[ClickDim] no hit → clear _activated={ClickNearestDimensionAnchor._activated}")
ClickNearestDimensionAnchor._activated.clear()
return {"PASS_THROUGH"}
print(f"[ClickDim] hit={best_hit_type} obj={best_obj.name!r} ctrl={event.ctrl} alt={event.alt} _activated={ClickNearestDimensionAnchor._activated}")
# For midpoint hits (drive-dimension): require a prior interaction with this
# dimension before opening the dialog. First click explicitly selects it
# (anchor dots appear) so the user has clear feedback before the second click.
if best_hit_type == "MIDPOINT" and not event.ctrl:
if best_obj.name not in ClickNearestDimensionAnchor._activated:
ClickNearestDimensionAnchor._activated.add(best_obj.name)
print(f"[ClickDim] first click → select {best_obj.name!r}")
for o in list(context.selected_objects):
o.select_set(False)
best_obj.select_set(True)
context.view_layer.objects.active = best_obj
return {"FINISHED"}
print(f"[ClickDim] MIDPOINT dispatch → drive_dimension_length")
# Any successful non-first-click interaction marks this dimension as activated.
ClickNearestDimensionAnchor._activated.add(best_obj.name)
@@ -96,13 +96,10 @@ def update_diagram_scale(self: "BIMCameraProperties", context: bpy.types.Context
self.update_camera_resolution()
group = tool.Drawing.get_drawing_group(element)
print(f"[SECTION] update_diagram_scale: camera={camera.name}, group={group}")
if group:
for annotation in tool.Drawing.get_group_elements(group) or []:
print(f"[SECTION] checking group member: {annotation}")
if annotation.is_a("IfcAnnotation") and ifcopenshell.util.element.get_predefined_type(annotation) == "SECTION":
ann_obj = tool.Ifc.get_object(annotation)
print(f"[SECTION] found SECTION annotation, ann_obj={ann_obj}")
if ann_obj:
tool.Drawing.update_section_endpoints(ann_obj, camera)
-2
View File
@@ -520,7 +520,6 @@ def add_annotation(
relating_type: ifcopenshell.entity_instance,
enable_editing: bool = False,
) -> bpy.types.Object:
print(f"[SECTION] core.add_annotation called: object_type={object_type}")
target_view = drawing_tool.get_drawing_target_view(drawing)
context = drawing_tool.get_annotation_context(target_view, object_type)
if not context:
@@ -545,7 +544,6 @@ def add_annotation(
ifc.run("group.assign_group", group=drawing_tool.get_drawing_group(drawing), products=[element])
if object_type == "SECTION":
camera = ifc.get_object(drawing)
print(f"[SECTION] add_annotation: object_type=SECTION, camera={camera}")
if camera:
drawing_tool.update_section_endpoints(obj, camera)
if representation := drawing_tool.get_representation(element, context):
-21
View File
@@ -77,7 +77,6 @@ if TYPE_CHECKING:
from bonsai.bim.module.drawing.prop import Drawing as DrawingProperties
print("[SECTION] tool/drawing.py module loaded")
class Drawing(bonsai.core.tool.Drawing):
@@ -2962,38 +2961,29 @@ class Drawing(bonsai.core.tool.Drawing):
"""Return world-space positions for section endpoints placed at the camera border + border_offset_mm (paper mm)."""
diagram_scale = cls.get_diagram_scale(camera)
if not diagram_scale:
print("[SECTION] get_section_border_positions: no diagram_scale, returning original")
return v0_world, v1_world
scale = cls.get_scale_ratio(diagram_scale["Scale"])
model_offset = (border_offset_mm / 1000.0) / scale
print(f"[SECTION] scale={scale}, border_offset_mm={border_offset_mm}, model_offset={model_offset:.4f}m")
width, height = cls.get_camera_dimensions(camera)
half_w, half_h = width / 2, height / 2
print(f"[SECTION] camera dims: width={width:.3f}, height={height:.3f}, half_w={half_w:.3f}, half_h={half_h:.3f}")
cam_inv = camera.matrix_world.inverted()
v0_local = cam_inv @ v0_world
v1_local = cam_inv @ v1_world
print(f"[SECTION] v0_local={v0_local}, v1_local={v1_local}")
origin = Vector(((v0_local.x + v1_local.x) / 2, (v0_local.y + v1_local.y) / 2))
dir_xy = Vector((v1_local.x - v0_local.x, v1_local.y - v0_local.y))
if dir_xy.length < 1e-6:
print("[SECTION] get_section_border_positions: degenerate edge, returning original")
return v0_world, v1_world
dir_xy = dir_xy.normalized()
z = v0_local.z
print(f"[SECTION] origin={origin}, dir_xy={dir_xy}, z={z:.4f}")
t_values = cls._section_ray_rect_intersections(origin, dir_xy, half_w, half_h)
print(f"[SECTION] ray-rect t_values={t_values}")
pos_ts = sorted(t for t in t_values if t >= 0)
neg_ts = sorted((t for t in t_values if t < 0), reverse=True)
print(f"[SECTION] pos_ts={pos_ts}, neg_ts={neg_ts}")
if not pos_ts or not neg_ts:
print("[SECTION] get_section_border_positions: no valid border intersections, returning original")
return v0_world, v1_world
t_end = pos_ts[0]
@@ -3013,44 +3003,34 @@ class Drawing(bonsai.core.tool.Drawing):
@classmethod
def update_section_endpoints(cls, obj: bpy.types.Object, camera: bpy.types.Object) -> None:
"""Move section line endpoints to camera border + BorderOffset, skipping any manually moved vertex."""
print(f"[SECTION] update_section_endpoints called: obj={obj.name}, camera={camera.name}")
element = tool.Ifc.get_entity(obj)
if not element:
print("[SECTION] SKIP: no IFC element on obj")
return
if not obj.data or not hasattr(obj.data, "edges") or not obj.data.edges:
print("[SECTION] SKIP: obj has no mesh edges")
return
pset_data = ifcopenshell.util.element.get_pset(element, "BBIM_Section") or {}
border_offset = float(pset_data.get("BorderOffset", 8.0))
print(f"[SECTION] pset_data={pset_data}, border_offset={border_offset}")
if border_offset <= 0:
print("[SECTION] SKIP: BorderOffset <= 0")
return
auto_v0 = cls._parse_vector3(pset_data.get("AutoStartPosition") or "")
auto_v1 = cls._parse_vector3(pset_data.get("AutoEndPosition") or "")
print(f"[SECTION] stored auto_v0={auto_v0}, auto_v1={auto_v1}")
edge = obj.data.edges[0]
v0 = obj.data.vertices[edge.vertices[0]]
v1 = obj.data.vertices[edge.vertices[1]]
v0_world = obj.matrix_world @ v0.co
v1_world = obj.matrix_world @ v1.co
print(f"[SECTION] current v0_world={v0_world}, v1_world={v1_world}")
# A vertex is "auto" if it has never been auto-positioned, or still sits at the stored auto position.
v0_is_auto = auto_v0 is None or (v0_world - auto_v0).length < 1e-4
v1_is_auto = auto_v1 is None or (v1_world - auto_v1).length < 1e-4
print(f"[SECTION] v0_is_auto={v0_is_auto}, v1_is_auto={v1_is_auto}")
if not v0_is_auto and not v1_is_auto:
print("[SECTION] SKIP: both vertices are manually overridden")
return
new_v0_world, new_v1_world = cls.get_section_border_positions(camera, v0_world, v1_world, border_offset)
print(f"[SECTION] new_v0_world={new_v0_world}, new_v1_world={new_v1_world}")
if v0_is_auto:
v0.co = obj.matrix_world.inverted() @ new_v0_world
@@ -3076,7 +3056,6 @@ class Drawing(bonsai.core.tool.Drawing):
},
)
bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")
print(f"[SECTION] done. stored auto_v0={cls._format_vector3(stored_v0)}, auto_v1={cls._format_vector3(stored_v1)}")
@staticmethod
def _parse_vector3(s: str) -> Optional[Vector]: