Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Snapang to toggle between 0 & 45

  1. #1
    I could stop if I wanted to kwong's Avatar
    Join Date
    2002-11
    Posts
    270
    Login to Give a bone
    0

    Default Snapang to toggle between 0 & 45

    Hi all,
    Is it possible to write a macro, LISP or Diesel or whatever, to control a function key to toggle the snapang between 0 & 45 degrees? What we have now are two F keys to do the job. Thanks.
    kwong.

  2. #2
    Member dkh007.66346's Avatar
    Join Date
    2004-03
    Location
    Dallas, TX
    Posts
    42
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    The simplest thing to do is create an IF statement to check if the SNAPANG is set to 0.0. If if is, then set it to 45 degrees. Hope this helps.

    (defun c:045 ()
    (if (= (getvar "SNAPANG") 0.0)
    (setvar "SNAPANG" (* pi 0.25))
    (setvar "SNAPANG" 0.0)
    )
    (princ)
    )

  3. #3
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    Quote Originally Posted by dkh007.66346
    The simplest thing to do is create an IF statement to check if the SNAPANG is set to 0.0. If if is, then set it to 45 degrees. Hope this helps.
    So true! However, I would like to caution everyone that when you perform an equality test on a real, you would be wise to include a fuzz value:
    Code:
    (if (equal (getvar "SnapAng") 0.0 1e-8)
    I was bitten by this not too long ago, not following my own advice, even after 20+ years of programming!

  4. #4
    Member dkh007.66346's Avatar
    Join Date
    2004-03
    Location
    Dallas, TX
    Posts
    42
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    Quote Originally Posted by RobertB
    So true! However, I would like to caution everyone that when you perform an equality test on a real, you would be wise to include a fuzz value:
    Code:
    (if (equal (getvar "SnapAng") 0.0 1e-8)
    I was bitten by this not too long ago, not following my own advice, even after 20+ years of programming!
    Great tip! Thanks.

  5. #5
    I could stop if I wanted to kwong's Avatar
    Join Date
    2002-11
    Posts
    270
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    Guys,
    Thanks a million, I've just saved an F key for something else.
    kwong (very satisfied customizer)

  6. #6
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    Here is another option.
    You may enter SA [space] 45 [Enter] to set to 45 deg.
    This will set to any angle you enter or you can pick the angle.
    Entering SA [space] [Enter] or SA [Enter] [Enter] or SA 0 [Enter] sets to zero

    Code:
    (defun c:sa (/ ang)
      (if (setq ang (getangle "\nEnter or pick the snap angle: "))
        (setvar "SNAPANG" (* 180.0 (/ ang pi)))
        (setvar "SNAPANG" 0.0) ; SA [Enter] [Enter]
      )
      (princ)
    )
    (prompt "\nSnapAngle lisp loaded, Enter SA [space] the angle and Enter.")
    (princ)

  7. #7
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    Here is some button code for a 45 to 0 toggle.
    It will flip back and forth between 0 and 45 deg.
    Code:
    ^C^C(setvar "SNAPANG" (cond ((equal (getvar "SnapAng") 0.0 1e-8) 45) (0)))

  8. #8
    Member dkh007.66346's Avatar
    Join Date
    2004-03
    Location
    Dallas, TX
    Posts
    42
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    Another one that let's you pick an entity... This is about 14 years old, one of my first LISP routines. Of course with POLAR set to 45, I don't use it as much any more.

    Code:
    (defun c:= (/ r e p1 p2)
      (graphscr)
      (initget "Entity")
      (setq r
    	(getangle "nSnap rotation angle/<Entity>: "))
      (cond
    	((numberp r) (setvar "snapang" r))
    	((and (or (not r) (eq r "Entity"))
    	  (setq e (entsel))
    	  (setq p1 (osnap (cadr e) "qui,end"))
    	  (setq p2 (osnap (cadr e) "qui,mid")))
    	  (setvar "snapang" (angle p1 p2)))
    	(t (princ "nInvalid selection."))
    )
      (princ)
    )

  9. #9
    I could stop if I wanted to kwong's Avatar
    Join Date
    2002-11
    Posts
    270
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    G'day ab2draft,

    I like that, it fits nicely into the button macro without having to load any lisp routine. Thanks.
    kwong

  10. #10
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Snapang to toggle between 0 & 45

    You're welcome.

    If you want to put a lisp in a button without loading the lisp first use this code.
    Code:
    ^C^C(if (not c:lisp_call)(load "lisp_name"));lisp_call
    If the lisp is not loaded it will load it first.
    If you saved the SA lisp above as sa.lsp you would use this:
    Code:
    ^C^C(if (not c:sa)(load "sa.lsp"));sa

Page 1 of 2 12 LastLast

Similar Threads

  1. Toggle XREFS on/off
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2012-08-27, 04:13 AM
  2. (getvar "snapang") not yielding correct value...
    By kmayhew936033 in forum AutoLISP
    Replies: 4
    Last Post: 2009-12-10, 02:20 PM
  3. X Y Z toggle Display??
    By mickaeL_renauD in forum 3ds Max - General
    Replies: 4
    Last Post: 2008-11-25, 03:04 PM
  4. snapang (can you rotate bounding box too)???
    By mark.momper in forum AutoCAD General
    Replies: 1
    Last Post: 2008-08-07, 01:00 PM
  5. Slope Defining Toggle should act like Constrain Toggle
    By gregcashen in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2004-01-15, 10:17 PM

Posting Permissions

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