electrical Legend automatic population lisp?

electrical Legend automatic population lisp?

Anonymous
Not applicable
1,334 Views
8 Replies
Message 1 of 9

electrical Legend automatic population lisp?

Anonymous
Not applicable

Hello All,

I am attempting to figure out a way (possibly a lisp?) so that whenever I insert a block into a dwg, the same block is placed onto a separate drawing, so I can generate an Electrical Symbols Legend after I am done with all of the drafting. AutoCAD already itemizes every block in a project so this idea seems possible but as of yet Google has not been helpful.

 

Thanks,

 

0 Likes
1,335 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

That doesn't sound very likely exactly as described, because an AutoLisp function can't start in one drawing and continue in another.  But consider another approach such as a text file.  It should be possible to make a routine, dedicated to only the Blocks that would go into such a legend, that would check for a Block-listing text file name, if it doesn't exist make it, and write the Block name used as a line in that file.  That could be done from any number of different drawings, as long as you don't have more than one User wanting to have it open to write to it at the same time.  Then when you're all done [assuming you used only that routine to Insert such Blocks], another routine could open that file, go through the lines containing the Block names, and for each one it hasn't Inserted yet, put one in, with some kind of positional relationship to the last one, such as below it by a defined distance.

Kent Cooper, AIA
0 Likes
Message 3 of 9

Anonymous
Not applicable

Thank you very much for the quick response. I will re-read your response and attempt to implement.

0 Likes
Message 4 of 9

dgorsman
Consultant
Consultant

That's a lot of work, considering that most of the time the legend sheets would look the same.  Fill out a standard legend sheet (or sheets) with *all* of the standard symbols (leave some space for extras), then add a copy of it to every project.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 5 of 9

Anonymous
Not applicable

Thank you for your reply. I took your idea and what I ended up doing was using the"eattext" command to generate a list of all the blocks inserted into a dwg(s). that info can be exported to a table or into excel. My question now is, is there a way to take that xlsx sheet and have a route insert the blocks listed into a different sheet?

0 Likes
Message 6 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... is there a way to take that xlsx sheet and have a route insert the blocks listed into a different sheet?


Yes.  Exactly how may depend on the format of that .xlsx file, but if you post a simple one, people can experiment.  I haven't used them with AutoCAD, and wonder whether maybe a .csv file would be better -- I'm not sure how many file types AutoLisp's (open) and (read-line) functions can work with, but others here can probably answer that easily.

 

If this is the only purpose for that file, I would recommend a plain old .txt file, with each Block name on a line, if extracted data can be sent to something like that.  That would be quite simple to use to bring them in.

Kent Cooper, AIA
0 Likes
Message 7 of 9

Anonymous
Not applicable

So with the Eattext Command I chose to export the names of the blocks into a .txt file. I have looked on the internet but I have not yet read how to use these names to insert the blocks associated with the name. 

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant

It would be a little more straightforward if it could write them out [in addition to or instead of, as appropriate] a .txt file with only the Block names, not also the drawing file names they come from.  But if that's impractical, the format you have can be used -- a routine would have to lop off everything starting with the tab \t character from each line as it goes.

 

But a question:  You have some Blocks that came from being nested in Xrefs [the ones with $0$ in their names] that have the same names except for the source drawing part, such as many of those with names starting with ES.  Are those the same, or should they be dealt with separately?

 

Putting them in would involve an (open) function to get into the .txt file, and a series of (read-line) functions to pull the text of each line, and use of the first part of each line [or all of it, if you make a file with only the names] in Insert commands or (entmake) functions.  Those would have to increment the insertion points.  Are these things of similar-enough size that one increment-spacing size would space them all appropriately?  If not, it could be done by reading each one's bounding box to determine how far to move to put in the next one, but then there's the question of whether their insertion points are in similar positions [all in the middle of Blocks, or some in corners, etc.] -- could get complicated.  I think I may have something that deals with that kind of situation, if I can find itEDIT:  It's >>here<<.  It does it with all drawings in a folder, but could be adjusted easily enough to use a file like yours instead, assuming the Blocks themselves are all in some place it will be able to find [in the Support File Search Path list].

Kent Cooper, AIA
0 Likes
Message 9 of 9

Anonymous
Not applicable

The nested blocks are not the ones I care about. I am just trying to get the blocks in the drawing. Yes there is a centralized folder that contains all of the blocks. I tested the routine that you sent the link for, Something like that could be useful if I was able to run it on a series of drawings.

0 Likes