Creating faces from a DXF file
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: Creating faces from a DXF file
usually you should be able to call OpenSCAD2Dgeom.edgestofaces(edges) without the algo parameter.
Re: Creating faces from a DXF file
hi
I do not know how to operate with or without algo
mario
I do not know how to operate with or without algo
Code: Select all
import FreeCAD,FreeCADGui,Part,OpenSCAD2Dgeom
edges=sum((obj.Shape.Edges for obj in FreeCADGui.Selection.getSelection() if hasattr(obj,'Shape')),[])
faces=OpenSCAD2Dgeom.edgestofaces(edges,algo=None)
#Part.show(faces[0]) #problematic face to ommit
faces2=faces[1:9]+faces[10:15]+faces[16:]
face1=OpenSCAD2Dgeom.Overlappingfaces(faces2).makeshape()
#face2=face1.cut(faces[15]).cut(faces[9])#.fuse(faces[0])
Part.show(face2)
Part.show(faces[0])
Part.show(faces[9])
Part.show(faces[15])
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Creating faces from a DXF file
Code: Select all
import FreeCAD,FreeCADGui,Part,OpenSCAD2Dgeom
edges=sum((obj.Shape.Edges for obj in FreeCADGui.Selection.getSelection() \
if hasattr(obj,'Shape')),[])
Part.show(OpenSCAD2Dgeom.edgestofaces(edges))
Re: Creating faces from a DXF file
hi
same
Traceback (most recent call last):
File "C:/Program Files/FreeCAD 0.14/Macro_Creating faces from a DXF file.FCMacro", line 11, in <module>
Part.show(OpenSCAD2Dgeom.edgestofaces(edges))
File "C:\Program Files\FreeCAD 0.14\Mod\OpenSCAD\OpenSCAD2Dgeom.py", line 393, in edgestofaces
return Overlappingfaces(facel).makeshape()
File "C:\Program Files\FreeCAD 0.14\Mod\OpenSCAD\OpenSCAD2Dgeom.py", line 212, in makeshape
return fusefaces(faces)
File "C:\Program Files\FreeCAD 0.14\Mod\OpenSCAD\OpenSCAD2Dgeom.py", line 349, in fusefaces
return reduce(lambda p1,p2: p1.fuse(p2),faces)
<type 'exceptions.TypeError'>: reduce() of empty sequence with no initial value
mario
same
Traceback (most recent call last):
File "C:/Program Files/FreeCAD 0.14/Macro_Creating faces from a DXF file.FCMacro", line 11, in <module>
Part.show(OpenSCAD2Dgeom.edgestofaces(edges))
File "C:\Program Files\FreeCAD 0.14\Mod\OpenSCAD\OpenSCAD2Dgeom.py", line 393, in edgestofaces
return Overlappingfaces(facel).makeshape()
File "C:\Program Files\FreeCAD 0.14\Mod\OpenSCAD\OpenSCAD2Dgeom.py", line 212, in makeshape
return fusefaces(faces)
File "C:\Program Files\FreeCAD 0.14\Mod\OpenSCAD\OpenSCAD2Dgeom.py", line 349, in fusefaces
return reduce(lambda p1,p2: p1.fuse(p2),faces)
<type 'exceptions.TypeError'>: reduce() of empty sequence with no initial value
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Creating faces from a DXF file
And what did you select in the gui?
Re: Creating faces from a DXF file
hi
with select, give this error
Traceback (most recent call last):
File "C:/Program Files/FreeCAD 0.14/Macro_Creating faces from a DXF file.FCMacro", line 16, in <module>
faces2=faces[1:9]+faces[10:15]+faces[16:]
<type 'exceptions.TypeError'>: 'Part.TopoShape' object is unsubscriptable
mario
forget it !!!!shoogen wrote:And what did you select in the gui?
with select, give this error
Traceback (most recent call last):
File "C:/Program Files/FreeCAD 0.14/Macro_Creating faces from a DXF file.FCMacro", line 16, in <module>
faces2=faces[1:9]+faces[10:15]+faces[16:]
<type 'exceptions.TypeError'>: 'Part.TopoShape' object is unsubscriptable
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Creating faces from a DXF file
shoogen is there a way to work on shapes by DXF file layer? For each layer, I want to extrude the shapes differently to create different depth pockets. E.g., Mechanical30 is for holes all the way through the part, Mechanical31 is for pockets 1mm deep, Mechanical is for pockets 4mm deep, etc.
Re: Creating faces from a DXF file
You could try to select the objects by group.
But the file you attached to this topic only contained one group.
Code: Select all
objectlist=App.ActiveDocument.Mechanical30.Group
edges=sum((obj.Shape.Edges for obj in objectlist \
if hasattr(obj,'Shape')),[])
Re: Creating faces from a DXF file
Hi shoogen -- thanks! Yes, the original file had only one layer. We've subsequently broken it up into layers to help automate part generation in OpenSCAD for printing prototypes (attached). We're trying to use FreeCAD to make the CNC data though, since it can output STEP files.
- Attachments
-
- PCB7001-shieldtop1.dxf
- (133.57 KiB) Downloaded 103 times
Re: Creating faces from a DXF file
Code: Select all
import FreeCAD,Part,OpenSCAD2Dgeom
doc=App.ActiveDocument
for group in doc.findObjects('App::DocumentObjectGroup'):
try:
edges=sum((obj.Shape.Edges for obj in group.Group \
if hasattr(obj,'Shape')),[])
face = OpenSCAD2Dgeom.edgestofaces(edges)
faceobj=doc.addObject('Part::Feature','face_%s' % group.Name)
faceobj.Label = 'face_%s' % group.Label
faceobj.Shape = face
except Part.OCCError:
FreeCAD.Console.PrintError('Error in Group %s (%s)' % (group.Name,group.Label))