Skip to content

Drawings: ordinate dimension layout slows down near the sheet edge #27087

In review

Description

@nullifyr

Found while testing a synthetic part.

What happens

An ordinate dimension set placed near the edge of the paper takes longer to lay out as members are added. When both sides of the set are blocked by the paper edge, the layout tries shorter offsets in 1 mm steps. Each candidate builds the full set of leaders before its first collision check, and each leader scans the part outline for clearance. The cost grows with members times candidates.

On z97 with 35 targets, a CLI before #26845 took a median of 2.0 ms to inspect the sheet, and the CLI at #26845 took 9.9 ms. The 8-target case took 1.0 ms before and 4.1 ms after. These are short diagnostic timings.

Steps

  1. Save the script below as repro.py. It builds the part and an ISO A3 sheet from formulas.
  2. Run python3 repro.py /path/to/solidcraft-cli 35. It runs one add and three inspections.
  3. Compare inspection times between a CLI built before Drawings: an ordinate set moved off another view never leaves the paper #26845 and one built at Drawings: an ordinate set moved off another view never leaves the paper #26845.
repro.py
import json
import subprocess
import sys
from time import perf_counter

binary = sys.argv[1]
count = int(sys.argv[2])
with subprocess.Popen([binary, "mcp", "--structured"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) as process:
    sequence = 0

    def send(method, params, notify=False):
        global sequence
        sequence += 1
        request = dict(jsonrpc="2.0", method=method, params=params)
        if not notify:
            request["id"] = sequence
        print(json.dumps(request), file=process.stdin, flush=True)
        if notify:
            return
        while True:
            line = process.stdout.readline()
            if not line:
                raise RuntimeError("MCP server stopped")
            response = json.loads(line)
            if response.get("id") == sequence:
                return response["result"]

    def command(name, **params):
        reply = send("tools/call", dict(name="execute", arguments=dict(command=name, params=params)))
        if reply.get("isError"):
            raise RuntimeError(reply)
        return reply["structuredContent"]["result"]

    send("initialize", dict(protocolVersion="2025-06-18", capabilities={}, clientInfo=dict(name="synthetic-ordinate-sheet", version="1")))
    send("notifications/initialized", {}, notify=True)
    for i in range(36):
        command("solid.box", length=2, width=6, height=8, corner=[3*i, 0, 0], body_name=f"Block {i+1}", operation="new")
    command("drawing.create", template="iso-a3-part", omit_first_sheet_title_block=True)
    view = command("drawing.view.base", sheet="Sheet 1", view="front", scale="1:1", position_mm=[56, 120])["view"]
    command("drawing.scene", sheet="Sheet 1")
    targets = [[3*i, 0, 8] for i in range(1, count+1)]
    start = perf_counter()
    added = command("drawing.dimension.add", view=view, kind=dict(ordinate=dict(origin=[0, 0, 8], targets=targets, direction="horizontal")), offset_mm=90)
    after_add = perf_counter()
    assert added["status"] == "ok" and len(added["members"]) == count, added["status"]
    for _ in range(3):
        command("drawing.dimension.inspect", dimension=added["dimension"])
    after_inspect = perf_counter()
    print(f"{count} targets: add {1e3*(after_add-start):.1f} ms, inspect mean {1e3*(after_inspect-after_add)/3:.1f} ms", flush=True)
    process.stdin.close()

Expected

Leader starts are found once per member per side. Candidate offsets are checked without building every leader, and the accepted placement is built once.

Actual

Every candidate offset builds all leaders before its first collision check.

Activity

  1. added
    area:sketch
    needs-triage
    in progress
    on Dec 6, 2026
  2. github-actions commented on Dec 6, 2026

    @github-actions
    Contributor

    Claimed by @nullifyr through #27088. The claim lapses after 14 days without pushes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:sketchin progressneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions