Lisp to list layer xrefs inserted on

Lisp to list layer xrefs inserted on

ralstogj
Collaborator Collaborator
5,421 Views
27 Replies
Message 1 of 28

Lisp to list layer xrefs inserted on

ralstogj
Collaborator
Collaborator

Hi, Guys

I am tying to piece together a piece of lisp code that will look at all the xrefs in a drawing and find what layer they are inserted on and then print the xref name and the layer at the command line. I found this example for listing the paths Example of Listing Paths. It that does something similar to what I want. I have tried for a couple of hours to re write to give the layer name with on luck below is my code so far. If some one could get it working that would be appreciated so long since I did lisp I have forgotten most things.

 

 

 

 

(defun c:xreflayers ()
(vl-load-com)
(vlax-for item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(if (= (vla-get-isxref item) :vlax-true)

(setq oLayer(vla-item(vla-get-layers(vla-get-activedocument (vlax-get-acad-object)))));; oxref layer
(setq layerName (cdr (assoc 8 (entget oLayer))))


)

(princ (strcat "\nXref name: "(vla-get-name item)" --- Layer: " layername)
)
)
(princ)
)

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
0 Likes
Accepted solutions (1)
5,422 Views
27 Replies
Replies (27)
Message 21 of 28

braudpat
Mentor
Mentor

 

Hello

 

Please could you re-attach the lastest version of your Lisp routine ?

 

Thanks, Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 22 of 28

pbejse
Mentor
Mentor

@braudpat wrote:

 

Please could you re-attach the lastest version of your Lisp routine ?


Sure, but it doesn't include the script version yet.

 

So it still a draft [ Includes the mod for the recent issue ]

 

HTH

 

 

 

0 Likes
Message 23 of 28

braudpat
Mentor
Mentor

 

Hello

 

Current result is >>>

 

Commande: XREFUNDERLAY

Choose type [All/Dwg/dGn/dwF/PDF/Image] <All>:

Layout to process [Current/All] <All>:

Result on text/command screen [Text/File] <Text>:

============================================================
BlockReference ......................................1 Found
------------------------------------------------------------
ENTCADRE ...............................................XREF
============================================================

============================================================
RasterImage .........................................1 Found
------------------------------------------------------------
ENTFRANC ..............................................IMAGE
============================================================

============================================================
DwfReference ........................................1 Found
------------------------------------------------------------
CPE_BUSE ..................................................0
============================================================

============================================================
DgnReference ........................................1 Found
------------------------------------------------------------
DGN8_BIZOTS_CADA_2004 .....................................0
============================================================

============================================================
PdfReference ........................................1 Found
------------------------------------------------------------
EX1_2__A4_EN_PDF ..........................................0
============================================================

Commande:

 

Please for DWF, DGN , PDF could you display the Xref Type : DWF , DGN , PDF

Instead of : ....... 0

 

Thanks, Regards

 

PS1: please if ANY XREF (DWG, PDF, etc) is inserted N times, I wish N lines into the report ...

 

PS2: as I said BEFORE, 2 routines (Normal & Script) could be easier for you ! (No problem for me)

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 24 of 28

pbejse
Mentor
Mentor

@braudpat wrote:

  

Please for DWF, DGN , PDF could you display the Xref Type : DWF , DGN , PDF

Instead of : ....... 0

 

Thanks, Regards

 

PS1: please if ANY XREF (DWG, PDF, etc) is inserted N times, I wish N lines into the report ...

PS2: as I said BEFORE, 2 routines (Normal & Script) could be easier for you ! (No problem for me)

 


 

The 0 is referring to layer "0" [ the object's layer ] , now if it were on a layer named "DWF" then you will see that "DWF"

 

 

 

 

 

0 Likes
Message 25 of 28

braudpat
Mentor
Mentor
Hello

You are right ! I am stupid !!

Regards, Patrice
Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 26 of 28

Anonymous
Not applicable

Hi, Guys

 

Been using this code for a couple of months now and it has been a great help in checking the drawings of newbies to figure out what the heck they have done with the xref's when setting up a new projects by themselves and gone off script. We are only a small office so do not have rigid cad standards (trying to introduce as time allows) and I am struggling at the moment to train all the new guys on the ways of the Autocad, particularly with regards to land development projects and setting up xref’s.

 

To this end I have Dream 2.0 where I want to get a visual graph of how all the drawing files within a project folder are linked together. So you can see on one page and discuss how a project has been setup and explain what is wrong and how it should be corrected in relation to a company standard. I have been able to develop a basic graph as explained in this blog post.

 

http://c3dxtreme.blogspot.com/2018/10/mapping-project-xrefs-in-social-network.html

 

However I am missing a few additional pieces of information that I would really like to add to the graph as well.

  1. The name of the layouts in each drawing.
  2. The layer of the xrefs in each drawing and
  3. Possibility a thumbnail preview of the drawing.

 

To that end I have trawled net again and found various pieces of code that do parts of the job but really need assistance to string it all together into the one super routine.

 

To search all of the drawing files in one project folder at once I found the code mentioned in my blog post BatchFindXref.lsp that can be found here

 

http://forums.augi.com/showthread.php?152990-Listing-all-xrefs-attached-to-a-group-of-(unopened)-dra...

 

Into this code I would like to add functions that will include into the csv file it produces as additional columns of data the layer the xref is on and a string list of layout names.

 

Once included in the csv I can manually manipulate the data in the nodexl template to add to node labels etc.

 

To add the xref name I thought the functions of xrefunderlay could be added and for the layouts names in each drawing. I found this example code

 

http://forums.augi.com/showthread.php?70723-Export-Layout-Tab-Names

 

As for the thumbnails I found this code but do not know if it still works have tried with no luck or if nodexl will support the images for labels being nested in the excel file for icons. I found this code to get the dwg thumbnail drawing previews

 

http://www.theswamp.org/index.php?topic=33819.msg391791

 

So if you are able to suggest how to merge these bits of code together or help that would be greatly appreciated.

0 Likes
Message 27 of 28

ralstogj
Collaborator
Collaborator

Ok done a little more playing around with Nodexl and yes you can have a image at the vertice as the icon.

See attached image example of a project mapping with images of the drawings and below are the settings you have to use in nodexl. All I need to do now is get a copy of the preview thumbnail for each drawing saved into a folder and then add hyperlinks to them into nodexl. I see another potential way of getting the images here so will give it a try.

 

https://www.cadtutor.net/forum/topic/62416-lisp-dcl-thumbnail-preview-of-file/

 

 

nodexl_settings.png

Regards

 

Justin

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
Message 28 of 28

ralstogj
Collaborator
Collaborator

ok

 

I have managed to put in the lines of code below to add the layout names into the csv file

 

;;;Get a list of the the layout names in the drawing
(setq Alllayoutnames "")
(vlax-for x (vla-get-Layouts doc)


;;; add the layout name to a string
(setq Thislayoutname (vla-get-Name x))
;;; need to change separator to carriage return can not do for now just use | instead ""
(setq Alllayoutnames (strcat Alllayoutnames "|" Thislayoutname))

)

 

However am struggling to get the xref layer name again I am trying to use the line

(setq xrefLAYERNAME (vla-get-layer x))

but get and error. I am assuming x is an xref object that actually has a property for the layer.

 

I have attached the updated code with various attempts of trying to get the xref layer in commented out code blocks

If some one could troubleshoot and advise how to get the xref layer name into the csv file that would be appreciated.

 

Justin

 

 

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
0 Likes