Center block lisp

Discussion in 'AutoCAD' started by Steve W., Jan 15, 2004.

  1. Steve W.

    Steve W. Guest

    Below is a custom button I created to be able to center a block between two points by selecting the block then selecting the two points. In this particular case I want the two points to always be intersections (ceiling grid). I have another button that is always centering between to circles (recessed lights). Is there a way to make this into a lisp or something so that I can simply right click to bring up the command again? This works well for me but sometimes it is annoying to not be able to simply right click to get the command again. The point I am copying the block from could be either an insertion point or a center point. I guess the way I am trying to get it to work is to pick my block on the screen and then select the two points I want it in between and then keep on picking the points to insert it in multiple locations during the same command. The two points would always be either an intersection or a center osnap.

    C^C^_osmode;4;copy;\;\'cal (int+int)/2;
     
    Steve W., Jan 15, 2004
    #1
  2. Steve W.

    ECCAD Guest

    Steve,
    The attached will get you started. Load the Lisp, type in CB.
    Cheers.
    Bob Shaw
    (bobscadshop.com)
     
    ECCAD, Jan 15, 2004
    #2
  3. Steve W.

    Jim Claypool Guest

    You can't do it without creating a command.

    (defun c:copyctr ( / pt1 pt2 pt3 ename)
    (setvar "osmode" 36) ;set osnap to center and intersect
    (while (not (setq ename (entsel "\nSelect block to copy: "))))
    (setq ename (car ename))
    (setq
    pt1 (cdr (assoc 10 (entget ename)))
    pt2 (getpoint "\nFirst point: ")
    pt3 (getpoint "\nSecond point: ")
    )
    (command ".copy" ename "" pt1 (polar pt2 (angle pt2 pt3) (/ (distance pt2
    pt3) 2.0)))
    (princ)
    )

    For your menu pick use ^C^Ccopyctr

    two points by selecting the block then selecting the two points. In this
    particular case I want the two points to always be intersections (ceiling
    grid). I have another button that is always centering between to circles
    (recessed lights). Is there a way to make this into a lisp or something so
    that I can simply right click to bring up the command again? This works well
    for me but sometimes it is annoying to not be able to simply right click to
    get the command again. The point I am copying the block from could be either
    an insertion point or a center point. I guess the way I am trying to get it
    to work is to pick my block on the screen and then select the two points I
    want it in between and then keep on picking the points to insert it in
    multiple locations during the same command. The two points would always be
    either an intersection or a center osnap.
     
    Jim Claypool, Jan 15, 2004
    #3
  4. Steve W.

    Steve W. Guest

    Thanks that works great.
     
    Steve W., Jan 15, 2004
    #4
  5. Steve W.

    Steve W. Guest

    Thanks this one works great too.
     
    Steve W., Jan 15, 2004
    #5
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.