Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

linetype lisp help

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
dlyons1
910 Views, 3 Replies

linetype lisp help

Been a long time since I've written any lisp. I am trying to write a lisp to get the current linetype, load new linetype and set as current, allow you to draw a line with that newly loaded linetype then return the linetype to previous linetype. Make since? Here is the code;

 

(defun c:ldlt()
(setq CLT (getvar "celtype"))
(setq a "data")
  (if (= (tblsearch "ltype" a) nil) 
   (command "-linetype" "l" a "data.lin" "")
   (princ)
  )
 (setq D "data")
  (command "-linetype" "_s" D "")
   (command "line")
;    (setvar "celtype" CLT)
)

If I leave the  (setvar "celtype" CLT) line in it just restores to CLT and draws a line. If I take it out it does load and set the linetype and lets me draw the line with the linetype but does not return the previous linetype. Any help greatly appreciated.

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: dlyons1

Something like this perhaps.

 

(defun c:ldlt ()
  (setq CLT (getvar "celtype"))
  (setq a "data")
  (if (= (tblsearch "ltype" a) nil)
    (command "-linetype" "l" a "data.lin" "")
  )
  (setq D "data")
  (command "-linetype" "_s" D "")
  (command "line")
  (while (> (getvar 'cmdactive) 0)
    (command pause)
  )
  (setvar "celtype" CLT)
  (princ)
)

HTH

Henrique

EESignature

Message 3 of 4
dlyons1
in reply to: hmsilva

Thanks, I knew it was something simple. I haven't touched lisp in about 8 years. Thanks again!

Message 4 of 4
hmsilva
in reply to: dlyons1

You're welcome.
Glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost