Short description
This AutoLISP routine is made for AutoCAD Civil 3D and is used to quickly set the drawing’s coordinate system, drawing scale, angular units and linear drawing units from one dialog.
It reads the Civil 3D COM objects and applies the settings directly to the active document, so the drawing is ready for civil work after one configuration step.

Command:
Command: c:settupunits
Running this command opens a custom DCL dialog called “Set Drawing Units”, where the user can pick Country/Region, Coordinate System (zone), Drawing Scale, Angular Units and Drawing Units.
Description:
When executed, the program:
• Creates a temporary DCL file in the AutoCAD temp folder named settupunits.dcl and defines the dialog layout in it (country list, zone list, scale list, angle list, units list).
• Displays the dialog and populates the Country/Region popup with values taken from an internal zone database (a large list of LL / national / regional coordinate systems included in the .lsp).
• When the user picks a country, the Coordinate System popup is updated to show only the zones for that selected country.
• The user can also pick a Drawing Scale from a list of scales (1:100, 1:200, etc.), which the code internally converts into the Civil 3D drawing scale value.
• The user can pick Angular Units (Degrees, Radians, Grads) and Drawing Units (Meters, Millimeters, Centimeters, Decimeters, Inches).
• After pressing OK, the dialog is closed, the temporary DCL file is deleted, and the chosen settings are applied to the current Civil 3D drawing.
Helper function: (if any)
Helper Functions Used:
• setunits — main worker function at the top of the file; it connects to the Civil 3D COM object, gets the active document settings and writes the selected CS code, drawing scale, angular units and drawing units into DrawingSettings → UnitZoneSettings.
• getaeccApp (defined inside setunits) — looks in the Windows registry for the installed Civil 3D “Aecc” library (e.g. “AeccXUiLand”) and returns the correct COM object, so the code works across Civil 3D versions.
• The command c:settupunits itself — builds the DCL on the fly using (open), (write-line), loads it, shows it, and then calls (setunits …) if the user pressed OK.
• A large internal list called something like zoneDB that stores pairs/triples of “Country / Coordinate system codes” — this is used to fill the two popup lists (country and zone).
Functionalities:
Main Functionalities:
• Set Civil 3D coordinate system: it gets the DrawingSettings → UnitZoneSettings → CoordinateSystem object and sets its cscode property to the picked zone (e.g. “LL”, national grids, etc.).
• Set drawing scale: writes the numeric scale into drawingScale so all drawing annotations follow that scale.
• Set angular units: writes user’s choice (Degrees / Radians / Grads) into angularUnits of the drawing settings.
• Set drawing/linear units: writes user’s choice (Meters, Millimeters, Centimeters, Decimeters, Inches) into drawingUnits so the drawing reflects the expected measurement system.
• Dynamic DCL generation: the dialog is not a separate .dcl file shipped with the routine — it is generated in the temp folder at runtime and deleted afterwards, so the LSP is self-contained.
• Civil 3D version independence: by reading the registry for “Aecc” it tries to attach to whatever Civil 3D version is installed, instead of hardcoding the COM server name.
Result:
Result:
After the user picks country, coordinate system, scale, angle and units, the routine applies everything in one go to the active Civil 3D drawing.
The drawing now has the correct CS code and unit settings, so subsequent civil objects will be created in the right context without the user going through several Civil 3D dialogs.
A confirmation message is printed in the command line showing the applied zone, scale, angular units and drawing units.
Images, animations etc.





Log in to download.
Log in
Log in
Additional info:
Learn more:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
Tags: Coordinates, Maps
Tags: Coordinates, Maps
