find an insertion point of block within an xref

Discussion in 'AutoCAD' started by Tom Hanley, Jul 9, 2004.

  1. Tom Hanley

    Tom Hanley Guest

    How can I find an insertion point of a block that is within an xref drawing?
    I want to use a lisp routine if practical.
    Thanks,
    Tom Hanley
     
    Tom Hanley, Jul 9, 2004
    #1
  2. Tom Hanley

    Rudy Tovar Guest

    You have to create a reoccurring loop, so that it passes through the entire
    xref and any there after to extract relative to the actual xref insertion
    point any insertions. Then simply return the insertion point of each block
    relative the xref insertion point. Why do I say relative?, because you may
    have placed the xref in a different insertion point in the current drawing,
    and it will only report the insertion point of the selected xref. Here's an
    example of looping and gathering info of a selected xref.

    (defun c:scan (/ e da ty)

    (setq e (entsel"\nSelect block: "))

    (if e
    (progn
    (setq da (entget (car e))
    ty (cdr (assoc 0 da))
    )
    (if (= ty "INSERT")
    (progn
    (setq na (cdr(assoc 2 da)))
    (scan_insert na)
    )
    (progn
    )
    )
    )
    )
    (princ)
    )

    (defun scan_insert ( na / );id ln n y d area cn)

    (vmon)
    (setq id (tblsearch "block" na)
    ln (length id)
    )

    (if (= ln 6)
    (progn
    (setq area (entget(cdr (assoc -2 id)))
    ent (cdr (assoc -1 area))
    cn 0)

    (while
    (and ent
    (setq n (entnext ent))
    )
    ;(pointcollector1 cn)
    (setq d (entget n)
    y (cdr (assoc 0 d))
    )
    (prompt"\n")
    (princ y)
    (princ d)
    (if (= y "INSERT")
    (progn
    (setq x (cdr (assoc 2 d)))
    (scan_insert x)
    )
    )
    (setq ent n cn (1+ cn))

    )
    )
    )


    (princ)
    )

    (defun pointcollector1 (counter /)


    (princ (strcat "\rProcessing: "
    (rtos counter 2 0)
    " Lines/Plines "
    )
    )
    )
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jul 9, 2004
    #2
  3. Tom Hanley

    andywatson Guest

    Rudy!
    I didn't know it was possbile to scan an xref's entities! Holy frijoles batman, this opens up so many doors.
    Thanks.
     
    andywatson, Jul 9, 2004
    #3
  4. Tom Hanley

    Josh Guest

    Command: (setq a (nentsel)) ;select the block you want

    Select object: (<Entity name: 412f1538> (29062.2 29561.0 0.0) ((1.0 0.0 0.0)
    (0.0 1.0 0.0) (0.0 0.0 1.0) (29061.2 29563.1 0.0)) (<Entity name: 412f1708>
    <Entity name: 400d8f30>))

    Command: (setq b (entget (car (last a))))
    ((-1 . <Entity name: 412f1708>) (0 . "INSERT") (330 . <Entity name:
    412f4cf8>)
    (5 . "63D9") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
    "base|p-util-san-mh") (100 . "AcDbBlockReference") (2 . "Base|SAN MH-4") (10
    29061.2 29563.1 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0)
    (71 .
    0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

    Command: (cdr (assoc 10 b))
    (29061.2 29563.1 0.0) ;returns the insertion of the selected block
     
    Josh, Jul 9, 2004
    #4
  5. Tom Hanley

    Rudy Tovar Guest

    Then again he could be talking about multiple occurrences...

    If not him, perhaps others..
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jul 9, 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.