Macro Creating faces from a DXF file

From FreeCAD Documentation
Jump to: navigation, search
Other languages:
English • ‎français • ‎italiano

Macro Creating faces from a DXF file.png Macro Creating faces from a DXF file

Description
This macro create face from a DXF file, the "Layer" are recognized separate and trained in groups.

Macro version : 01.00
Date last modification : 2014-10-29
FreeCAD version : All
Download : ToolBar Icon
Author
shoogen
Download
ToolBar Icon
Links
Macro Version
01.00
Date last modification
2014-10-29
FreeCAD Version(s)
All
Default shortcut
None
See also
None


Description

This macro create face from a DXF file, the "Layer" are recognized separate and trained in groups.

There must be groups in the file.

Uses

Launch the macro all objects are analyzed and transformed into faces.

Note: an unclosed object return an error

Script

ToolBar Icon Macro Creating faces from a DXF file.png

Macro_Creating_faces_from_a_DXF_file.FCMacro

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: # Exception: # 
        FreeCAD.Console.PrintError('Error in Group %s (%s)' % (group.Name,group.Label)+"\n")

Link

Forum Creating faces from a DXF file

Here an example Generate 3D solid from intersection of three imported 2D