Fix DrawParametricDimension: always regenerate from anchors after RMB

regenerate_dimension was only called when ForcePerpendicularToFace was
set, so normal two-anchor dimensions were left at raw polyline cursor
positions after placement.  The depsgraph handler would later correct
them when the user happened to select a referenced IFC element, making
accurate placement appear to require a manual selection step.

Remove the _force_perpendicular guard so the anchor-based regeneration
always runs at the end of _create_dimension_from_polyline.
This commit is contained in:
Ryan Schultz
2026-06-14 15:09:27 -05:00
parent ffe7296973
commit 5309b4614c
@@ -6242,26 +6242,27 @@ class DrawParametricDimension(bpy.types.Operator, PolylineOperator, tool.Ifc.Ope
pset_props["ForcePerpendicularToFace"] = True pset_props["ForcePerpendicularToFace"] = True
ifcopenshell.api.run("pset.edit_pset", file, pset=pset_entity, properties=pset_props) ifcopenshell.api.run("pset.edit_pset", file, pset=pset_entity, properties=pset_props)
if self._force_perpendicular: # Always regenerate from anchor data so the curve reflects the true IFC
placement_override: dict = {} # face positions rather than the raw cursor positions from the polyline.
for a in anchors: placement_override: dict = {}
guid = a.get("guid") for a in anchors:
if not guid: guid = a.get("guid")
continue if not guid:
try: continue
elem = file.by_guid(guid) try:
elem_obj = tool.Ifc.get_object(elem) elem = file.by_guid(guid)
if elem_obj: elem_obj = tool.Ifc.get_object(elem)
placement_override[elem.id()] = np.array(elem_obj.matrix_world) if elem_obj:
except Exception: placement_override[elem.id()] = np.array(elem_obj.matrix_world)
pass except Exception:
resolved_pts = drawing_api.regenerate_dimension( pass
file, annotation, resolved_pts = drawing_api.regenerate_dimension(
shape_cache=getattr(self, "_shape_cache", None), file, annotation,
placement_override=placement_override, shape_cache=getattr(self, "_shape_cache", None),
) placement_override=placement_override,
if resolved_pts: )
_update_blender_curve(annotation, resolved_pts) if resolved_pts:
_update_blender_curve(annotation, resolved_pts)
from bonsai.bim.module.drawing import handler as _drawing_handler from bonsai.bim.module.drawing import handler as _drawing_handler
_drawing_handler.invalidate_dim_index() _drawing_handler.invalidate_dim_index()