Repository navigation
-INSERT of a drawing file converts its INSUNITS - #3482
Merged
HakanSeven12 merged 2 commits intoNov 23, 2026
Merged
Conversation
A metres drawing named at -INSERT's block prompt in a millimetre drawing must come in at scale 1000, feet at 304.8, inches at 25.4, as an XREF of the same file does. All come in at 1 (HakanSeven12#3474). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-INSERT of a drawing file, the Blocks palette and Redefine from a file define the block from the file's model space but left the block record unitless, so a new reference was not scaled against the drawing's INSUNITS and a metres drawing came into a millimetre one 1000 times too small (HakanSeven12#3474). The record now takes the file's INSUNITS; references then scale the way they already do for any block with units, and as an XREF of the same file does. A unitless file stays unitless. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How it shows up
Fixes #3474. A drawing named at
-INSERT's block prompt comes in at scale 1 whatever its INSUNITS: a metres drawing inserted into a millimetre drawing is 1000 times too small. An XREF of the same file is scaled.Synthetic drawings, each a 10-unit line:
metres.dwg(INSUNITS 6),feet.dwg(2),inches.dwg(1),millimetres.dwg(4), inserted into a new drawing with INSUNITS 4 by-INSERT <file> 0,0 1 1 0.Cause
A new block reference is already scaled by its block's units against the drawing's INSUNITS, in one place:
commit_entity_handle_with_policies(src/app/properties.rs) usesinsert_unit_scale(host, record.units). A block brought in from a file byimport_document_block(src/app/update/dialog.rs) is defined from the file's model space, but its block record keeps units 0, unitless, so that factor is 1. Saved to DXF, the four blocks have70= 0 in their BLOCK_RECORD.The change
import_document_blockgives the block record the file'sheader.insertion_unitsonce the block is defined. Nothing else changes: the scale is then applied where it already is for any block with units. A unitless file stays unitless, and a drawing with INSUNITS 0 still inserts at scale 1, sinceinsert_unit_scalereturns no factor when either side is unitless.import_document_blockis reached from-INSERTwith a file name, the Blocks palette (insert of a drawing, and Redefine from a drawing), and a table cell's block from a file. The first two place their reference through the same commit, so they scale too. A table cell's block is not placed as a block reference, and the table code does not read block units (by reading the code; not run).Measured
Release builds, Windows 11.
mainis 8e5f39f with thegpu-allocatorline of 35d5fc5; the branch now sits on c206c53, whose changes since are in tests, the release workflow,Cargo.lockand viewport selection. The same script on both builds.-INSERTinto a drawing with INSUNITS 4mainmetres.dwg(6)feet.dwg(2)inches.dwg(1)millimetres.dwg(4)Then, on the reference of
metres.dwg, each step on both builds. Every result is themainone times 1000, and nothing is converted twice:main: scale / extent-INSERT metres.dwg-INSERT metres(by name)mainTests
insert_of_a_drawing_file_converts_its_units(src/app/commands/blocks.rs): writes the five drawings and runs-INSERT <file> 0,0 1 1 0into a millimetre drawing for each. Fails on the first commit:metres drawing inserted into a millimetre drawing at scale 1, expected 1000; all scales: [("metres", Some(1.0)), ("feet", Some(1.0)), ("inches", Some(1.0)), ("millimetres", Some(1.0)), ("unitless", Some(1.0))].cargo test --lib app::commands::blocks::tests app::update::dialog::tests: 58 passed. On c206c53, the new test withapp::update::dialog::tests: 21 passed.cargo test --workspace --no-fail-fast: 7,756 passed, 1 failed, 49 ignored. The failure,app::control::spellcheck::tests::speller_survives_com_unload_reload_cycles, fails the same way onmainon this machine.cargo check --target wasm32-unknown-unknown --libpasses.Limits
mainalready places any block with units (a block with units 6 inserted by name into a millimetre drawing shows a 10-unit preview and lands at 1000); a drawing file now does the same. Not changed here.INSUNITSDEFSOURCEandINSUNITSDEFTARGETare not read, as before: a unitless side means no conversion.OCS
mainat c206c53, Windows 11.🤖 Generated with Claude Code