Problems importing DXF with OpenSCAD

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
chennes
Veteran
Posts: 3877
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Problems importing DXF with OpenSCAD

Post by chennes »

I've had to make some additional changes to the fix code, which still didn't result in a successful import. Once I get the import, I'm still getting an error in the openSCAD importer:

Code: Select all

22:50:20  successfully imported /var/folders/v4/gg68t8g97r77jw78dz117ts00000gn/T/../../../../../../Users/chennes/Downloads/testbend_files/testbend_R12.dxf
22:50:20  Traceback (most recent call last):
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/OpenSCADCommands.py", line 403, in addelement
22:50:20      importCSG.insert(tmpfilename,doc.Name)
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/importCSG.py", line 154, in insert
22:50:20      processcsg(filename)
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/importCSG.py", line 179, in processcsg
22:50:20      result = parser.parse(f.read())
22:50:20    File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ply/yacc.py", line 333, in parse
22:50:20      return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
22:50:20    File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
22:50:20      p.callable(pslice)
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/importCSG.py", line 856, in p_import_file1
22:50:20      p[0] = [process_import_file(filen,ext,p[3]['layer'])]
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/importCSG.py", line 874, in process_import_file
22:50:20      obj=processDXF(fname,layer)
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/importCSG.py", line 971, in processDXF
22:50:20      face = importDXFface(filename,layer,doc)
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/OpenSCAD2Dgeom.py", line 496, in importDXFface
22:50:20      faces = edgestofaces(edges)
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/OpenSCAD2Dgeom.py", line 409, in edgestofaces
22:50:20      return Overlappingfaces(facel).makeshape()
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/OpenSCAD2Dgeom.py", line 228, in makeshape
22:50:20      return fusefaces(faces)
22:50:20    File "/Users/chennes/Documents/FreeCAD-chennes-master-build/Mod/OpenSCAD/OpenSCAD2Dgeom.py", line 365, in fusefaces
22:50:20      return reduce(lambda p1,p2: p1.fuse(p2),faces)
22:50:20  TypeError: reduce() of empty iterable with no initial value
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
imm
Posts: 250
Joined: Wed Nov 03, 2021 1:00 pm

Re: Problems importing DXF with OpenSCAD

Post by imm »

chennes wrote: Fri Mar 24, 2023 3:24 am I've submitted a PR with the suggested fix (is there anything special about using "0" as the default layer name?). https://github.com/FreeCAD/FreeCAD/pull/9021
I specified "0" as that was the 'default' layer specified in AutoCAD ...back in the days of DOS....
Thus it was almost always guaranteed to exist.

For those interested below link is a pdf reference from autodesk on AutoCAD ver 12 take on DXF structure.
Page 37 approximately lists a program in BASIC to read and interprete a dxf file.

https://damassets.autodesk.net/content/ ... 12_dxf.pdf
Post Reply