take the quote marks from your variable names in your setvar statements and try again
Registered forum members do not see this ad.
I am trying to create several lisp routines or modify ones already in existence that changes the osnap and layers and performs a function. What I want to do is store the current osnap and layer (or any current settings for that matter), then when the lisp routine changes these, and does its task the original layer is reset and the osnap is set back to what it was before the lisp was run.
I used to do allot of lisp about 10 years ago, and I have honestly forgotten nearly everything I know, I have searched everywhere and the closest I have come to is following.
I know something is wrong but cannot figure it out. Any help would be apreciated.(setq clyr (getvar "clayer")) ;store current layer
(setvar "clayer" "CLYR") ;RESTORE LAYER
(setq osm (getvar "osmode")) ;store osnap settings
(setvar "osmode" "osm") ;RESTORE OSNAP
take the quote marks from your variable names in your setvar statements and try again
"That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson
Dave
Something still isn't working correctly. I am sure you are correct, Maybe it's where I am placing my text?
This is a portion of the lisp routine I am trying to change this is the part that actually draws the object ;
Thank you BTW.;-> draw rafter
(defun raf_draw ( / slope up dn rt rafbot raftop pt3 pt4 pt5
pt6 pt7 pt8 tmpt horiz)
(setq clyr (getvar "clayer")) ;store current layer
(SETVAR "CLAYER" "A-SECT-MEDM"); set current layer to draw rafter on
(setq slope (atan (/ rise 12)))
(setq up (/ pi 2.0))
(setq dn (* pi 1.5))
;-> set direction symbols for polar in draw function
(if (= rafdir 1) ;right
(progn ;then
(setq rt 0.0)
(setq rafbot slope)
(setq raftop (- slope pi))
) ;progn
(progn ;else left
(setq rt pi)
(setq rafbot (- pi slope))
(setq raftop (- pi (- slope pi)))
) ;progn
) ;if
(setvar "osmode" 0)
(setq pt3 (polar pt2 rafbot (/ (- span walwid) (cos slope))))
(setq pt4 (polar pt3 up (/ rafsiz (cos slope))))
(setq pt5 (polar pt4 raftop (/ (+ span eave) (cos slope))))
(if (= eave 0)
(command "Pline" pt1 pt2 pt3 pt4 pt5 pt1 "")
) ;if
(if (and
(> eave 0)
(= tlstyl nil)
) ;and
(progn
(setq pt6 (polar pt5 dn (/ rafsiz (cos slope))))
(setq pt7 (polar pt6 rafbot (/ eave (cos slope))))
(command "Pline" pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt1 "")
) ;progn
) ;if
(if (and
(> eave 0)
(/= tlstyl nil)
) ;and
(progn
(if
(= tlstyl 0)
(progn ;then ripped
(setq pt6 (polar pt5 dn (/ tlsiz (cos slope))))
(setq pt7 (polar pt6 rafbot (/ eave (cos slope))))
(command "Pline" pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt1 "")
) ;progn
(progn ;else bobbed
(setq pt6 (polar pt5 dn (/ tlsiz (cos slope))))
(setq tmpt (polar pt6 rt eave))
(setq pt7 (inters pt6 tmpt pt2 pt3 nil))
(setq horiz (distance pt6 pt7))
(if (> horiz eave)
(progn ;then
(setq pt7 (polar pt6 rt eave))
(setq pt8 (polar pt6 rt eave))
) ;progn then
(setq pt8 (polar pt7 rafbot (/ (- eave horiz) (cos slope))))
) ;if
(command "Pline" pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt1 "")
(setvar "clayer" CLYR) ;RESTORE LAYER
) ;progn
) ;if
) ;progn
) ;if
) ;defun
;;;-----------------------------------------------------------------------;;;
Registered forum members do not see this ad.
Never mind I figured it out, the change has to go on the actual command portion of the lisp routine that runs all the commands.
Thanks again for the help.;-> define acad command "rafter"
(defun c:rafter ( / rise span rafsiz eave tlstyl tlsiz pt1 pt2
walwid rafdir scmd sosm )
(setq clyr (getvar "clayer")) ;store current layer
(princ "\nRafter.lsp Modified for architectural use for SEI by CRC 02-19-08")
(raf_setup)
(raf_info)
(raf_draw)
(raf_normex)
(princ)
(setvar "clayer" CLYR) ;RESTORE LAYER
) ;defun
;;;-----------------------------------------------------------------------;;;
;;; End Of Rafter.lsp, Thank You...
;;;-----------------------------------------------------------------------;;;
Last edited by mondomojo1969; 12th Mar 2008 at 03:17 pm.
Bookmarks