Jump to content

Recommended Posts

Posted

Dear All,

 

Anymore know how to convert drawing from inches to millimeter by lisp ? it there any variable for change inches to millimeter ?

Thank you very much for all expert !

Posted

Why don't you tell us exactly what you are attempting to do?

Posted

not by LISP but all you need to do is scale everything by 25,4. You may then need to change your text sizes and dimension styles.

Posted

I agree with ReMark on this one.

 

It really depends on what you are trying to accomplish. If the drawing has a lot of blocks it could get very complicated. If the drawing is made up of mostly of basic geometry (lines, circles, arcs, polylines, etc.) it shouldn't be such a problem.

 

Usually the scale command can help you on this one rather easily. Scale up using the factor dbroda suggested, 25.4.

Posted
are the INS* variables available in 2004? I thought they came in with 2006.

 

INSUNITS are available in r2002 :D

Posted

in that case I didn't discover them until we had 2006 :D

 

(but I don't think we had 2002)

Posted
Dear All,

 

Anymore know how to convert drawing from inches to millimeter by lisp ? it there any variable for change inches to millimeter ?

Thank you very much for all expert !

(setvar 'Insunits 1)                              ; change drawing units to inch
;; make sure no layer is frozen and no layer is locked
(command "._BLOCK" "temp" "_NONe" '(0 0 0) "ALL" "")
                                                 ; making temporary block "temp" for all objects
(setvar 'Insunits 4)                              ; change drawing units to mm
(command "._INSERT" "temp" "_NONe" '(0 0 0) 1 1 0)
(command "._EXPLODE" "_Last")
(command "._PURGE" "_Block" "temp" "_No" )

Posted

thanks for all expert, my problem is some of my CAD files drawing units are changed to inches instead of millimeters. As a result, all the calculation will got the wrong result. So I want to make a lisp to check the drawing units frist, if the drawing is not equal to milllimeter and I will change it back to millimeter.

Posted
thanks for all expert, my problem is some of my CAD files drawing units are changed to inches instead of millimeters. As a result, all the calculation will got the wrong result. So I want to make a lisp to check the drawing units frist, if the drawing is not equal to milllimeter and I will change it back to millimeter.

 

Just call this one line code:

(setvar 'Insunits 4); change drawing units to mm

 

... but note that maybe drawing is made in inch units without setting the value of insunits.

Posted

thanks for your reply ! but when I try to type this code in command line. It return 4, after that I type command "units" again. But the drawing units is the same as before (i.e."inches"). Anything wrong ?

 

Just call this one line code:

(setvar 'Insunits 4); change drawing units to mm

 

... but note that maybe drawing is made in inch units without setting the value of insunits.

Posted

UNITS & INSUNITS are two different things. UNITS controls what system AutoCAD believes is being used. It is still up to the draughtsman to decide what a unit really means. e.g. although UNITS may be set to inches I can still draw my bits in millimeters at 1 unit = 1mm.

 

The INSUNITS controls how an inserted drawing is scaled. Again assumptions are made as to what units the current drawing and the inserted drawing each have.

 

Just changing these variable DOES NOT change the drawing.

Posted
UNITS & INSUNITS are two different things. UNITS controls what system AutoCAD believes is being used. It is still up to the draughtsman to decide what a unit really means. e.g. although UNITS may be set to inches I can still draw my bits in millimeters at 1 unit = 1mm.

 

The INSUNITS controls how an inserted drawing is scaled. Again assumptions are made as to what units the current drawing and the inserted drawing each have.

 

Just changing these variable DOES NOT change the drawing.

 

Thanks dbroada ! Do you know which variable to indicate the drawing units is "inches" ? Is it contain in setvar ?

Posted (edited)
Thanks dbroada ! Do you know which variable to indicate the drawing units is "inches" ? Is it contain in setvar ?

I thought that it was the UNITS variable but looking now I see that it isn't. It would appear that the drawing remains UNITLESS unless it is part of a block. I have to admit to not studying this before as we generally draw unitless and I have only recently started making my blocks metric.

Edited by dbroada
Posted

In vanilla (normal) AutoCAD: If you use the UNITS command most of those settings are displayed in the dialog. The "main" one you're looking at is the "Insertion scale" about midway down the dialog - but that IS in fact the INSUNITS value (1 = Inches; 4 = mm; etc.). So try this:

Command: (getvar 'insunits)
1
Command: units
Command: (setvar 'insunits 4)
4
Command: UNITS

This would show in the dialog that the drawing is now meant for Millimeters.

 

There's also another sysvar to watch out for: MEASUREMENT. If it is 0, then acad will use hatches & linetypes designed for Inches. If it is 1 then acad will use hatches & linetypes designed for mm.

 

...

BUT

...

 

You're on ADA right? There it is quite different. E.g. if I change the drawing from Inches to mm then there are quite a few things happening (including scaling MS / PS objects if you select that). To test, I use a bit of lisp reactors to check what sysvars have changed, and what commands were issued:

;; Clear reactors
(setq rlst (vlr-reactors))
(foreach item rlst
 (foreach ro (cdr item)
   (if (= "TEST" (vlr-data ro))
     (vlr-remove ro)
   ) ;_ end of if
 ) ;_ end of foreach
) ;_ end of foreach

(defun TraceSysVar1 (obj info)
 (princ (strcat "\n" (car info) " is about to change from "))
 (prin1 (getvar (car info)))
 (princ " ... ")
)
(defun TraceSysVar2 (obj info)
 (if (not (eq (car info) "CMDECHO"))
   (progn
     (princ (strcat (car info) " has changed to "))
     (prin1 (getvar (car info)))
   )
   (if (= (getvar "CMDECHO") 0) (setvar "CMDECHO" 1))
 )
)
(VLR-Reaction-Set (vlr-sysvar-reactor "TEST") :vlr-sysVarWillChange 'TraceSysVar1)
(VLR-Reaction-Set (vlr-sysvar-reactor "TEST") :vlr-sysVarChanged 'TraceSysVar2)

(defun TraceCommand (obj info /)
 (print (strcat (car info) " has been called."))
)
(VLR-Reaction-Set (vlr-editor-reactor "TEST") :vlr-commandEnded 'TraceCommand)

When I've got that loaded and I run the UNITS command I get this at the command-line:

[color=indigo][/color]Command: UNITS

CMDECHO is about to change from 1 ...
CMDECHO is about to change from 1 ...
CMDECHO is about to change from 0 ...
CMDECHO is about to change from 0 ... _AecDwgUnitsSetup
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
INSUNITS is about to change from 1 ... INSUNITS has changed to 4
LUNITS is about to change from 4 ... LUNITS has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
Scaling the entire database...
Scaling AecDbObject(s)...
Scaling entities in Model Space...
Scaling entities in Paper Space...
Scaling entities in Paper Space...
"AECDWGUNITSSETUP has been called."
Command:
CMDECHO is about to change from 1 ...
CMDECHO is about to change from 1 ...

So AFAICT the changing sysvars are: INSUNITS=1=>4; LUNITS=4=>2. And then some "things" happen and the AECDWGUNITSSETUP command is ended (which is the "real" name of the ACA-version of the UNITS command.

 

Unfortunately what happens during those Scaling... lines I cannot tell.

Posted
In vanilla (normal) AutoCAD: If you use the UNITS command most of those settings are displayed in the dialog. The "main" one you're looking at is the "Insertion scale" about midway down the dialog - but that IS in fact the INSUNITS value (1 = Inches; 4 = mm; etc.). So try this:
Command: (getvar 'insunits)
1
Command: units
Command: (setvar 'insunits 4)
4
Command: UNITS

This would show in the dialog that the drawing is now meant for Millimeters.

 

There's also another sysvar to watch out for: MEASUREMENT. If it is 0, then acad will use hatches & linetypes designed for Inches. If it is 1 then acad will use hatches & linetypes designed for mm.

 

...

BUT

...

 

You're on ADA right? There it is quite different. E.g. if I change the drawing from Inches to mm then there are quite a few things happening (including scaling MS / PS objects if you select that). To test, I use a bit of lisp reactors to check what sysvars have changed, and what commands were issued:

;; Clear reactors
(setq rlst (vlr-reactors))
(foreach item rlst
 (foreach ro (cdr item)
   (if (= "TEST" (vlr-data ro))
     (vlr-remove ro)
   ) ;_ end of if
 ) ;_ end of foreach
) ;_ end of foreach

(defun TraceSysVar1 (obj info)
 (princ (strcat "\n" (car info) " is about to change from "))
 (prin1 (getvar (car info)))
 (princ " ... ")
)
(defun TraceSysVar2 (obj info)
 (if (not (eq (car info) "CMDECHO"))
   (progn
     (princ (strcat (car info) " has changed to "))
     (prin1 (getvar (car info)))
   )
   (if (= (getvar "CMDECHO") 0) (setvar "CMDECHO" 1))
 )
)
(VLR-Reaction-Set (vlr-sysvar-reactor "TEST") :vlr-sysVarWillChange 'TraceSysVar1)
(VLR-Reaction-Set (vlr-sysvar-reactor "TEST") :vlr-sysVarChanged 'TraceSysVar2)

(defun TraceCommand (obj info /)
 (print (strcat (car info) " has been called."))
)
(VLR-Reaction-Set (vlr-editor-reactor "TEST") :vlr-commandEnded 'TraceCommand)

When I've got that loaded and I run the UNITS command I get this at the command-line:

Command: UNITS

CMDECHO is about to change from 1 ...
CMDECHO is about to change from 1 ...
CMDECHO is about to change from 0 ...
CMDECHO is about to change from 0 ... _AecDwgUnitsSetup
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
AUNITS is about to change from 0 ... AUNITS has changed to 0
AUPREC is about to change from 2 ... AUPREC has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
INSUNITS is about to change from 1 ... INSUNITS has changed to 4
LUNITS is about to change from 4 ... LUNITS has changed to 2
ANGDIR is about to change from 0 ... ANGDIR has changed to 0
ANGBASE is about to change from 0.0 ... ANGBASE has changed to 0.0
Scaling the entire database...
Scaling AecDbObject(s)...
Scaling entities in Model Space...
Scaling entities in Paper Space...
Scaling entities in Paper Space...
"AECDWGUNITSSETUP has been called."
Command:
CMDECHO is about to change from 1 ...
CMDECHO is about to change from 1 ...

So AFAICT the changing sysvars are: INSUNITS=1=>4; LUNITS=4=>2. And then some "things" happen and the AECDWGUNITSSETUP command is ended (which is the "real" name of the ACA-version of the UNITS command.

 

Unfortunately what happens during those Scaling... lines I cannot tell.

 

Thank you for your kindly assist, I will try this.

Posted

I found program code from other expert, use this function can determining the drawing units that are being used in a drawing? but it require dbview.arx file. However, it is no longer support in AA2011. Is there other method to do the same thing ? Thanks !

 

(defun jb:GetADTVar (var / dict vars ret)

;check to see if the dict exists, if not initialize it . . .

(if (not (cdar (dictsearch (namedobjdict) "AEC_VARS")))

(aeclayerkeylist))

(setq dict (dictsearch

(cdar (dictsearch (namedobjdict) "AEC_VARS"))

"AEC_VARS_DWG_SETUP")

vars (member '(100 . "AecDbVarsDwgSetup") dict)

ret (cdr (assoc var vars)))

ret)

 

 

(jb:GetADTVar 71)

 

Feet returns 30

Inches returns 31

 

Milimeters returns 25

Centimeters returns 24

Decimeters returns 23

Meters returns 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...