Exchange Forum > AutoCAD General
Challenge(?) converting DWG
Challenge(?) converting DWG

#1

fredpox
Join Date:
04-05-2008
Hi there,
I'm new to this forum, and to AUTOLISP/VLISP as well so please be nice.
 
I work in a firm in which we do lots of buildings drawings with the aid of an add-in to Autocad. This app is linked to an Access database and has some nice UI to add dynamic blocks in order to create the main structure in 3D as well. Same bases for each drawing, different interior design depending on request.
 
The point is we have to show customers our projects in dwg files (please don't ask why) and to do this (and obviously to prevent from further manipulation of the drawing itself) we use to convert files in order to 'explode' the content.
 
Actually the procedure is exporting in PDF, convert in DXF and resave in DWG.
You might easily understand that this is very time consuming if many drawings are to be sent...
 
SO..I googled the Net for any other conversion tool which might do the 'trick' a little better but..I didn't come up with a really good option.
 
Then I asked myself, 'what if I'd flatten the drawing, remove all unwanted content, explode all entities and text, and resave the file'?
 
Actually, I was wondering if all this would be possible via AUTOLISP/VISUALLISP...
 
Here are the steps I need:
 
1: select all visible elements and -> change to layer 0
2: change color to white (for all the objects in the drawing)
3: delete all the thawed content
4: purge
5: explode all entities
6: explode text
7: save to a new dwg file
 
and...am I asking the Moon?
I did find in your 'favorites' post some nice stuff, such as changing to current layer and similar but I can't come up with such a complex app by myself
 
If you could send me to some good manual which lists all the methods and properties I'd appreciate that as well.
 
Thanks in advance
 
PP
Challenge(?) converting DWG

#2

Bennett
Join Date:
07-26-2007
Play around with the WMFOUT and WMFIN commands and see if this is anything like what you are looking for. You can explode the *.wmf block and change all the entities to layer 0 after you bring it in. If this works like you need to, the process can be automated using a small AutoLISP program that will work very fast.
Challenge(?) converting DWG

#3

fredpox
Join Date:
04-05-2008
Hi Bennett
Thank you for your reply and your concern.
Now I am at home and I'll try as you told me to follow your advices.
Anyway, I just tried WMFOUT and WMFIN commands and then exploded and I did find this:
 
Assume that I have a plan view and I have a preset which show me only the layers I want to see (the ones I need to work with and the clients want to see).
 
* WMFOUT -> select elements
* WMFIN -> place, Xscale (don't know why the drawing is scaled down 1:2), Yscale (same as above, gotta choose 2 to restore the original scale), Rotate 0
* Explode entities (read wmf block)
* RE-Explode entities (I tried step 3 on solids and I did find that still maintains some lines as polylines, then repeating it everything is fine)
* Change entities color to white
* Change entities to layer 0
* Delete all the unwanted content/layers extra wmfOf course, I exported my drawing from within the drawing itself and I placed it once again inside it. If I did create another file perhaps it wouldn't have required steps 6 and 7. And thus this might be even more suitable for my needs. Am I right?
 
I apologize for my English and for my poor knowledge of what Autolisp is capable of, and how much I can 'dare'.
 
I'll let you know if WMF is useful for my job too, as soon as I'll have my hands on some drawings next morning.
 
Thanks again and regards.
 
Paolo
Challenge(?) converting DWG

#4

Bennett
Join Date:
07-26-2007
Paolo,
Yes, the WMF is stored as half scale. But that shouldn't be a problem. We'll just insert it with a scale of 2.
 
Are the drawings that you're working with on the Model tab only, or are they using the Mspace/Pspace method?
Challenge(?) converting DWG

#5

fredpox
Join Date:
04-05-2008
Quote:
Paolo, 
Yes, the WMF is stored as half scale. But that shouldn't be a problem. We'll just insert it with a scale of 2. 
  
Are the drawings that you're working with on the Model tab only, or are they using the Mspace/Pspace method?
 
Hi Bennett,
my drawings are placed in Paper Space, with the proper "stamp" and so on.
I just tried the WMF commands and I did find that in Mspace it works great, but in Paper Space it requires me to export multiple WMF for each viewport...and then re-assembly...
 
any other advice?
 
thanks again!
 
Paolo
Challenge(?) converting DWG

#6

Zeanor
Join Date:
07-26-2007
Bennett,
You will have to do something with CHSPACE. The dimensions may have to be exploded first in order for this to work correctly.
Challenge(?) converting DWG

#7

Bennett
Join Date:
07-26-2007
Zeanor,
The CHSPACE only seems to work well under user control, so I had to improvise a little.
 
Paolo,
Here is a test version that you can run on one drawing to see if this is what you are looking for. You might have to adjust the ltscale settings.

Attachments  DwgConvert.lsp  
Challenge(?) converting DWG

#8

Zeanor
Join Date:
07-26-2007
The wblocks are coming in with the INSBASE set to the upper left corner. You might want to change this to 0,0.
Challenge(?) converting DWG

#9

Bennett
Join Date:
07-26-2007
You're right! I fixed that and looked into the LtScale ratio. Here's the new version.

Attachments  DwgConvert.lsp  
Challenge(?) converting DWG

#10

fredpox
Join Date:
04-05-2008
Hi guys and thanks a lot for your quick replies.
 
Bennett, I tested your lisp file on my ACAD 2008 and I did find that it works great for me in plan mode!
Unfortunately if I have multiple viewports (very often) with different views all the other ones are changed to plan (Top view)
 
Is this lisp file compatible even with 'old' autocad versions? I mean, 2004 release. Since that is the version with which we work at the very moment.
We plan an upgrade (hope soon...)
 
Thanks again for your concern in this matter.
 
Paolo