help to update 2 useful LISP

help to update 2 useful LISP

jtm2020hyo
Collaborator Collaborator
2,150 Views
13 Replies
Message 1 of 14

help to update 2 useful LISP

jtm2020hyo
Collaborator
Collaborator

I found 2 useful LISP on this website: https://www.cadtutor.net/forum/topic/38563-exporting-multiple-blocks-in-one-dwg-to-having-them-as-in...

 

works perfectly, but I need to modify both like this:

 

Bimport:

I need this lisp to import all block inside a selected folder (or folder with a name written in the prompt command line) but without insert block, just IMPORT.

 

wb-all: 

I need to export all blocks to a selected folder (or folder with a name written in the prompt command line) but I add options like "export all", "export all expect xref", "export just xref".

 

 

 

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

jtm2020hyo
Collaborator
Collaborator

@jtm2020hyo wrote:

I found 2 useful LISP on this website: https://www.cadtutor.net/forum/topic/38563-exporting-multiple-blocks-in-one-dwg-to-having-them-as-in...

 

works perfectly, but I need to modify both like this:

 

Bimport:

I need this lisp to import all block inside a selected folder (or folder with a name written in the prompt command line) but without insert block, just IMPORT.

 

wb-all: 

I need to export all blocks to a selected folder (or folder with a name written in the prompt command line) but I add options like "export all", "export all expect xref", "export just xref".

 

 

 


another one I need for Bimport.LSP:

 

If block already exists inside the drawing, then lisp routine should update or replace such block(s).

0 Likes
Message 3 of 14

Moshe-A
Mentor
Mentor

@jtm2020hyo  hi,

 

Attached the revised files but did not test them.

 

Bimport:

I need this lisp to import all block inside a selected folder (or folder with a name written in the prompt command line) but without insert block, just IMPORT.

If block already exists inside the drawing, then lisp routine should update or replace such block(s).

yes done

 

wb-all: 

I need to export all blocks to a selected folder (or folder with a name written in the prompt command line) but I add options like "export all", "export all expect xref", "export just xref".

there is no need to export xrefs cause they are already external files, if you want to gather them in 1 folder, eTransmit the file and delete the host drawing.

to me it looks like the intention of the author was to wblock only blocks so the the fix i gave is to skip xrefs.

 

Note to run wb-all.lsp you need Dos Lib module for your AutoCAD version.

 

enjoy

moshe

 

 


 

Message 4 of 14

jtm2020hyo
Collaborator
Collaborator

"wb-all.lsp" works. but "BImport.lsp" does not work.

 

can change the way of a folder is selected to one like "wb-all.lsp"?

0 Likes
Message 5 of 14

Moshe-A
Mentor
Mentor

@jtm2020hyo 

 

sorry can not i do not have dos lib installed

 

0 Likes
Message 6 of 14

Kent1Cooper
Consultant
Consultant

@jtm2020hyo wrote:

....

Bimport:

I need this lisp to import all block inside a selected folder (or folder with a name written in the prompt command line) but without insert block, just IMPORT.

....

If block already exists inside the drawing, then lisp routine should update or replace such block(s).


 

Here's my take on that one -- BlockImport.lsp with its BIMP command [I already have a custom command named BI, but you can rename this one's command name to that].  Lightly tested.  See the comments at the top of the file.  It's modified from my own routine similar to their Bimport, called BlockChart, that Inserts one of each drawing in the folder into the current drawing [also attached if it's of any interest], with the Yes-to-redefine feature added.

Kent Cooper, AIA
0 Likes
Message 7 of 14

Sea-Haven
Mentor
Mentor

Have a look at www.lee-mac.com Steal.lsp you can drive it from a lisp may be useful also.

0 Likes
Message 8 of 14

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

Have a look at www.lee-mac.com Steal.lsp ....


 

[That's not what's needed -- it is to bring Block definitions (this thread's concern, but also other things) from within another drawing, not to import each drawing in a folder  as a Block definition, as requested.]

Kent Cooper, AIA
0 Likes
Message 9 of 14

jtm2020hyo
Collaborator
Collaborator

both lisp routines do not redefine block.

I need to update all block inside selected drawing to opened (current) drawing

0 Likes
Message 10 of 14

Kent1Cooper
Consultant
Consultant

@jtm2020hyo wrote:

both lisp routines do not redefine block.

I need to update all block inside selected drawing to opened (current) drawing


 

Could it be just a language difference?  This part:

 

    (if (wcmatch (getvar 'lastprompt) "*Redefine*")
      (command "_yes" nil); then -- answer to redefine, cancel before Inserting
      (command); else -- cancel before Inserting

 

is dependent on the wording of the prompt in which it asks whether you want to redefine the Block if there is already a Block definition by the same name in the current drawing.  In a different-language version of AutoCAD, that test would need to be changed, though the "_yes" answer [when appropriate] should not need to be.

Kent Cooper, AIA
0 Likes
Message 11 of 14

jtm2020hyo
Collaborator
Collaborator

@Kent1Cooper wrote:

@jtm2020hyo wrote:

both lisp routines do not redefine block.

I need to update all block inside selected drawing to opened (current) drawing


 

Could it be just a language difference?  This part:

 

    (if (wcmatch (getvar 'lastprompt) "*Redefine*")
      (command "_yes" nil); then -- answer to redefine, cancel before Inserting
      (command); else -- cancel before Inserting

 

is dependent on the wording of the prompt in which it asks whether you cant to redefine the Block if there is already a Block definition by the same name in the current drawing.  In a different-language version of AutoCAD, that test would need to be changed, though the "_yes" answer [when appropriate] should not need to be.


I'm using US-en version.

 

I need to redefine all (dynamic, regular, nested) blocks with the same name.

0 Likes
Message 12 of 14

Kent1Cooper
Consultant
Consultant

@jtm2020hyo wrote:

both lisp routines do not redefine block.
I need to update all block inside selected drawing to opened (current) drawing


 

Well, there's the problem.  Message 1 said "... all block inside a selected folder ...."  That's a very different animal, and my suggested routine does a folder-full of them, with the drawings in the folder becoming the definitions of Blocks in the current drawing.

 

I don't know how to pull a Block definition out of another drawing file using AutoLisp [though I would not claim that there's no way to do it], other than to Insert the whole drawing file that would bring its Block definitions along with it, but that would not redefine any whose names are already in the current drawing.  The Design Center can do it with the Redefine-only option, but it may only be possible one Block definition at a time.

Kent Cooper, AIA
0 Likes
Message 13 of 14

jtm2020hyo
Collaborator
Collaborator

@Kent1Cooper wrote:

@jtm2020hyo wrote:

both lisp routines do not redefine block.
I need to update all block inside selected drawing to opened (current) drawing


 

Well, there's the problem.  Message 1 said "... all block inside a selected folder ...."  That's a very different animal, and my suggested routine does a folder-full of them, with the drawings in the folder becoming the definitions of Blocks in the current drawing.

 

I don't know how to pull a Block definition out of another drawing file using AutoLisp [though I would not claim that there's no way to do it], other than to Insert the whole drawing file that would bring its Block definitions along with it, but that would not redefine any whose names are already in the current drawing.  The Design Center can do it with the Redefine-only option, but it may only be possible one Block definition at a time.


I just need a batch update (redefine) all my (dynamic, regular, nested) blocks. no matter if is since a folder or a drawing. 

...I will adapt my needs to whatever. 

0 Likes
Message 14 of 14

Kent1Cooper
Consultant
Consultant

@jtm2020hyo wrote:

@Kent1Cooper wrote:
....  Message 1 said "... all block inside a selected folder ...."  That's a very different animal, and my suggested routine does a folder-full of them....

I don't know how to pull a Block definition out of another drawing file using AutoLisp ....


I just need a batch update (redefine) all my (dynamic, regular, nested) blocks. no matter if is {from} a folder or a drawing.  ...I will adapt my needs to whatever. 


 

The problem is that it really does  matter, quite a lot, to the procedure involved, whether the definitions are coming from a folder or a drawing.  It's not too difficult if they're separate drawing files in a folder [that's what the BlockImport.lsp code in Message 6 is designed to do].  If it's true that you can adapt it for your needs, to get updated Block definitions out of a single drawing instead, then go for it.  My guess is that the way to do so, if the Design Center is too cumbersome, would be to first open up that drawing and use something like wb-all.lsp in Message 1 to WBLOCK all its Block definitions out to a new folder, and then  use something like BlockImport.lsp to pull those definitions from that new folder into another drawing.

Kent Cooper, AIA