moving objects with lisp

Discussion in 'AutoCAD' started by molokaiboy, Jul 29, 2004.

  1. molokaiboy

    molokaiboy Guest

    How do you select or enter in selection points to move objects using lisp? I am trying to move block1 when block2 is inserted.

    TIA

    Collin
     
    molokaiboy, Jul 29, 2004
    #1
  2. molokaiboy

    BillZ Guest

    You need to use the block object.

    (setq blockobject (vlax-ename->vla-object (car entsel "\nSelect block: <>"))))

    (setq basepoint (getpoint "\nBase Point:")
    destpoint (getpoint "\nDestination Point:"))

    (vla-move blockobj (vlax-3d-point basepoint)(vlax-3d-point destpoint))

    HTH

    Bill
     
    BillZ, Jul 29, 2004
    #2
  3. molokaiboy

    Jürg Menzi Guest

    Hi Bill

    How about:
    (vlax-invoke blockobject 'Move basepoint destpoint)
    no point conversion necessary...;-)

    Cheers
     
    Jürg Menzi, Jul 29, 2004
    #3
  4. molokaiboy

    BillZ Guest

    Fine with me.. :)

    Thanks


    Bill
     
    BillZ, Jul 29, 2004
    #4
  5. molokaiboy

    molokaiboy Guest

    WIth this code, I can put in the block name, base point, and destination point without having any input from the user?

    Collin
     
    molokaiboy, Jul 29, 2004
    #5
  6. molokaiboy

    Joe Burke Guest

    Hi Juerg,

    Just a thought to be safe with the Move method. Given getpoint returns a UCS point
    and Move expects WCS points.

    (vlax-invoke blockobject 'Move (trans basepoint 1 0) (trans destpoint 1 0))

    Joe Burke
     
    Joe Burke, Jul 30, 2004
    #6
  7. molokaiboy

    molokaiboy Guest

    How do I set the base point and destpoint? I know what the coords of the block are and don't want any prompts for the user.

    Collin
     
    molokaiboy, Jul 30, 2004
    #7
  8. molokaiboy

    ECCAD Guest

    Say you want to move Block from PTA to PTB.
    And, further, the X distance to move is 10.0
    And the Y distance is 6.0
    To 'calculate' the relative move, you need to
    make a 'point' - PTB - from PTA (x,y,z).
    Do:
    (setq PTB (list (+ (car PTA) 10.0)(+ (cadr PTA) 6.0) 0.0)); Point PTB
    To 'move' the block, you could then do:
    (setq ss (ssget "C" PTA PTA)); Grab selection set at PTA
    (if ss
    (command "_move" ss "" PTA PTB); and move it
    );if

    Bob
     
    ECCAD, Jul 30, 2004
    #8
  9. Seems to me that if you have constant X and Y displacements, you could skip
    PTB entirely, unless you need to have it to use for something else later.
    Under Bob's assumptions about X and Y:

    (setq ss (ssget "C" PTA PTA)); Grab selection set at PTA
    (if ss
    (command "_move" ss "" "10,6" ""); and move it
    );if

    If the displacements wouldn't always be the same, you would want to prompt
    for them, and then building a PTB from the user input would be a good
    approach, using saved quantities to add to the X and Y coordinates of PTA.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Aug 2, 2004
    #9
  10. molokaiboy

    molokaiboy Guest

    Here is what I have. I get this error msg:
    ; error: bad argument type: numberp: nil


    (setq PTB (list (+ (car PTA) 10.0)(+ (cadr PTA) 6.0) 0.0)); Point PTB
    (setq sss (ssget "C" PTA PTA)); Grab selection set at PTA


    (if(tblsearch "block" BAEC1-A)
    (command "-layer" "S" "notes" "" "" "-insert" "InsertOpticalBlk.dwg" "1.875,16.250" "" "" "0" "-insert" "InsertOpticalBlk2.dwg" "1.875,16.000" "" "" "0" "move" sss "" PTA PTB))

    Collin
     
    molokaiboy, Aug 2, 2004
    #10
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.