Jump to content

Multiple linetype setup command


Recommended Posts

Posted

Hey everyone,

 

My first post here, have read quite a few posts and have always gotten good advice, hopefully you can help again. I have been getting into autolisp and have written a couple of simple functions and would like to combine them into one large function, but for some reason when i combine the two separate lisps into one it only runs half of the lisp no matter what the input. See below lisp code:

 

 
(DEFUN pslt ()
command:(foreach lay (layoutlist)(command "_LAYOUT" "_Set" lay "PSLTSCALE" 1))
(princ)
(setq a(getstring "\nEnter Drawing Units <M=Metric/I=Imperial>:"))
(if (or (equal a "M")(equal a "m")) (metric2) (imperial2)) 
(princ)
)
(DEFUN metric2 ()
   (command "LTSCALE" 12.5 "")
   (princ)
)
(DEFUN imperial2 (/ isc)
   (command "LTSCALE" 0.5 "")
   (princ)
)
;end pslt

(DEFUN mslt ()
command:(foreach lay (layoutlist)(command "_LAYOUT" "_Set" lay "PSLTSCALE" 0))
(princ)
(setq a(getstring "\nEnter Drawing Units <M=Metric/I=Imperial>:"))
(if (or (equal a "M")(equal a "m")) (metric1) (imperial1)) 
(princ)
)
(DEFUN metric1 (/ msc)
(setq msc (getreal "Enter Drawing Scale: "))
   (command "LTSCALE" (* msc 12.5) "")
   (princ)
)
(DEFUN imperial1 (/ isc)
(setq isc (getreal "Enter Drawing Scale: "))
   (command "LTSCALE" (* isc 0.5) "")
   (princ)
)
;end mslt

(DEFUN c:ltsetup ()
(setq myscale (getreal "\Enter Drawing Scale <0=Varies>:"))
  (if (or (equal myscale "0")(equal myscale ""))
   (progn                                 ;if myscale = 0 or enter run paperspace setup
     (pslt)
   )                                      ;if myscale \=0 or enter run modelspace setup
   (progn 
     (mslt)
   )
  )
(princ)
)

 

The purpose of this lisp is to determine what the scale of the drawing will be, if it varies then it should run the pslt function, if it is constant it should run the mslt function.

 

Both pslt and mslt run perfectly if they are separate lisp commands, but when combined as I have done above it always runs the mslt function but asks for the scale twice?.... I am really confused and any help is much appreciated.

 

Thanks

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