Is there a way to extract XYZ coordinates from only xref blocks?

Is there a way to extract XYZ coordinates from only xref blocks?

Anonymous
Not applicable
1,923 Views
4 Replies
Message 1 of 5

Is there a way to extract XYZ coordinates from only xref blocks?

Anonymous
Not applicable

Hello,

I'm working on a big project and we're having some trouble with xrefs ending up at different insertion Points (probably due to the original drawing having a faulty BASE)

 

Now I'd like to do a data extraction reporting the XYZ coordinates of just the Xrefs of the files

(so I can easily track the faulty insertions)

 

I've gotten so far that I can extract the correct data, but is there any fast and reliable way to select just the xrefs and not have to deselect other blocks in the drawing so the process can be automated more easily?

 

Ideally I'd create something like:

data extraction > select all xrefs in selected drawings > extract XYZ coordinates > output to excel file

0 Likes
Accepted solutions (1)
1,924 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... is there any fast and reliable way to select just the xrefs and not have to deselect other blocks in the drawing so the process can be automated more easily?

....


One way is to check whether the Block table entry for each INSERT object contains a path  [i.e. an (assoc 1) entry other than an empty "" string], which only Xrefs do.  This reports their "Block" names to the command line, but you can adjust it to put their entity names into a list or a selection set, or send each one's information out to an external file as it goes, or whatever else makes the most sense for the data extraction.

 

(setq blkss (ssget "_X" '((0 . "INSERT")))); get all INSERT objects

(repeat (setq n (sslength blkss))

  (if

    (/= ; looking for those without a path string

      (cdr

        (assoc 1 ; path, if there is one

          (entget

            (tblobjname "block"

              (setq xrname (cdr (assoc 2 (entget (ssname blkss (setq n (1- n))))))); name

            ); tblobjname

          ); entget

        ); assoc

      ); cdr

      "" ; empty string [means ordinary Block]

    ); /= ; if it isn't  empty, it's an Xref, so:

    (prompt (strcat "\n" xrname))

  ); if

); repeat

 

Another way is to check whether the (assoc 70) value contains the 4 or 8 "bit" that indicate an attached or overlaid Xref:

 

(repeat (setq n (sslength blkss))

  (if

    (/= ; looking for those not  containing those bits

      (logand

        (cdr

          (assoc 70

            (entget (tblobjname "block" (setq xrname (cdr (assoc 2 (entget (ssname blkss (setq n (1- n)))))))))

          ); assoc

        ); cdr

        12 ; = 4 + 8

      ); logand

      0 ; if it's an Xref, this will be 4 or 8 or 12

    ); /= so if that's the case [i.e. it's not zero]:

    (prompt (strcat "\n" xrname))

  ); if

); repeat

Kent Cooper, AIA
Message 3 of 5

john.vellek
Alumni
Alumni

Hi @Anonymous,

 

I see that you are visiting as a new member to the AutoCAD forum. Welcome to the Autodesk Community!

 

 When you set up the dataextraction, it allows you to select which drawing(s) to utilize. Simply select the Xref files and not the host file and I think that should give you the results you want.

 

Capture.PNG

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
Message 4 of 5

Anonymous
Not applicable

Thanks!

 

However, I'm specifically interested in the xref insertion points (perhaps I wasn't clear on this point) and so I'm looking for a way to extract this data from host files in a sleek manner, preferably without having to bother with the other blocks. Of course, being new to this side of CAD:ing I might have missed something in your description.

 


@john.vellek wrote:

Hi @Anonymous,

 

I see that you are visiting as a new member to the AutoCAD forum. Welcome to the Autodesk Community!

 

 When you set up the dataextraction, it allows you to select which drawing(s) to utilize. Simply select the Xref files and not the host file and I think that should give you the results you want.

 

Capture.PNG

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


 

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

…. I'm specifically interested in the xref insertion points (perhaps I wasn't clear on this point) and so I'm looking for a way to extract this data from host files in a sleek manner, preferably without having to bother with the other blocks. …. 


You could change this line in the first routine in Message 2:

              (setq xrname (cdr (assoc 2 (entget (ssname blkss (setq n (1- n))))))); name

 

to this, to keep the entity data list for use later:

 

              (setq xrname (cdr (assoc 2 (setq xrdata (entget (ssname blkss (setq n (1- n)))))))); name

 

and then at the end, pull the insertion point from that, by replacing this line:

 

    (prompt (strcat "\n" xrname))

 

to something involving:

    (cdr (assoc 10 xrdata))

 

which is the insertion point, as a list of XYZ coordinates.  What you surround that with depends on exactly what kind of file you want to put it in [involving a (write-line) function and a conversion from numbers to text], or what kind of Text you want to draw it into the drawing with, or ….

Kent Cooper, AIA