Error setting system variable.

Discussion in 'AutoCAD' started by Chip Harper, Feb 1, 2005.

  1. Chip Harper

    Chip Harper Guest

    I'm tweaking my codes and have run into a wall on 1 system variable,
    UCSAXISANG.

    Here is a snip of the relavent code that loads the values and resets the
    variables:

    (setq VARIABLE_LIST (load "chLIST_SYSVAR.txt"))
    ;;
    ;;
    (foreach CSET VARIABLE_LIST
    (setq CVAR (nth 0 CSET)) ; Variable
    (setq CVAL (nth 1 CSET)) ; Value
    (setvar CVAR CVAL) ; Set values
    ) ; End foreach


    Here is the structure of the data list:

    (quote(
    ( "UCSAXISANG" 1.5708)
    ))

    AutoCAD rejects the value as a radian ( "UCSAXISANG" 1.5708) and as a degree
    ( "UCSAXISANG" 90).

    What am I doing wrong here?
     
    Chip Harper, Feb 1, 2005
    #1
  2. Chip Harper

    BTO Guest

    hi,

    (setvar "UCSAXISANG" 45) doesn't work

    but :

    (setvar "UCSAXISANG" (/ pi 4.0)) does

    need radians, but allowed values are exactly : 5, 10, 15, 18, 22.5, 30, 45,
    90, 180 degrees

    Bruno Toniutti
     
    BTO, Feb 1, 2005
    #2
  3. Chip Harper

    Chip Harper Guest

    That gets me ...Error: bad argument value: AutoCAD variable value: (/ PI
    4.0)

    I tried radians ( "UCSAXISANG" 1.5708), which is equal to 90 and should be a
    valid input amount but it errors out ...

    The code works correctly for "POLARANG" 1.5708 but the same value for
    UCSAXISANG is rejected.
     
    Chip Harper, Feb 1, 2005
    #3
  4. Chip Harper

    BTO Guest

    may be a solution :
    (setvar "UCSAXISANG" 1.5708) doesn't work
    (setvar "UCSAXISANG" 1.57079 ) doesn't work
    but
    (setvar "UCSAXISANG" 1.570796 ) works

    despite help file, POLARANG accepts every value,



    tested with map 2005 sp2

    Bruno Toniutti
     
    BTO, Feb 1, 2005
    #4
  5. Chip Harper

    Joe Burke Guest

    Chip,

    Not true.

    Command: (equal 1.5708 (* pi 0.5))
    nil

    As Bruno said, the variable only accepts values expressed as radians given the degree
    values he listed.

    So for 10 degrees:

    Command: (setvar "ucsaxisang" (/ pi (/ 180 18)))
    0.314159

    IOW, always express the value in a form derived from pi.

    HTH
    Joe Burke
     
    Joe Burke, Feb 1, 2005
    #5
  6. Chip Harper

    Joe Burke Guest

    PS

    Watch out for dividing integers as I suggested. One or both numbers should be a real
    to return the correct answer.

    Command: (/ 3 2)
    1

    First grade math says that answer is wrong.

    Command: (/ 3.0 2)
    1.5
     
    Joe Burke, Feb 1, 2005
    #6
  7. Chip Harper

    Chip Harper Guest

    BTO,

    Using '1.570796' resolved the problem. Thanks!
     
    Chip Harper, Feb 1, 2005
    #7
  8. I use the function DTR (degrees to radians) and don't deal with decimal
    places...

    (defun DTR (a)
    (* pi (/ a 180.0))
    )

    so that for 10 degrees I would use (DTR 10) which returns the value
    0.174533.
     
    Michael Lemerond, Feb 1, 2005
    #8
  9. Chip Harper

    Chip Harper Guest

    Whats not true?

    I'm not doing this from the comand line, I'm pulling the data from a quoted
    list ( a .txt file) ... my first attempt was derived from pi ... which
    returns: Error: bad argument value: AutoCAD variable value: (* PI (/ 90
    180.0)).
     
    Chip Harper, Feb 1, 2005
    #9
  10. Chip Harper

    Joe Burke Guest

    Michael,

    When I see DTR or RTD in code, I think the author simply doesn't understand angles
    expressed as radians.

    Joe Burke
     
    Joe Burke, Feb 1, 2005
    #10
  11. Chip Harper

    BTO Guest

    Glad I could help

    Bruno Toniutti
     
    BTO, Feb 1, 2005
    #11
  12. Chip Harper

    Joe Burke Guest

    Chip,

    You said:

    I tried radians ( "UCSAXISANG" 1.5708), which is equal to 90.

    The following proves that's not true. Which should be obvious since any math
    operation applied of an irrational number like pi, will return an irrational number.

    Command: (equal 1.5708 (* pi 0.5))
    nil

    Joe Burke
     
    Joe Burke, Feb 1, 2005
    #12
  13. Chip Harper

    Chip Harper Guest

    OK, but if I enter this at the command line .....

    (* PI (/ 90 180.0))

    AutoCAD returns:

    1.5708

    So it's wasn't obvious to this old fart redneck sitting behind the keyboard.
    :)
     
    Chip Harper, Feb 1, 2005
    #13
  14. Chip Harper

    Doug Broad Guest

    Hi Joe,
    That's not a justifiable position. Many times an angle specified in degrees
    is more conveniently converted with a packaged function rather than risk
    making errors by doing it on the fly. The purpose is also self documenting.

    Your posted example up thread is a case in point
    (/ pi (/ 180 18))) is not the same thing as 10 degrees in terms of radians.

    The result above is just pi/10 rather than (* 10 (/ pi 180))

    Any time I can reduce my chance of making errors, I take it.

    Regards,
    Doug
     
    Doug Broad, Feb 1, 2005
    #14
  15. Chip Harper

    Don Butler Guest

    Chip...

    From help

    UCSAXISANG System Variable

    Type: Integer
    Saved in: Registry
    Initial value: 90
    Stores the default angle when rotating the UCS around one of its axes using
    the X, Y, or Z options of the UCS command. Its value must be entered as an
    angle in degrees (valid values are: 5, 10, 15, 18, 22.5, 30, 45, 90, 180).

    Not exactly what help implies...

    Command: (setq val (rtd (getvar "UCSAXISANG")))
    90.0

    Command: (setvar "UCSAXISANG" (dtr val))
    1.5708

    Don
     
    Don Butler, Feb 1, 2005
    #15
  16. Chip Harper

    Joe Burke Guest

    Hi Doug,

    Agreed and point taken.

    What can I say about this: (/ pi (/ 180.0 18)) other than just plain dumb and it was
    pushing 4:30 AM. :)

    Joe Burke
     
    Joe Burke, Feb 2, 2005
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.