Jump to content

Get dwg unit in lisp (metric/imperial)


Recommended Posts

Posted

I have a custom leader lisp that draws a leader perfectly if the dwg is metric. When the dwg is imperial, the leader head is 25.4X smaller. Is ther a way to check for drawing units on the lisp? and then scale the leader head 25.4 times?

 

;;;Conduit Leader;;;
(defun c:cld ( / )
 ;;store orig error handler, assign new error handler 
 (setq OrigError *error* *error* *InsError*) 
 (command "-insert" "cleader");****** the cleader.dwg must be in one of the support path for it to work!******
 (command);;cancels the insert 
 (setvar "dimldrblk" "cleader")
 (setvar "texteval" 1)
 (prompt "\nCLeader")
 (setq CL (getvar "clayer"))
 (c:setlayer "E-ANNO-TEXT")
 (command "_.qleader")
 (while (> (getvar "cmdactive") 0);;pauses while command is active 
      (command pause) 
  ) 
 (setvar "dimldrblk" ".") ;;restore arrowhead 
 (setvar "clayer" CL);;restore layer
 (setq *error* OrigError);;restore default error handler 
 (princ)
)
;;---error handler for routine------- 
(defun *InsError* (msg) 
   (princ (strcat msg " ** CLeader Terminated **")) 
   (if CL (setvar "clayer" CL));;restore layer 
   (setvar "dimldrblk" ".") ;;restore arrowhead 
   (setq *error* OrigError) 
)

CLeader.dwg

Posted
(getvar "LUNITS")

Hmm...LUNITS only tells me if it's:

1 Scientific

2 Decimal

3 Engineering

4 Architectural

5 Fractional

 

It doesn't tell me if the dwg is metric or imperial.:(

Posted

(getvar "MEASUREMENT") will return 0 for imperial units and 1 for metric.

Posted
(getvar "MEASUREMENT") will return 0 for imperial units and 1 for metric.

Thanks. I got it now.:D

Posted

To VovKa

I see you posted the same answer just with one minute later as I did. There is no need to delete your own post. This forum is full of duplicate answers.

Posted

ok, thanks fuccaro, i'll do as the ancients said - "Repetitio est Mater Studiorum" :)

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...