Author Topic: FYI.... GetAngle has defaults!  (Read 2172 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
FYI.... GetAngle has defaults!
« on: October 05, 2007, 05:44:54 PM »
I was updating one of my routines, and was going to ask the user to select an object to copy it's rotation (angle), so I was going to use
Code: [Select]
(initget "Select")
(setq Opt (getangle "\n Enter angle [Select object]: "))
But this will give you the default for 'south' with your current setup.  I just tested, because that was just a guess that the letter stood for south, and sure enough if you enter 'n' = north, 'e' = east, 'w' = west.

Thought I would share incase someone else tried this one day, and got strange answers that they didn't expect.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: FYI.... GetAngle has defaults!
« Reply #1 on: October 05, 2007, 06:21:47 PM »

That's odd that it does not honor the keyword defined in (initget) if the keyletter is N E W or S. Anything else works as expected. Thanks for catching that one, Tim.


LE

  • Guest
Re: FYI.... GetAngle has defaults!
« Reply #2 on: October 05, 2007, 06:23:59 PM »
You found one of those undoc features... great finding !

ASMI

  • Guest
Re: FYI.... GetAngle has defaults!
« Reply #3 on: October 06, 2007, 01:59:22 AM »
There is ENTSEL imitation with options. Use COND to elaborate output.

Code: [Select]
(defun Asmi_Entsel_w_Options(Message / grLst filPt selSet)
     (if Message
       (princ Message)
       (princ "\nSelect object: ")
       ); end if
        (setq lChr ""
          grLst(list 2 678)
          tStr ""
          ); end setq
        (while
          (and
              (not
            (member lChr '(" " "\r")))
          (/= 3(car grLst))
        ); end or
      (if
        (setq grLst(grread nil 4 2))
        (progn
          (cond
          ((= 3(car grLst))
           (setq filPt(cadr grLst)
                 selSet(ssget filPt)
                 ); end setq
           (if selSet
               (setq outVal
                (list(ssname selSet 0)filPt))
             ); end if
           ); end cond #1
          ((= 2(car grLst))
           (setq lChr(chr(cadr grLst)))
           (if
             (not
               (member lChr '(" " "\r")))
                 (progn
                 (setq tStr(strcat tStr lChr)
                   outVal tStr); end setq
                 (princ lChr)
               ); end progn
             ); end if
           ); end cond #2
            ); end cond
           ); end progn
          ); end if
         ); end while
        outVal
    ); end of aAsmi_Entsel_w_Options