Open a file from folder, explode, wblock with same name in a new folder

Open a file from folder, explode, wblock with same name in a new folder

hari.lallGSCRP
Enthusiast Enthusiast
914 Views
10 Replies
Message 1 of 11

Open a file from folder, explode, wblock with same name in a new folder

hari.lallGSCRP
Enthusiast
Enthusiast

Folks,

 

I have about 500 dwgs, that were created using a non Autodesk software and required cleaning. All I want to do is Open a drawing from a specific folder, explode, wblock and save as a new drawing with same name in a New folder. Is this something that can be achieved using VBA or Macro?

 

Macros and scripts is something I have no notion about but I can manage few easy ones. This is to be used with AutoCAD 2020 and I do have VBA enabled plus a ScriptPro installed. Any help will be much appreciated. Thanks.  

0 Likes
915 Views
10 Replies
Replies (10)
Message 2 of 11

pendean
Community Legend
Community Legend
The dedicated VBA forum is over here if that is all you wish to use https://forums.autodesk.com/t5/vba/bd-p/33

Do you want your post moved there?

Message 3 of 11

Kent1Cooper
Consultant
Consultant

Since you're talking about new files with the same names, it might be easier to just copy all the drawing files into the new folder, after which all you need to do in each one in the new folder is open it, EXPLODE, QSAVE and CLOSE -- no designation of folder path and location or pulling of current-drawing name as you would need to do in WBLOCK .  [And maybe PURGE?]  A simple Script invoked via ScriptPro should be able to do that.

Kent Cooper, AIA
Message 4 of 11

hari.lallGSCRP
Enthusiast
Enthusiast
I am actually not sure what to use to achieve this task. If you think it might be more appropriate in the other forum please do move it or may put one in there too.
0 Likes
Message 5 of 11

hari.lallGSCRP
Enthusiast
Enthusiast
That won't work, as the AutoCAD will see the file as coming from external source again and not a native file, plus I have tried it and somehow the attribute information for blocks within the file remains even after cleaning purging everything. hence the best solution is Wblock the contents and save it as a new file.
0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@hari.lallGSCRP wrote:
.... the attribute information for blocks within the file remains even after cleaning purging everything. hence the best solution is Wblock the contents and save it as a new file.

Does the attribute information not also remain when you use your Wblock approach?

Kent Cooper, AIA
Message 7 of 11

hari.lallGSCRP
Enthusiast
Enthusiast

No, once the contents are all exploded it all gets delinked but some how stays in the file. I tried every single way possible and no matter what I do the files are just not good after cleaning, some residue is always left behind.

 

So the best option at the moment is to just open file explode everything and then wblock it out and save with the same name. This way the file sizes are almost half the original file size and everything works perfectly. The problem is that I have so many files to deal with and this is going to be repetitive process every year.  

0 Likes
Message 8 of 11

pendean
Community Legend
Community Legend
@hari.lallGSCRP Can you share one or more of those DWG files here?
Message 9 of 11

stev98312
Enthusiast
Enthusiast

You might be able to make a script from these instructions.

https://www.landfx.com/docs/admin/drawing-setup/item/6184-clean-export.html#manual

 

Steve

Message 10 of 11

hari.lallGSCRP
Enthusiast
Enthusiast

Unfortunately, I can't, all drawings are copyright protected and under a licence from government agency. Anyway cleaning is just out of question at this stage. I just need a way to automate the task as I have described.

 

To give you some more insights into the real issue. The government agency has recently changed their system to produce the base maps. The new maps we are getting are more inclined toward GIS systems than AutoCAD. Every single entity is a closed polygon/region (as a block) in the base map, and every single block has attributes attached to it. They use a GIS database system and then run it through FME to produce CAD base maps for the whole country. Some genius decided its better to have closed polygons as regions so it can be better utilised in the likes of Civil 3D or Map3D, however this just make regular AutoCAD go nuts, specially when you have insert couple of base maps in one drawing. 

0 Likes
Message 11 of 11

hari.lallGSCRP
Enthusiast
Enthusiast

I have not accepted any solution to this so please don't just mark your own answer as a solution, when all you have done is ask me a another question.

0 Likes