Draft: Proper support for layers in DXF import/export (py exporter)

This commit is contained in:
Yorik van Havre
2019-07-04 11:03:03 -03:00
parent c246d76f0f
commit 2f4b08035f
2 changed files with 11 additions and 4 deletions

View File

@@ -386,7 +386,10 @@ Ex: for files in millimeters: 1, in centimeters: 10, in meters: 1000, in inches:
<string>If this is checked, DXF layers will be imported as Draft VisGroups</string>
</property>
<property name="text">
<string>Use VisGroups</string>
<string>Use Layers</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>dxfUseDraftVisGroups</cstring>

View File

@@ -254,7 +254,11 @@ def calcBulge(v1,bulge,v2):
return startpoint.add(endpoint)
def getGroup(ob):
"checks if the object is part of a group"
"checks if the object is part of a group or layer"
if dxfUseDraftVisGroups:
for layer in [o for o in FreeCAD.ActiveDocument.Objects if Draft.getType(o) == "Layer"]:
if ob in layer.Group:
return layer.Label
for i in FreeCAD.ActiveDocument.Objects:
if i.isDerivedFrom("App::DocumentObjectGroup"):
for j in i.Group:
@@ -1928,7 +1932,7 @@ def writePanelCut(ob,dxf,nospline,lwPoly,parent=None):
# dxf.append(dxfLibrary.Line(pts,color=getACI(ob),layer="Tags"))
def getStrGroup(ob):
"gets a string version of the group name"
"gets a string version of the group or layer name"
l = getGroup(ob)
if six.PY2:
if isinstance(l,six.text_type):
@@ -2335,7 +2339,7 @@ def readPreferences():
dxfImportHatches = p.GetBool("importDxfHatches",False)
dxfUseStandardSize = p.GetBool("dxfStdSize",False)
dxfGetColors = p.GetBool("dxfGetOriginalColors",False)
dxfUseDraftVisGroups = p.GetBool("dxfUseDraftVisGroups",False)
dxfUseDraftVisGroups = p.GetBool("dxfUseDraftVisGroups",True)
dxfFillMode = p.GetBool("fillmode",True)
dxfUseLegacyImporter = p.GetBool("dxfUseLegacyImporter",False)
dxfUseLegacyExporter = p.GetBool("dxfUseLegacyExporter",False)