newbie/oldie code needs help

Discussion in 'AutoCAD' started by Rob Davis, Jul 21, 2004.

  1. Rob Davis

    Rob Davis Guest

    Could someone look at this and tell me what I am doing wrong. It's been
    a long time since I tried to do a lisp routine and I never really got
    the hang of it. So please don't laugh. ;-) Could you please tell me what
    I am doing wrong here?


    Thanks in advance.
    Rob

    (defun c:mr (/ OLD_OS NEW_OS RTU_BLK)
    (setq OLD_OS (getvar "osmode"))
    (setq NEW_OS (setvar "osmode" 675))
    (defun from (/ PT-1 PT-2)
    (setq PT-1 (getpoint "\nSelect Column or Wall: "))
    (setvar "LASTPOINT" PT-1)
    (setq PT-2 (getpoint "\n<Offset Distance>: "))
    )
    (setq RTU_BLK (nentsel "Select RTU")
    )
    (command "move" RTU_BLK (from))
    (setvar "osmode" OLD_OS)
    (princ)
    )
     
    Rob Davis, Jul 21, 2004
    #1
  2. Rob Davis

    Paul Turvill Guest

    You're working too hard (i.e., unneeded code). Try this:

    (defun c:mr (/ OLD_OS RTU_BLK)
    (setq OLD_OS (getvar "osmode"))
    (setvar "osmode" 675)
    (setq PT-1 (getpoint "\nSelect Column or Wall: "))
    (setq PT-2 (getpoint "\n<Offset Distance>: "))
    (setq RTU_BLK (nentsel "Select RTU"))
    (command "move" RTU_BLK "" PT-1 PT-2)
    (setvar "osmode" OLD_OS)
    (princ)
    )
     
    Paul Turvill, Jul 21, 2004
    #2
  3. Rob Davis

    ECCAD Guest

    ;; Very close, try this modified version.

    (defun c:mr (/ OLD_OS RTU_BLK PT-1 PT-2)
    (setq OLD_OS (getvar "osmode"))
    (setvar "osmode" 675)
    ;
    (setq PT-1 (getpoint "\nSelect Column or Wall: "))
    (setvar "LASTPOINT" PT-1)
    (setq PT-2 (getpoint "\n<Offset Distance>: "))
    (setq RTU_BLK (nentsel "\nSelect RTU"))
    (if RTU_BLK
    (command "move" RTU_BLK pt-1 pt-2)
    );if
    (setvar "osmode" OLD_OS)
    (princ)
    )

    Bob
     
    ECCAD, Jul 21, 2004
    #3
  4. Rob Davis

    ECCAD Guest

    Correction:
    (command "move" RTU_BLK "" pt-1 pt-2)
     
    ECCAD, Jul 21, 2004
    #4
  5. Rob Davis

    Paul Turvill Guest

    As far as I can see, setting LASTPOINT serves no purpose, and
    (command "move" RTU_BLK pt-1 pt-2)
    requires another "" to close out the selection set:
    (command "move" RTU_BLK "" pt-1 pt-2)
    ___
     
    Paul Turvill, Jul 21, 2004
    #5
  6. Rob Davis

    dblaha Guest

    Ditto, but just a little tighter:

    (defun c:mr (/ OLD_OS)
    (setq OLD_OS (getvar "osmode"))
    (setvar "osmode" 675)
    (command "move" (nentsel "\nSelect RTU") ""
    (getpoint "\nSelect Column or Wall: ")
    (getpoint "\n<Offset Distance>: "))
    (setvar "osmode" OLD_OS)
    (princ)
    )
     
    dblaha, Jul 21, 2004
    #6
  7. Rob Davis

    Rob Davis Guest

    I'm sorry guys, I tried all of them and it still just goes thru the
    routine without doing any move. What I am trying to do is select the
    block, pick it up by an endpoint and move it by however many feet or
    inches to either side/or up,down of the wall or column that was
    indicated by PT-1. The routine runs through and doesn't error out, yet
    it doesn't move the block either.
    Thanks in advance again,
    I guess I should've said what I was trying to do in the first place. I
    am kind of trying to emulate the move command using the "from" + "nea or
    per" osnap and moving the cursor to any side of the pick point that is
    indicated when I do this and giving direct input coordinates entry.
    Hopefully I have explained what I am trying to do, as you might notice,
    I also have a problem sometimes conveying what I am thinking. ;-)

    -Rob
     
    Rob Davis, Jul 21, 2004
    #7
  8. Rob Davis

    ECCAD Guest

    ; Modified, using (ssget) instead of (nentsel)
    ;
    (defun c:mr (/ OLD_OS RTU_BLK PT-1 PT-2)
    (setq OLD_OS (getvar "osmode"))
    (setvar "osmode" 675)
    (setq PT-1 (getpoint "\nSelect Column or Wall: "))
    (setq PT-2 (getpoint "\n<Offset Distance>: "))
    (setvar "osmode" 0)
    (prompt "\Select RTU")
    (setq RTU_BLK (ssget))
    (if RTU_BLK
    (command "move" RTU_BLK "" pt-1 pt-2)
    );if
    (setvar "osmode" OLD_OS)
    (princ)
    )

    Cheers
    Bob
     
    ECCAD, Jul 22, 2004
    #8
  9. Rob Davis

    ECCAD Guest

    Another correction..not enough cofee..

    (prompt "\nSelect RTU")

    Bob
     
    ECCAD, Jul 22, 2004
    #9
  10. Rob Davis

    Rob Davis Guest

    Thanks Bob, it still doesn't work like I want it to. I was doing some
    more work on it yesterday and tried to figure out how to add to it so
    that I can tell it which side of the column or wall I want to move it to
    and I must say it is becoming more involved than I figured on. I don't
    think I could drink enough coffee to help me that much. ;-)

    Thanks again,
    I have a project I have to get out today so it may be next week before I
    can get back to it and post what I have done.

    -Rob
     
    Rob Davis, Jul 22, 2004
    #10
  11. Rob Davis

    ECCAD Guest

    Ok,
    I'll hang in there..waiting..
    :)
    Bob
     
    ECCAD, Jul 23, 2004
    #11
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.