DWG support for Blender

I have written a wrapper around the dxf scripts of Blender to implement dwg support. You can read more about it on my blog: http://pythonide.blogspot.com/2009/04/dwg-support-for-blender.html

I hope it might be useful for some of you.

hey that’s great :slight_smile: thank you very much
so now we don’t need any converter to dxf if I understand it correctly
gonna try it asap

many thanks, Stani.

Your idea of binding external DWG converter works great with DXF-Importer/Exporter, so i will get it in 2.49 release.
You can test updated scripts in 2.48 already, to get from here: Exporter and Importer

migius

Edit: The scripts use DConvertCon.exe - an older version of EveryDWG.exe converter from www.openDWG.org

Hi Migius,
Nice to see you back online!
If possible it is better to use the latest version which uses EveryDWG. The DconvertCon supports not the latest dwg formats and the files display an (unimportant) error message when opened.
You would only need to bundle my ar/lib/everydwg library with Blender.

interesting but

can you give general info on what is does
i mean does it read a DXF file an import into blender

and when talking about dxf are we talking about 2D dwg or 3D drawings here?

is there anything that can read the latest files from Atuocad or may be other soft ?

Thanks

Hi Stani, hi Migius,

I have some problems with the import scripts.
With EveryDWG I get this error:

DXF-Importer v1.12 - 2009.03.14 by migius *** start ***
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Programme\Blender\248a_SSE3\.blender\scripts\import_everydwg.py", line 65, in <module>
    def import_ui(file_dwg, version=acad_version()):
  File "C:\Programme\Blender\248a_SSE3\.blender\scripts\import_everydwg.py", line 59, in acad_version
    rdict   = Registry.Get(key, True)
AttributeError: 'module' object has no attribute 'Get'

I have installed all installers (bazaar, ipython, pyreadline, pil and psyco) from the installation instructions.

And the Version with DConvertCon.exe doesn’t understand the DWG (ACAD 10. I think)

Tested both versions with 2.48a and 2.49 (both found python v2.5)
Any ideas?

DConvertCon.exe should work for DWG r10 - supported acad versions: 2.5 | 2.6 | 9 | 10 | 11 | 13 | 14 | 15
Try to convert your drawing to DXFr12 in dos-console-mode:

DConvertcon your_drawing.dwg -acad12 -dxf

then manually import dxf file with dxf-importer

Thank you Migius.
But it’s not working with DConvertCon. Maybe I have downloaded an old DConvertCon.exe.

Error: Invalid version - ‘-acad12’!
Processing 090505_at_E_GP5b_1_1_OG.dwg to 090505_at_E_GP5b_1_1_OG.dxf.
Error: Failed to load input file - ‘090505_at_E_GP5b_1_1_OG.dwg’!
I’ll follow your idea with converting to DXF R12. I have now downloaded the latest EveryDWG from opendwg.org. Now I can convert the files an import them to blender. :slight_smile:
I get only 80% of the data, some lines are not there and all text is missing. And maybe 5-10% of the lines are in wrong position.
I have downloaded the freeDWG viewer, too. There I can see, that all lines are in there and in correct position.

EDIT:
I can only import the new DXF files with the classic “DXF import” in Blender.
If I use your importer “import_dxf.py”, than I get errors:

DXF/DWG-Importer v1.12 - 2009.05.27 by migius *** start ***
reading file: d:\Projekte_lokal\GBW\Vorlagen\DWG_05_05_09\DXF_R12\090505_at_E_GP
5b_1_1_OG.dxf.
reading finished in 0.6820 sec.
found table:vport
found table:view
Traceback (most recent call last):
File “C:\Programme\Blender\249_py25_official.blender\scripts\import_dxf.py”,
line 6114, in bevent
main(dxfFile)
File “C:\Programme\Blender\249_py25_official.blender\scripts\import_dxf.py”,
line 4374, in main
settings.validate(drawing)
File “C:\Programme\Blender\249_py25_official.blender\scripts\import_dxf.py”,
line 4029, in validate
blocksmap, obj_number = getBlocksmap(drawing, layersmap, self.var[‘layFrozen
_on’])
File “C:\Programme\Blender\249_py25_official.blender\scripts\import_dxf.py”,
line 4539, in getBlocksmap
usedblocks[child[0]][0] = True # marked as used BLOCK
KeyError: ‘*X336’

errors? then let me look at that dxf file.
It seems to be an dxf-importer issue - please write a report to: http://blenderartists.org/forum/showthread.php?t=84319