Snapping to block insertion point?

Discussion in 'AutoCAD' started by Keithhankins, Jul 5, 2004.

  1. Keithhankins

    Keithhankins Guest

    I am new to lisp and my problem is I have a program where I have to select the objects on the page. I want to do this with in the routine by selecting the insertion point of a block called SheetID and then inputting the distance to the second point at x,y. Does anybody have any ideas?
     
    Keithhankins, Jul 5, 2004
    #1
  2. Keithhankins

    Anthony Guest

    Hello,

    Try using a selection set with filters
    ie

    'select the block (i assume you only have one block in your dwg with the
    name sheetid)
    (setq blockobjs (ssget "X" (list (cons 0 "INSERT") (CONS 2 "SheetID"))))
    'select the first entity in your selection set ie your block
    (setq en (ssname exPlanRl counter))
    'extract the insertpoint of your block
    (setq Insertpnt (assoc 10 (entget en)))

    any help?

    Regards

    Anthony




    the objects on the page. I want to do this with in the routine by selecting
    the insertion point of a block called SheetID and then inputting the
    distance to the second point at x,y. Does anybody have any ideas?
     
    Anthony, Jul 5, 2004
    #2
  3. Keithhankins

    Paul Turvill Guest

    The insertion point of a Block Insertion can be found by accessing the
    INSERT's DXF Code 10:

    (setq blk (entsel "\nSelect a Block Insertion: ")
    dat (entget (car blk))
    inspt (cdr (assoc 10 dat))
    );; setq

    the objects on the page. I want to do this with in the routine by selecting
    the insertion point of a block called SheetID and then inputting the
    distance to the second point at x,y. Does anybody have any ideas?
     
    Paul Turvill, Jul 5, 2004
    #3
  4. Keithhankins

    ECCAD Guest

    You can use this as a starting point.

    ;; Lisp program to select SheetID block.
    (defun C:go ()
    (setq blk_name "")
    (while (/= blk_name "SHEETID")
    (setq blk (entsel "\nSelect the SheetID Block: "))
    (setq dat (entget (car blk)))
    (setq blk_name (strcase (cdr (assoc 2 dat))))
    (setq inspt (cdr (assoc 10 dat))); insertion point
    (if (/= blk_name "SHEETID")
    (alert "Block Picked is not BlockID, please pick the BlockID Block..")
    ); end if
    ); end while
    ;; get offsets
    (setq xoff (getreal "\nOffset in X Direction: "))
    (setq yoff (getreal "\nOffset in Y Direction: "))
    ;; calculate a point..
    (setq pt (list (+ (car inspt) xoff)(+ (cadr inspt) yoff)))
    ;;
    ;; insert some text at that point..
    (if pt
    (progn
    (command "_limits" "off")
    (command "_text" pt "0.125" "0" "INSERTION POINT IS HERE")
    (command "_limits" "on")
    ); end progn
    ); end if
    (princ)
    ); end function

    Cheers

    Bob Shaw
    www.bobscadshop.com
     
    ECCAD, Jul 6, 2004
    #4
  5. Keithhankins

    ECCAD Guest

    Correction. Can't spel either..
    (alert "Block Picked is not SheetID, please pick the SheetID Block..")
    Bob
     
    ECCAD, Jul 6, 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.