Entity pick → text input subcommands:
C / CLOSE → set closed flag
O / OPEN → clear closed flag
W <value> → set uniform width on LwPolyline vertices
X / EXIT → cancel
Command stays active after each op (CmdResult::PeditOp) for multiple edits.
Supports LwPolyline and Polyline2D.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pick vertices, Enter to finish (≥2 pts). Text input while picking:
C / CLOSE → close and commit (≥3 pts)
S <value> → set scale factor (default 1.0)
S alone → prompt for scale then continue
Uses acadrust MLine::from_points / closed_from_points + scale_factor field.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Status bar: shows "N VP" pill (with tooltip) when in a paper layout that has
user viewports (id > 1). New Scene::viewport_count() method.
REVCLOUD: closed LwPolyline with arc bumps (bulge = 0.5) along each edge.
Click polygon corners, Enter to close into a revision cloud shape.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pick polygon corners, Enter to close. Each edge is subdivided into arc
bumps (bulge = 0.5 ≈ 53° arcs). Result is a closed LwPolyline.
Arc bump length defaults to 1.0 drawing units.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
wires_for_block() now looks up the SortEntitiesTable for the current block.
When found, wires are sorted by sort_handle.value() so DRAWORDER F/B results
are immediately visible in the viewport (not just written to DXF).
Entities not in the sort table default to u64::MAX/2 (middle of draw order).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Options via text input after entity pick:
DE <delta> — extend by delta (negative trims)
TO <total> — set absolute total length / arc length
P <percent> — scale by percentage
<number> — plain number treated as DE delta
Closest end to pick point is modified. Uses CmdResult::LengthenEntity.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Selection-gathering mode: select objects, press Enter to apply.
- Lines: checks collinearity + no-gap, merges into single line span
- Arcs: checks same center/radius + contiguous angles, merges to Arc or Circle
- Uses CmdResult::JoinEntities; geometry computed in cmd_result from document
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3-step interactive flow:
1. Entity pick (first break point recorded at click location)
2. Optional first point refinement
3. Second break point → CmdResult::BreakEntity applied in cmd_result
Geometry:
- Line: project p1/p2 onto line parameter space → two line fragments
- Arc: project p1/p2 to arc angles → trim CCW from p1 to p2
- Circle: same as Arc, converts Circle → Arc
- LwPolyline: nearest-vertex split → two polyline fragments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add three classic CAD measurement commands:
- DIST (DI): two-point pick → distance, angle, delta XYZ
- ID: one-point pick → coordinates
- AREA: multi-point polygon pick (Enter to close) → area + perimeter
New CmdResult::Measurement(String) variant ends active command and
prints result to command line without modifying the document.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- mline.rs: MLine renders center spine + two parallel offset lines at
±scale/2 using the vertex miter directions; vertex grips; scale,
closed and style-name properties
- tolerance.rs: Tolerance renders the GDT text string via font
tessellation at insertion_point with rotation from direction vector;
insertion grip and position properties
- properties.rs: Dimension entity's style_name EditText is upgraded to
a Choice dropdown when document.dim_styles is non-empty, enabling
point-and-click DimStyle assignment without a separate panel
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- raster_image.rs: RasterImage renders as border rectangle + X diagonals
(pixel placeholder); Wipeout renders border or polygon clip boundary;
both support insertion_point grip, brightness/contrast/fade properties,
clipping toggle, and mirror transform (u/v vectors reflected)
- attribute.rs: AttributeDefinition renders default_value (or [TAG] if
empty) as font-tessellated text; AttributeEntity renders the live value;
both support insertion grip, position/height/rotation properties,
and transform operations
- mod.rs + traits.rs: wire up all four new entity types through the full
dispatch chain (to_truck, grips, geometry_properties, apply_geom_prop,
apply_grip, apply_transform)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- polyline.rs: TruckConvertible/Grippable/PropertyEditable/Transformable
for all three polyline types; Polyline2D handles bulge arcs via the
same truck Wire path as LwPolyline; Polyline and Polyline3D use
TruckObject::Lines for straight-segment rendering
- ray.rs: Ray renders as base→+1e6; XLine renders as ±1e6; both have
base-point and direction grips; mirror correctly reflects direction
vector; base X/Y/Z and Dir X/Y/Z exposed in properties panel
- traits.rs: dispatch all five new entity types through
to_truck_entity, grips, geometry_properties, apply_geom_prop,
apply_grip, apply_transform
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- properties.rs: inject 'UCS Name' Choice property for viewports when
document.ucss is non-empty; resolves current handle to display name
- update.rs: intercept PropGeomChoiceChanged for 'vp_ucs_name'; clones
UCS origin/x_axis/y_axis into viewport and sets ucs_handle — no
trait signature change required
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- viewport_content_wires(): conditional perspective divide using
camera_dist = view_height * lens_length / 24.0 (35mm-film equiv.);
points behind the camera are mapped to NaN for safe clipping
- viewport.rs: expose lens_length, ucs_per_viewport, ucs_origin,
ucs_x_axis, ucs_y_axis as editable properties; handle all new
fields in apply_geom_prop()
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PageSetup panel:
- Paper size presets (A4/A3/A2/A1/A0 portrait+landscape, Letter)
- Plot area selector: Layout vs Extents
- Center-on-page toggle
- Plot offset X/Y fields
- Rotation picker: 0° / 90° / 180° / 270°
PlotSettings (acadrust object):
- PageSetupCommit finds or creates a PlotSettings object in the document
- Writes paper size, plot type, centering, offset, rotation to it
- DXF round-trip: PlotSettings persisted to file
PDF export:
- Reads PlotSettings for the active layout
- Applies centering (auto-computes offset from wire extents)
- Applies offset X/Y from PlotSettings
- Applies rotation via PDF CTM transformation matrix
- Swaps paper dimensions for 90°/270° rotation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Enforce status.locked in pan_active_viewport and zoom_active_viewport:
locked viewports now reject pan/zoom inputs entirely
- Add perspective, render_mode, shade_plot_mode, hide_plot, ucs_icon_visible
fields to the viewport property panel with appropriate pickers/toggles
- Add VPORTS command: lists all user viewports in the current layout
(id, size, position, scale, on/locked state) in the command line
- Add VPLAYER command: per-viewport layer freeze/thaw from the command line
(F <layer> to freeze, T <layer> to thaw, Enter to exit)
- Add CmdResult::VpLayerUpdate variant and its handler in apply_cmd_result
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Snap is now suppressed (both cursor indicator and coordinate snapping)
when a command is in entity-pick mode (needs_entity_pick) or
selection-gathering mode (is_selection_gathering), and restored
automatically when the mode ends.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
line_weight_px was multiplied by the viewport scale factor, making lines
near-invisible at small scales (e.g. 1:100) and overly thick at large
scales (e.g. 5:1). Line weights represent physical pen widths on the
plotted sheet and must be constant regardless of viewport scale.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The preview rectangle used c1.y (constant) for all four corners and
pt.z for Z instead of c1.z. Corners 3 and 4 now correctly use pt.y
(varying Y) and the constant c1.z, producing a proper XY-plane rectangle.
Fixed in both layout/mview.rs and manage/mview.rs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Selection, snapping and editing are now mode-aware:
PSPACE (paper layout, no active viewport)
- Only paper-space entities (viewport borders, title blocks, etc.) are
hit-testable and selectable. Viewport content wires are invisible to
the interaction layer.
- Drawing commands add entities to the paper-space layout block so
annotations/title blocks land on the sheet, not in model space.
MSPACE (active viewport entered)
- Only model-space entities visible through the active viewport are
hit-testable. Other viewports' content and paper entities are ignored.
- Drawing commands add entities to model space (correct DXF block).
- Snap results from projected viewport-content wires are converted from
paper-space back to model-space via paper_to_model so that placed
coordinates and command previews are consistent.
Entering/exiting MSPACE clears the current selection so no stale
cross-space selection is carried over.
Implementation:
- Scene::hit_test_wires() returns mode-filtered wires for all
hit-tests, snaps, and selections (entity_wires() still returns
everything for rendering and PDF export).
- viewport_content_wires() gains an Option<Handle> filter to render
only the active viewport's content for MSPACE hit-testing.
- Scene::add_entity() routes to the paper-layout block or model-space
block depending on current_layout / active_viewport.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Four bugs prevented viewports from working like AutoCAD model-space windows:
1. Dead-code double-click block: `!is_down2` was always false because
`is_down2 = sel.left_down` is captured while the button is still held
(before the selection block clears it). Changed to `is_down` so the
double-click handler actually fires.
2. Inverted pan direction: pan_active_viewport used `-=` on the delta
returned by screen_delta_to_world, which is the same delta that cam.pan
*adds* to its target — causing reversed drag. Changed to `+=`.
3. Zoom not cursor-centered: zoom_active_viewport now accepts an optional
paper-space cursor position and adjusts view_target so the model point
under the cursor stays fixed (same as cam.zoom_about_point).
4. ESC did not exit MSPACE: CommandEscape now calls ExitViewport when
active_viewport is set and no command is running.
Also added MS/MSPACE and PSPACE command aliases, and MspaceCommand /
PspaceCommand messages so MS auto-enters the first viewport.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CadDocument::new() inserts default Layout1; DXF/DWG readers then add
the file's own Layout1 on top, producing duplicate tabs with the same
name but different handles. layout_names() now deduplicates by name,
preferring the entry with a non-null block_record (the real layout from
the file).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Root cause: the DXF reader never reads group code 340 (block_record
handle) inside LAYOUT objects, so layout.block_record stays Handle::NULL
after opening any DXF file. This caused current_layout_block_handle()
to return NULL, which made belongs_to_visible_block() return true for
every entity — all entities appeared in all layouts simultaneously.
Fix in current_layout_block_handle() — three-tier lookup:
1. Layout.block_record (non-null) — works for DWG files.
2. Conventional DXF name ("*Model_Space", "*Paper_Space", …) derived
from the layout's tab_order — works for standard DXF exporters.
3. Position-based fallback: sort paper-space block records and paper
layouts independently, then match by index — handles exporters that
set tab_order = 0 for all layouts.
Apply the same two-tier lookup to model_space_block_handle().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Paper limits:
- Change A4 fallback from 12×9 to 297×210 mm in paper_limits()
Context menu:
- Translate layout context menu labels to English (Rename / Delete)
Viewport clipping:
- Replace AABB-only culling with proper Cohen-Sutherland line clipping
in viewport_content_wires(); each projected segment is now clipped at
the exact viewport boundary instead of being included or discarded whole
- Add cs_clip() and clip_polyline_to_rect() free functions in scene/mod.rs
Frozen layers per-viewport UI:
- Inject a "Frozen Layers" EditText property in the Properties panel for
viewport entities (layer names resolved from handles at display time)
- Handle "frozen_layers" in PropGeomCommit: parse comma-separated names,
resolve to layer handles, update vp.frozen_layers in-place
PDF export improvements:
- Add offset_x/offset_y params to export_pdf() for model-space normalization:
coordinates are shifted so the drawing origin maps to the page origin
- Model space export computes extents via model_space_extents() (now public)
and adds a 5 % margin; falls back to A4 landscape for empty drawings
- Skip __paper_boundary__ wire in PDF (white background covers it)
- Map yellow (active viewport border) → black and cyan (vp border) → dark
blue for print-friendly output
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add printpdf 0.9.1 dependency for native PDF generation.
- New src/io/pdf_export.rs: converts paper-space WireModels to a PDF
page (per-wire stroke color, line weight in Pt, NaN-split segments).
White/near-white colors are inverted to black for print output.
- Add PlotExport / PlotExportPath messages: opens a save-file dialog
and writes a .pdf next to the drawing file.
- Add PageSetupOpen/Close/WidthEdit/HeightEdit/Commit messages: a
centered modal panel lets the user enter paper width and height (mm);
on commit the Layout object's min/max_limits are updated in-place.
- Register PRINT / PLOT / EXPORT and PAGESETUP (PS) commands in
dispatch_command; fix MVIEW error message to English.
- Layout ribbon gains a "Plot" group with Page Setup and Export PDF
ribbon buttons.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add model_space_extents() to Scene: collects key_vertices from all
model-space entities to compute an AABB.
- Add auto_fit_viewport() to Scene: sets view_target to model centroid
and derives custom_scale / view_height so the content fits the new
viewport with a 10% margin.
- Call auto_fit_viewport() in commit_entity() after a viewport is added
to a paper-space layout, so newly placed viewports immediately show
model-space content at a sensible scale.
- Scale line_weight_px by the viewport scale factor when projecting
model-space wires into paper space, so dimension arrows and annotation
lines appear at the correct visual thickness.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>