Lisp for Creating a Support Drawings Table of Filenames and Descriptions

Lisp for Creating a Support Drawings Table of Filenames and Descriptions

Anonymous
Not applicable
2,095 Views
13 Replies
Message 1 of 14

Lisp for Creating a Support Drawings Table of Filenames and Descriptions

Anonymous
Not applicable

This should be straightforward for someone acquainted with Lisp (I work in VBA, not familiar with Lisp at all). What I need is a program to open each drawing in a directory as read only (visible = false) and grab the drawing number and desc1 and desc2 attribute from the title block. Then close the drawing and go onto the next drawing until all drawings have been processed. The program would extract the target directory from the currently active drawing. The program will skip opening the currently active drawing and getting the attributes above. As a last step, the program will list each drawing in a table column and its corresponding description (desc1 + desc2) in the next column.

 

See attached pictures for more clarity.

 

any help is always appreciated.


Also, all our drawings are done in .dwg format in this particular directory and all will have 7 character filenames - EX: "JS9D002". If the program could ignore any dwg that didn't meet these criteria that would be great.

0 Likes
2,096 Views
13 Replies
Replies (13)
Message 2 of 14

pbejse
Mentor
Mentor

@Anonymous wrote:

 .. What I need is a program to open each drawing in a directory as read only (visible = false) and grab the drawing number and desc1 and desc2 attribute from the title block. Then close the drawing and go onto the next drawing until all drawings have been processed....


Not really necessary the need to open a drawing file to extract attribute data.

 


@Anonymous wrote:

....  The program would extract the target directory from the currently active drawing. The program will skip opening the currently active drawing and getting the attributes above. As a last step, the program will list each drawing in a table column and its corresponding description (desc1 + desc2) in the next column....


Preferably , the currently active drawing where the program will run is the sheet where the "table" will eventually be populated.

 


@Anonymous wrote:

 

....any help is always appreciated.


Also, all our drawings are done in .dwg format in this particular directory and all will have 7 character filenames - EX: "JS9D002". If the program could ignore any dwg that didn't meet these criteria that would be great.


Have no fear, Help is here. Post a couple of sample drawings and show us what the project folder structure looks like.

 

 

0 Likes
Message 3 of 14

maratovich
Advisor
Advisor

Maybe it's possible, we need to test the file.
It is possible to do this if you open all the drawings at the same time.
This is called a Statement
How many drawings do you have?
Attach the sample file to dwg

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 4 of 14

DannyNL
Advisor
Advisor

Why not use the default data extraction in AutoCAD?

Seems to me it does almost everything you ask for.

0 Likes
Message 5 of 14

Anonymous
Not applicable

pbejse,

sorry for slow response, work has been crazy busy lately!

 

I have attached a sample layout showing the table to be generated. The number of drawings in this table could be 1 or 100, but between 1-10 drawings is normal.

 

You had said: "Preferably , the currently active drawing where the program will run is the sheet where the "table" will eventually be populated" --- that is correct

 

The folder structure is shown in my original post as a picture. Of course, the job number will vary constantly so it's best (I think) if the program can look at the currently active drawing to find its directory then proceed through that directory processing the drawings as described.

 

thanks once again!

0 Likes
Message 6 of 14

pbejse
Mentor
Mentor

I'm on it.

 


@Anonymous wrote:

 

...The folder structure is shown in my original post as a picture


I see there is a "layout" folder, I guess its safe to assume there are other sub-directories like "Details"? Are the SUPPORT DRAWINGS located in the same folder ? 

 

Would you want to have an option to select the support drawing file from a list? 

 

 

0 Likes
Message 7 of 14

pbejse
Mentor
Mentor

Try this:

 


Command: SDT

 

"T:\\Jobs\\Jobs JA-JZ\\JS9\\Layout\\JS9E002.dwg processed"
"T:\\Jobs\\Jobs JA-JZ\\JS9\\Layout\\JS9E003.dwg processed"
"T:\\Jobs\\Jobs JA-JZ\\JS9\\Layout\\JS9E004.dwg processed"
"T:\\Jobs\\Jobs JA-JZ\\JS9\\Layout\\JS9E005.dwg processed"
"T:\\Jobs\\Jobs JA-JZ\\JS9\\Layout\\JS9E006.dwg processed"

 

Pick point for Table:

 

Conditions

(= 7 (strlen filename))		; filename is 7 characters long
(wcmatch dwgName "@@#@###")	; Filename to match this format
				; @ = Matches any single alphabetic character
				; # = Matches any single numeric digit
supportDrawings			; Files under folder to match Folder prefix
tabledata			; valid files attribute block should have both
				;	DESC1 & DESC2 attribute tag
"BORDER-E"			; Runs exclusively with this title block
				;	we will add more block names later

HTH

0 Likes
Message 8 of 14

Anonymous
Not applicable

The program runs but the command line returns :"No Valid Attributes Found"....

 

The other border names are BORDER-D, BORDER-R, and BORDER-B.

 

You are correct in assuming that all the SUPPORT DRAWINGS will be located in the same folder as the main layout.

 

thanks again for your effort!!

0 Likes
Message 9 of 14

Anonymous
Not applicable

It looks like your code is not running correctly because the output you stated above that all the support drawings for job JS9 are E size. If you look at the picture again, you will notice that the support drawings could be B, D, E, or R size drawings (borders mentioned in my previous post).

0 Likes
Message 10 of 14

pbejse
Mentor
Mentor

@Anonymous wrote:

The program runs but the command line returns :"No Valid Attributes Found"....

 

 


Because you get the message "No Valid Attributes Found" It can be these two things , either the files borders is other than "BORDER-E" [ the block is not found ]or the block attributes TAG are not always DESC1 and DESC2 for the description.

 

Try the attached code [ with additional Border names ]

 

Message 11 of 14

Anonymous
Not applicable

One final request and I promise I'm done! Upon insertion of the table can it place it on layer "0, set the color to be cyan, and if that layer is not present in the current drawing to create it? This layer is in the sample drawing I submitted to you before.

 

The code is working beautifully! This final tweak will save us engineers so much time. Thanks once again!!

 

0 Likes
Message 12 of 14

pbejse
Mentor
Mentor

@Anonymous wrote:

One final request and I promise I'm done! Upon insertion of the table can it place it on layer "0, set the color to be cyan, and if that layer is not present in the current drawing to create it? 

 

 


See attached lisp file:. The bit you need to edit when you need to change the layer name on the attached file, Line number 91

 

 

..
(if (not (tblsearch "LAYER" (setq thislayer "BLK")))
..

 


@Anonymous wrote:

 ..... The code is working beautifully! This final tweak will save us engineers so much time. Thanks once again!!

 


 

I am pleased to hear that. You are welcome

 

pBe <--- p = Patrick

 

 

 

0 Likes
Message 13 of 14

Anonymous
Not applicable

Is this lisp release dependent? I'm using 2017 but the other engineers are on 2014....Tried showing it to my boss and got an internal "VLAX OR FUNCTION NOT DEFINED" error.

0 Likes
Message 14 of 14

pbejse
Mentor
Mentor

@Anonymous wrote:

Is this lisp release dependent? I'm using 2017 but the other engineers are on 2014....Tried showing it to my boss and got an internal "VLAX OR FUNCTION NOT DEFINED" error.


 

Sorry my bad 🙂

 

Add this line at the end of the file

 

            )
      (princ)
)
(vl-load-com)

0 Likes