stuck on new lisp

Discussion in 'AutoCAD' started by CEIDave, Jan 20, 2004.

  1. CEIDave

    CEIDave Guest

    Ok... I'm trying to write a lisp that will allow me to change the rotation of attributes in relation to the block they are in by just picking the attribute. I'm planning on using the "cal" function within the -attedit command to do this. Only I'm stuck on how to make the "cal" part work. There is obviously alot more to do with this, but I'm just wanting help on this for now (not wanting you guys to write the code for me, just give me a bit of a kick in the hind to get moving again). Any ideas? If using this command from the command prompt, I just have to put " 'cal " in when the angle prompt pops up, but everything I've tried in this partial lisp brings back "Requires valid numeric angle or second point.
    ; error: Function cancelled" or " ; error: bad argument value: AutoCAD command: CAL"

    Thanks in advance for any help or suggestions!

    (defun C:RAT ()
    (SETQ A1 (GETANGLE "\nWhat is the angle of the block?")
    A2 (/(* A1 180.0)PI)
    )
    (COMMAND "-ATTEDIT" "" "" "" "" Pause "" "A" "'cal "A2 + 180"")
    (PRINC)
    )
     
    CEIDave, Jan 20, 2004
    #1
  2. CEIDave

    Dave Zinn Guest

    I dont believe that it is possible to call "cal" from lisp. Just do your
    calculations in lisp directly, & store them as a symbol.


    of attributes in relation to the block they are in by just picking the
    attribute. I'm planning on using the "cal" function within the -attedit
    command to do this. Only I'm stuck on how to make the "cal" part work. There
    is obviously alot more to do with this, but I'm just wanting help on this
    for now (not wanting you guys to write the code for me, just give me a bit
    of a kick in the hind to get moving again). Any ideas? If using this command
    from the command prompt, I just have to put " 'cal " in when the angle
    prompt pops up, but everything I've tried in this partial lisp brings back
    "Requires valid numeric angle or second point.
     
    Dave Zinn, Jan 20, 2004
    #2
  3. CEIDave

    R.K. McSwain Guest

    Yes, it is possible.

    (c:cal expression)
     
    R.K. McSwain, Jan 20, 2004
    #3
  4. CEIDave

    Mark Propst Guest

    I don't understand why you want to use 'cal.

    what you have written could also be done like this;
    (defun C:RAT ()
    (SETQ A1 (GETANGLE "\nWhat is the angle of the block?")
    A2 (/(* A1 180.0)PI)
    A3 (+ A2 180)
    )
    (COMMAND "-ATTEDIT" "" "" "" "" Pause "" "A" A3 "")
    (PRINC)
    )

    of attributes in relation to the block they are in by just picking the
    attribute. I'm planning on using the "cal" function within the -attedit
    command to do this.
     
    Mark Propst, Jan 20, 2004
    #4
  5. CEIDave

    CEIDave Guest

    Thanks Mark, I had kinda thought that way at first, but I guess I got locked into the mindset of using the cal command.
     
    CEIDave, Jan 20, 2004
    #5
  6. CEIDave

    Mark Propst Guest

    You're welcome
    :)
    also, can't you get the rotation of the block just by reading it's rotation
    after picking the attribute, instead of having to enter the angle manually -
    or does that not apply in your situation?

    locked into the mindset of using the cal command.
     
    Mark Propst, Jan 21, 2004
    #6
  7. CEIDave

    rdi Guest

    Also--rather than asking the user to tell you the angle of the block, why
    not just extract it yourself?

    (princ "Select the attribute: ")
    (setq ent(entsel))
    (if ent
    (setq a1(cdr (assoc 50 (entget (cdr ent)))))
    (setq A2 (/(* A1 180.0)PI))
    (setq A3 (+ A2 180))
    ;(car ent) will return the coordinate the user chose. Hopefully
    ;attedit will use this coordinate to get the attribute
    (COMMAND "-ATTEDIT" "" "" "" "" (car ent) "" "A" A3 "")
    )
     
    rdi, Jan 21, 2004
    #7
  8. CEIDave

    Jamie Duncan Guest

    at this point, why not use entmod with subst on the attribute rotation?

    Jamie
     
    Jamie Duncan, Jan 21, 2004
    #8
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.