+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Using
    Architectural DT 2006
    Join Date
    Jun 2007
    Posts
    6

    Default Lisp For Storing And Recalling Layer And Osnap

    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.


    (setq clyr (getvar "clayer")) ;store current layer
    (setvar "clayer" "CLYR") ;RESTORE LAYER

    (setq osm (getvar "osmode")) ;store osnap settings
    (setvar "osmode" "osm") ;RESTORE OSNAP
    I know something is wrong but cannot figure it out. Any help would be apreciated.

  2. #2
    Luminous Being dbroada's Avatar
    Computer Details
    dbroada's Computer Details
    Operating System:
    XP Pro
    Computer:
    Dell
    CPU:
    Intel Xeon 2.13GHz
    RAM:
    2GB
    Graphics:
    NVIDA Quadro FX 580
    Monitor:
    DELL 23" & SAMSUNG 21"
    Discipline
    Electro/Mech
    dbroada's Discipline Details
    Occupation
    Design Engineer
    Discipline
    Electro/Mech
    Using
    Electrical 2013
    Join Date
    Nov 2005
    Location
    Sussex, UK
    Posts
    5,059

    Default

    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

  3. #3
    Forum Newbie
    Using
    Architectural DT 2006
    Join Date
    Jun 2007
    Posts
    6

    Default

    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 ;

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

    ;;;-----------------------------------------------------------------------;;;
    Thank you BTW.

  4. #4
    Forum Newbie
    Using
    Architectural DT 2006
    Join Date
    Jun 2007
    Posts
    6

    Default

    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.

    ;-> 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...
    ;;;-----------------------------------------------------------------------;;;
    Thanks again for the help.
    Last edited by mondomojo1969; 12th Mar 2008 at 03:17 pm.

Similar Threads

  1. lisp for layer vis?
    By Hickoz_bro in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 31st May 2007, 11:30 pm
  2. Need points to new layer lisp
    By grinder in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 12th Mar 2007, 03:19 am
  3. Lisp Routine Osnap Off Help
    By dglenn9000 in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 4th Aug 2006, 11:04 pm
  4. My LISP doesn't work when OSNAP is turned on
    By moss in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 21st Dec 2005, 01:55 pm
  5. layer lisp
    By rjt205 in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 27th May 2005, 06:20 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts