Author Topic: Modify DWGUNITS  (Read 647 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 245
Modify DWGUNITS
« on: April 25, 2024, 05:40:35 PM »
How to modify the value in -DWGUNITS from 3 to 6 by AutoLISP?

Command: -DWGUNITS

Drawing units:
  1. Inches
  2. Feet
  3. Millimeters
  4. Centimeters
  5. Decimeters
  6. Meters
Unit for length <3>: 6
OK.

BIGAL

  • Swamp Rat
  • Posts: 1429
  • 40 + years of using Autocad
Re: Modify DWGUNITS
« Reply #1 on: April 25, 2024, 08:16:33 PM »
Something like this

Code: [Select]
(command "-dwgunits" 6 2 3 "N" "Y")
A man who never made a mistake never made anything

ScottMC

  • Newt
  • Posts: 193
Re: Modify DWGUNITS
« Reply #2 on: April 26, 2024, 09:55:58 AM »
With my ancient A2K, this works: (setvar "LUNITS" 2) <- for decimal

Lonnie

  • Newt
  • Posts: 183
Re: Modify DWGUNITS
« Reply #3 on: April 26, 2024, 11:45:03 AM »
With my ancient A2K, this works: (setvar "LUNITS" 2) <- for decimal

Untested but?

Code: [Select]
(defun check-and-set-lunits ()
  (if (/= (getvar "LUNITS") 6) ; Check if LUNITS is not already set to 6
      (progn
        (setq change_units (strcat "\nLUNITS is currently set to " (itoa (getvar "LUNITS")) ", do you want to change it to 6? [Y/N]: "))
        (if (equal (getstring change_units) "Y")
            (setvar "LUNITS" 6) ; Change LUNITS to 6
            (prompt "\nLUNITS remains unchanged.")))))
           
(check-and-set-lunits)

Change for meters
« Last Edit: April 26, 2024, 11:56:06 AM by Lonnie »

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: Modify DWGUNITS
« Reply #4 on: April 26, 2024, 03:52:42 PM »
With my ancient A2K, this works: (setvar "LUNITS" 2) <- for decimal
DWGUNITS can have another setting, it is optional to match AutoCAD units settings.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Modify DWGUNITS
« Reply #5 on: April 26, 2024, 04:37:07 PM »
With my ancient A2K, this works: (setvar "LUNITS" 2) <- for decimal
DWGUNITS can have another setting, it is optional to match AutoCAD units settings.

I would rather note that LUNITS is a sub-setting within the UNITS command, along with ANGDIR, AUNITS, ANGBASE, INSUNITS, LUPREC and AUPREC. Other system Variables that effect units are MEASUREINIT, MEASUREMENT and UNITMODE.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: Modify DWGUNITS
« Reply #6 on: April 27, 2024, 03:39:39 AM »
I did't say it isn't. DWGUNITS is something different. From origin it comes from a vertical, AutoCAD Architecture I think. Within DWGUNITS you can set some unit settings and it is optional to match them with the AutoCAD units.
Normally you don't notice the DWGUNITS stuff but there are cases you do.
The best setting is to match AutoCAD units and then forget all about DWGUNITS.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

FELIX

  • Bull Frog
  • Posts: 245
Re: Modify DWGUNITS
« Reply #7 on: May 17, 2024, 11:44:21 PM »
With my ancient A2K, this works: (setvar "LUNITS" 2) <- for decimal

Untested but?

Code: [Select]
(defun check-and-set-lunits ()
  (if (/= (getvar "LUNITS") 6) ; Check if LUNITS is not already set to 6
      (progn
        (setq change_units (strcat "\nLUNITS is currently set to " (itoa (getvar "LUNITS")) ", do you want to change it to 6? [Y/N]: "))
        (if (equal (getstring change_units) "Y")
            (setvar "LUNITS" 6) ; Change LUNITS to 6
            (prompt "\nLUNITS remains unchanged.")))))
           
(check-and-set-lunits)

Change for meters

The command is -DWGUNITS and LUNITS does not accept =6
OK.

FELIX

  • Bull Frog
  • Posts: 245
Re: Modify DWGUNITS
« Reply #8 on: May 17, 2024, 11:46:23 PM »
Something like this

Code: [Select]
(command "-dwgunits" 6 2 3 "N" "Y")

How to do it without COMMAND to look elegant within a program?
OK.

JasonB

  • Newt
  • Posts: 42
  • perfectionist trapped inside the mind of an idiot.
Re: Modify DWGUNITS
« Reply #9 on: May 18, 2024, 04:58:21 PM »
How to modify the value in -DWGUNITS from 3 to 6 by AutoLISP?

Command: -DWGUNITS

Drawing units:
  1. Inches
  2. Feet
  3. Millimeters
  4. Centimeters
  5. Decimeters
  6. Meters
Unit for length <3>: 6

This part of the command relates to INSUNITS
https://help.autodesk.com/view/ACDLT/2025/ENU/?guid=GUID-A58A87BB-482B-4042-A00A-EEF55A2B4FD8
Code - Auto/Visual Lisp: [Select]
  1. (setvar 'INSUNITS 6)

PKENEWELL has listed this and the other system variables related to this command.


FELIX

  • Bull Frog
  • Posts: 245
Re: Modify DWGUNITS
« Reply #10 on: May 18, 2024, 09:13:17 PM »
The command is -DWGUNITS and not INSUNITS or LUNITS.

Please pay more attention before responding.
OK.

JasonB

  • Newt
  • Posts: 42
  • perfectionist trapped inside the mind of an idiot.
Re: Modify DWGUNITS
« Reply #11 on: Today at 01:54:55 AM »
The command is -DWGUNITS and not INSUNITS or LUNITS.

Please pay more attention before responding.

-DWGUNITS is a command.

INSUNITS and LUNITS are system variables

As others have pointed out, -DWGUNITS looks to be related to an AutoCAD Vertical. It's not documented anywhere that I could find in the HELP. Also, from other posts it seems geared more towards converting a drawing from one set of units to another. Further to this, the prompting of the command changes depending on whether you've run the command previously in a drawing. So simply calling
Code - Auto/Visual Lisp: [Select]
  1. (command "._-DWGUNITS" 6 2 3 "_N" "_Y")
may not work in all cases.

If you're simply trying to set the drawing units, then it would be better to explore the -UNITS command.

How to do it without COMMAND to look elegant within a program?

All the settings of the -UNITS command can be set via a system variable, which allows you to avoid making a command call from lisp. This is a more elegant approach. e.g
Code - Auto/Visual Lisp: [Select]
  1. (setvar 'INSUNITS 6)
  2. (setvar 'LUNITS 2)
  3. (setvar 'LUPREC 4)