Get attribute values from xref dynamic block

Get attribute values from xref dynamic block

Anonymous
Not applicable
1,392 Views
2 Replies
Message 1 of 3

Get attribute values from xref dynamic block

Anonymous
Not applicable

Anyone can help to enhance this lisp to list the attribute value of xref block (dynamic block) for a grid line.

Below is the link to attached lisp, which can be a starting point. Need to improve this lisp to select xref block and it's a dynamic block.

  http://forums.augi.com/showthread.php?150072-Get-Attribute-Value-from-Block-Tag

Attached is a sample grid lines. Xref-attached this grid to a new drawing. It is in this new drawing I want to list any grid to get the Grid-Ref value.

This is to avoid zoom in/out and pan to find out the xref grid number when working in the center of he drawing.

 

(vl-load-com)

(defun c:GAV (/ LM:GetAttributeValue ss attValue)

  (defun LM:GetAttributeValue (blk tag / val enx)
    (while
      (and
        (null val)
        (= "ATTRIB"
           (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))
        )
      )
       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
         (setq val (cdr (assoc 1 enx)))
       )
    )
  )

  (if (and (setq ss (ssget ":S:E" '((0 . "INSERT") (2 . "GRID") (66 . 1))))
           (setq attValue (LM:GetAttributeValue (ssname ss 0) "GRID-REF"))
      )
    (prompt (strcat "\n[Attribute Value] : " attValue))
  )
  (princ)
)

Thanks

0 Likes
Accepted solutions (1)
1,393 Views
2 Replies
Replies (2)
Message 2 of 3

SeeMSixty7
Advisor
Advisor

Since the Attribute is in a Block inside of an Xref, and you don't have access directly to pick the attribute entity itself, you could consider the following.

 

Select the point on the xref for reference. (Basically touch the line you are wanting the grind info for.

Discover the XREF's name and full path. (get any other info needed ins point, rotation, scale.)

Use ODBX to open the file

Since it is an xref the space to search is model space. Search model space entities until you come to the desired block you are looking for,

Compare it's insertion point parameters to see if the point selected is along that axis, (translate the points as needed for the scale rotation and ins point)

If the point matches retrieve the attribute data.

Keep stepping til you find it.

display data to user or provide to calling function.

 

Good luck,

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thanks SeeMSixty7. That's a bit high level for me.

I changed the selection to be able to select dynamic block. I then incorporate refedit into this routine, list the attribute then close refedit.

It's all good. Thanks

0 Likes