DWG/DXF-exporter - release (2.49)

hi, thank you for your feedback. Just curious, how long took it with 65 mb blend model?

I’ll try the “flat” option and see how that works. That will be very helpful if for architectural models, so for a view (like orthographic view of a facade) to be exported as 2D, then tweaked and finally be part of construction documents. Thanks for your work!

Unfortunately “3D-View to Flat” cant remove hidden geometry automatic yet. I will try to implement such routine if many people interest.
Note: there is a similar functionality in pantograph plug-in

I exported as 3D-view to flat, yes it is not removing the hidden lines. i opened the file in SolidEdge 2D and yes, lines are overlapped. if you would implement that functionality, then is going to be a HIT!!! really nice work.

I haven’t tried pantograph, I downloaded a while ago, but did not have the time to jump in.

I haven’t tried pantograph till now, only read reports on his site. There are some problems with installation on win, and it is not bugs free. It seams, the author has no much time for further developing (has full time job yet).
Yesterday i’ve been looking through his code, and I think I could try to implement some of your code in the exporter, because of limitation in DXF-format it could never be so good as SVG output.

I will put it on my todo-list, eventually as part of upcoming blender foundation open project (architecture visualization).

Other way to speed up the developing is direct sponsoring/donating the developer (this case its me :)). If you interested to have enhancement in this exporter for better match your commercial purposes, don’t hesitance to contact me.

migius

Hey Migius, you will continue to use sdxf, right? I’m using it too for freecad, I think we could make a couple of enhancements to it that would serve all projects (exporting correct polylines, etc)… Unfortunately I don’t have all your knowledge of the dxf format, so I’m struggling a bit with all the versions stuff, but I might be able to put some new things. For example I’m putting now a convertor that takes rgb color and converts to autocad color.
The bore is that you must test your dxf files in a lot of applications to make sure it is well written… it is crazy how that format is implemented differently by each app…

Bad news: sdxf library supports only DXF-r9, an archaic specification. The most popular DXF version is r12.
Good news: sdxf code can be easily rewritten to r12 :slight_smile:
Bad news: there are many other official versions beside r12 and each needs something different service.
Good news: we have Python on board :slight_smile:

Unfortunately I don’t have all your knowledge of the dxf format, so I’m struggling a bit with all the versions stuff, but I might be able to put some new things. For example I’m putting now a convertor that takes rgb color and converts to autocad color.
Have you reverted the dxfColorMap.py from blender scripts folder?

The bore is that you must test your dxf files in a lot of applications to make sure it is well written… it is crazy how that format is implemented differently by each app…
Thats right, too many different implementations.
But i dont care about it - i do compare only with DXF specification. I don’t know more rigorous importer than autocad built-in one. The best test is the import->export loop through autocad.

FreeCAD is cool, keep it on, easy to share code with blender (both GPL)

I found a table of rgb values of all autocad color index, and I made a simple function to map rgb values to the closest ACI color. Now you can create entities giving an int or a (r,g,b) tuple for the color… The updated sdxf.py (v1.1.1) is here:
http://yorik.orgfree.com/scripts/sdxf.py
Would be cool to upgrade it a bit, though. I’ll dig more into the dxf reference…

Thank you for update sdxf, although with dxfColorMap.py i meant, there is such color converting table already in blender. It was done by Kitsu for his first release of DXF-Importer (probably based on some code from Stani). I’d suggest to leave this dictionary as extern module cause it is used by both scripts: importer and exporter.

The current DXF support in blender has some annoying limitations at big models: dramatic performance decrease and memory limits due to data virtualisation. I am preparing a paper for the conference about this issues and will present ideas to make things working better.

Yorik, I hope to meet you on the conference.

Oh ho, I hadn’t looked at the dxfColorMap… I’ll try to use it as you suggest, you’re right, it would be much better. Too bad I won’t be able go to the conference :frowning: good luck with your paper, though! It looks super interesting. You know I used the importdxf modules that Kitsu and you coded for importing dxf in freecad? I find that very cool, “generic” piece of code being used in several projects… This is something that could be carried on much further one of these days…
Okay, I’ll adapt the sdxf to use dxfColorMap then.
Cheers
Yorik

I did some tests using the “view to flat” option and the exported dxf files show perfectly in Qcad. Great work! :slight_smile:

Consider me interested!

Do you expect that this script and Yorik’s section script will eventually merge, so that sections with projections and hidden lines will become possible?

Actually maybe the best would be a separated script? So 1) you extract the sections, 2) you extract the views and 3) you export? Alxarch was also interested in coding such a “hidden-line” view generator…

Yes, these functions should be separated in individual extern modules, although it needs proper accessibility concept, so the >direct< export of profiles/flat views stays as option. Direct export has a few essential advantages for jobs with geometry-reach scenes!
At first I will separate r12-updated sdxf code form exporter script due its usability in feecad.

something curious: i was working on your 2d-profile script to make it working with any-oriented/parented objects and with optional polygon-curves output. Just finished it and found the version from Alxarch on your site - almost the same approach!
My version writes the output to >one< mesh-object (optionally a curve-object) positioned and scaled according cutting-object. The idea was: to become ready-for-export >well scaled< flat panel with desired section view. After reseting its transform-matrix it will automatic move to (0,0,0).

hi Migius,

working out of the box ! ( file open with Progecad )

but… the result can’t be imported by your import script :slight_smile:


DXF-Importer  *** start ***

Standard Mode: active
reading file: /home/milovann/Bureau/parlange02.dxf.
reading finished in 1.6333 sec.
found table:view
deb:getBlocksmap:  layersmap= {'PYDXF': Layer: name - PYDXF, color - 7}
Traceback (most recent call last):
  File "&lt;string&gt;", line 5842, in bevent
  File "&lt;string&gt;", line 4221, in main
  File "&lt;string&gt;", line 4418, in drawEntities
  File "&lt;string&gt;", line 4461, in drawer
KeyError: '0'

here is the file : http://www.yanatchkov.com/parlange01.dxf.zip

hi karpov, probably you are using an older importer version. The current version had no problems with this DXF file:

DXF-Importer v1.12 - 2008.08.03 by migius *** start ***

Standard Mode: active
reading file: D:\..\_bugreport081005\parlange01.dxf.
reading finished in 4.7721 sec.
found table:view
  1 objects imported from model space in 295.3463 sec.  -----DONE-----
DXF-Importer  *** exit ***

you’re too fast :wink:

sorry.

export_dxf.py update v.1.27beta 2008.10.07

  • exclude Stani’s DXF-Library to extern module dxfLibrary.py
  • add “Hidden-Mode” substitut: back-faces removal
  • add support for mesh ->POLYFACE
  • optimized code for “Flat” procedure

hi Yorik,
Stani’s sdxf.py is now /bpymodules/dxfLibrary.py :slight_smile:
update v1.27 - 2008.10.07

  • beautifying output code: keys whitespace prefix
  • refactoring DXF-strings format: NewLine moved to the end of
  • modif POLYLINE to support POLYFACE

Perfect work, as always Migius! I’m adapting the freecad dxf export script to use your revamped dxfLibrary… Thanks a lot for that!

All credits for you: your (working!) profile-exporter was the only reason for me to start working on DXF-exporter. It was the first time i saw practical usage for DXF export at all. Thanks!

Support for materials->colors is planed for the next update. Have you implemented it in sdxf already?

Hi migius,
I got the following error while using the script, same error for several blend files:
File “/home/yorik/.blender/scripts/export_dxf.py”, line 221, in exportMesh
points = [ me_verts[key].co[:3] for key in e.key]
IndexError: list index out of range

in fact, me_verts is an empty array in all tests I did, but the key has always more than one value, for ex: e = [MEdge (1 0) 0 0], me_verts = [], e.key = (0, 1)

for material colors i did it in the export script itself (used dxfColorMap), so the dxfLibrary stays independent of other files… seemed better to me, what do you think?

Ah, the freecad dxf export script is now working fine, thanks to your lib! Good work at upgrading all this, specially the polyline stuff!

how is it possible: mesh with edges/faces but with no vertices?
Could you send me an example blend file?

for material colors i did it in the export script itself (used dxfColorMap), so the dxfLibrary stays independent of other files… seemed better to me, what do you think?
it is ok for me.

It does like that with any shape… Check this one for example:
http://yorik.orgfree.com/archive/test-shapes.blend
It looks to me that the problem is at line 156… me.verts is a MVertSeq, and me_verts is an empty array…
I tried changing that line for this:

me_verts=[]
for v in me.verts: me_verts.append(v)

and it works… Maybe that MVertSeq type cannot be copied to a list? The strange thing is that it worked for you and not for me?? I used a svn version compiled today, and standard python that comes with ubuntu… Would it be different than yours?