AutoLISP Viewport Creator Script

Заказчик: AI | Опубликовано: 20.11.2025
Бюджет: 12 $

The task is to write a clean, well-commented AutoLISP routine that lets me pick one or more rectangular boundaries in model space and instantly turns each of them into its own viewport on a layout. Every viewport must display all elements inside the rectangle—nothing more, nothing less—so the clipping has to be exact even when the rectangle is rotated or drawn at odd coordinates. Key points you should cover • Command workflow: I launch the routine, click a series of closed rectangles (polylines or simple rectangles), then confirm. The code generates a new viewport for each selection and zooms it so the full rectangle contents are visible. • Inclusion rule: “All elements inside retangle” is the only filter—no layer or object type limitations. • Layout handling: use the current layout if I’m already in one, otherwise create a fresh layout automatically. • Naming: viewports and new layouts should receive incremental, human-readable names (e.g., VP-01, VP-02). • Error traps: ignore empty rectangles, warn if a boundary isn’t closed, and never crash the drawing. • Delivery: provide the .lsp file plus a brief README showing load instructions, command syntax, and any system variables you touch. Acceptance test 1. Load script in AutoCAD 2020 or later. 2. Draw three rectangles around different parts of an existing DWG. 3. Run the command; three viewports appear on a layout, each correctly clipped and zoomed. 4. Switching layers or regenerating the drawing does not alter the clipping. If you can keep the routine lightweight, with no external dependencies beyond vanilla AutoCAD, it will drop straight into my current workflow.