DXF Importer

RELEASE 0.8.3

https://bitbucket.org/treyerl/io_import_scene_dxf/downloads

I think it’s a good one :wink: But in case you should still encounter a bug, report it here or in the bitbucket’s issue tracker.

Nice :slight_smile: An option to center the data would be nice, the file I tried has horrible precision issue because it’s many thousand km away from origin.

The option is available. Turn on ‘import to new scene’ at the bottom. Then ‘re-center geometry’ will be available. Also read the release notes on the bitbucket page for more details.

Hey Matali,

I made the center option now available too for imports that don’t have a new scene created. There is no zip download for that yet, but you can check out the repo if you would like to test it. I also fixed a small bug in the code that does the centering.
The offset is stored as a custom property to the scene, but there is no possibility to find out lat / lon, since DXF does not store any information about the projection that was used to get the x,y,z coordinates in the DXF file - if they were projected at all. So if YOU as the user know this projection then you can transform the x,y,z offset to lat/lon/altitude, for instance with pyproj which I mentioned earlier. Maybe I could include such a projection feature in the next release, but you would need to install pyproj separately. Until then I hope you can live with the center option as it is for now.

Cool, thanks a lot :slight_smile: Now I understand why you can’t convert to lat/long. So maybe we could proceed the other way round, let the SHP, HGT and OSM importers also save offsets custom properties in x,y,z values to enable compatibility. Will speak to them.

Great, thanks a lot, it’s that i am waiting for.

Your plugin works perfectly on all data I tested. However, with the latest testbuild 2 for 2.71, it gives an error about a bad magic number…

Edit: only happen on windows 7, linux is ok.

Edit 2: On the file I’m working with, it seems that every vertex/curve point has 9 or 6 duplicates. So I have to convert the curves to mesh, then run “remove doubles” then convert back to curves and activate 2D in curve panel to fill them. Importing from Accutrans doesn’t give those duplicates.

Are you waiting for geo-referencing?

Hello everyone I was just made aware of this DXF importer by Ton on today’s developer meeting notes, and being an architect who as been lacking a decent DXF importer for Blender since the 2.5 series I plunged in right away to give it a try.

So I downloaded 0.8.3 and made a very simple file with a few polylines with Draftsightjust to give it a quick test, but got this error on import in Blender 2.70 64bits 51fa66b on Windows 7 64Bits:

Traceback (most recent call last):
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf_init_.py”, line 203, in execute
self.do_bbox, block_map[self.block_options], scene, self.recenter)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf_init_.py”, line 45, in read
errors = do.entities(os.path.basename(filename).replace(".dxf", “”), new_scene)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1278, in entities
self.combined_objects((en for en in self.dwg.modelspace() if is_.combined_entity(en)), scene)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1219, in combined_objects
o = self._call_object_types(TYPE, by_att, group, name, scene, False)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1133, in _call_object_types
o = self.object_curve(entities, scene, name)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1058, in object_curve
typefunc(en, d)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 296, in spline
self._cubic_bezier(convert.bspline_to_cubic(self, en, curve, self.errors), curve, en.is_closed)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 82, in _cubic_bezier
self._cubic_bezier_closed(points, curve)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 51, in _cubic_bezier_closed
b[i].handle_left = Vector(points[j-1])
IndexError: bpy_prop_collection[index]: index 2 out of range, size 2

location: <unknown location>:-1

Anyway from you description this looks like a very competent DXF importer, keep up the great work, hope it makes it to official builds

hey dphantom. thank you for trying it out. looks like you are trying to import a spline. could you post the testfile for me please? thank you.

EDIT: generally the knot insertion algorithm is quite incomplete which is why you might encounter some problems with splines. My tests with Vectorworks all were pretty ok so far, but it’s good to know that I probably tested some lucky cases. I tried it with draftsight too, and got some weird results too but no error so far.

That is correct I did make a few splines in there just to test several different objects, didn’t know this wasn’t supported.
Not a problem for me at least, I rarely use splines anyway, tried it without them and it seems to be working fine now.

I didn’t even save the original file since it was just a quick test but here is a recreation of it that produces the same error
https://drive.google.com/file/d/0B1Ngi12r9AUNblVBUmg3LURIUHM/edit?usp=sharing

Thanks a lot for this, I can now finally let my old 2.49 Blender install die in piece, I kept it arround for years just for the single purpose of importing DXF files since the original plugin was quite good.

Thank you for the file. I could provide a quick fix which should prevent the importer from crashing but the imported geometry isn’t satisfying yet… hope to be able to improve that with the next release.

Thanks for the quick reply and the fix. Looking forward to future versions

Hi,
I just found out about this addon from Ton’s develper meeting notes. Tried one of my files (plan of a building). It works great. I would have to clean that file a lot before being able to import it with the internal dxf-importer.
As mentined above, splines were not imported correctly, but that’s a tiny problem compared to problems with internal dxf importer.
Thank you vey much.

Hey dphantom!

I got the knot insertion working! Try it out: io_import_dxf_0.8.4_BETA.zip
For those of you interested in a proper DXF importer: this strange thing called knot insertion is the heart of many spline operations, and if it is able to handle your test-files this could be quite a step towards a DXF importer that feels professional. So try it with your fancy spline files please! :wink:

Hi semhustej,

Thank you for reporting on your tests. Saw your post only now. I hope I could fix the problems with the splines in the latest (beta) version.

Hey CND thanks for the quick development.
I gave a try to your new 0.8.4, but unfortunately it still gives the error

Traceback (most recent call last):
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf_init_.py”, line 203, in execute
self.do_bbox, block_map[self.block_options], scene, self.recenter)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf_init_.py”, line 45, in read
errors = do.entities(os.path.basename(filename).replace(".dxf", “”), new_scene)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1278, in entities
self.objects_before += scene.objects[:]
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1219, in combined_objects
att += “extrusion” + str([str(round(c, 1)) + “…” + str©[-1:] for c in extrusion]) + ", "
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1141, in _call_object_types
else:
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 1058, in object_curve
continue
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 296, in spline
curve.dimensions = “3D”
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 82, in _cubic_bezier
self._cubic_bezier_closed(points, curve)
File “D:\Duarte\System\Blender\2.70\scripts\addons\io_import_dxf\dxfimport\do.py”, line 51, in _cubic_bezier_closed
b[i].handle_left = Vector(points[j-1])
IndexError: bpy_prop_collection[index]: index 2 out of range, size 2

location: <unknown location>:-1

The addon in user preferences still reads 0.8.3 even after uninstalling old version and replacing with the new download, is that normal or did you by any chance post the wrong file?

it’s not a release yet, because I want to put in the georeferencing stuff too. Was just happy that I finally had knot insertion working, and I assume that’s the part that needs testing. I tested with the file I had from you. I’ll give it a try on windows then and get back to you. What’s your timezone btw? Lisbon night time or GMT-x?

EDIT: So, I could reproduce the problem. That made me downloading the source files and not only the zipped addon, so I could look for the error. When I did so another error was displayed, that said there are duplicate addons, so I deleted the old importer from C:\Program Files\Blender Foundation\Blender\2.70\scripts\addons and it worked. So I tried to reproduce the problem once again: I deleted the addon source files (basically the same as the addon but with some testing lines) tried to put back the old addon but could not find it. So I reinstalled Blender and then my addon (the zip file from my download section) and it worked. No error anymore. So there might be an issue with the my addon having the same name as the old addon that ships with Blender. Deleting the addon that ships with Blender should solve the problem for the time being. If not, reinstalling Blender might do…

I use Blender has a “portable app” not really installed on system, but tried it on a fresh unpacking and it worked fine. Tried again on my main Blender “installation” after restarting between scripts install and uninstall and it solved the problem too.

Quick test file with a few random splines imported flawlessly to bezier curves with handles. Thats was really quick, great work!

My timezone is GMT+1 (Lisbon/London) time, it’s almost 1am here: time to play with blender and a few games before bedtime :wink:


Nice little architectural plan imported with your script, and quickly extruded. Works very well