Skip to content

Commit

Permalink
Draft: importDXF: fix off layer bug (FreeCAD#11090)
Browse files Browse the repository at this point in the history
* Draft: importDXF fix off layer bug

Fixes FreeCAD#10254.

* Typo

* Typo 2
  • Loading branch information
Roy-043 committed Oct 19, 2023
1 parent e95a1d7 commit 7eda70c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Mod/Draft/importDXF.py
Expand Up @@ -245,7 +245,7 @@ def deformat(text):
return t


def locateLayer(wantedLayer, color=None, drawstyle=None):
def locateLayer(wantedLayer, color=None, drawstyle=None, visibility=True):
"""Return layer group and create it if needed.
This function iterates over a global list named `layers`, which is
Expand All @@ -268,6 +268,14 @@ def locateLayer(wantedLayer, color=None, drawstyle=None):
A tuple with color information `(r,g,b,a)`, where each value
is a float between 0 and 1.
drawstyle : str, optional
It defaults to `None`. In which case "Solid" is used.
"Solid", "Dashed", "Dotted" or "Dashdot".
Visibility : bool, optional
It defaults to `True`.
Visibility of the new layer.
Returns
-------
App::FeaturePython or App::DocumentObjectGroup
Expand Down Expand Up @@ -298,6 +306,7 @@ def locateLayer(wantedLayer, color=None, drawstyle=None):
newLayer = Draft.make_layer(name=wantedLayer,
line_color=(0.0,0.0,0.0) if not color else color,
draw_style="Solid" if not drawstyle else drawstyle)
newLayer.Visibility = visibility
else:
newLayer = doc.addObject("App::DocumentObjectGroup", wantedLayer)
newLayer.Label = wantedLayer
Expand Down Expand Up @@ -2155,7 +2164,7 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
for table in drawing.tables.get_type("table"):
for layer in table.get_type("layer"):
name = layer.name
color = tuple(dxfColorMap.color_map[layer.color])
color = tuple(dxfColorMap.color_map[abs(layer.color)])
drawstyle = "Solid"
lt = rawValue(layer, 6)
if "DASHED" in lt.upper():
Expand All @@ -2164,7 +2173,7 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
drawstyle = "Dotted"
if ("DASHDOT" in lt.upper()) or ("CENTER" in lt.upper()):
drawstyle = "Dashdot"
locateLayer(name, color, drawstyle)
locateLayer(name, color, drawstyle, layer.color>0)
else:
locateLayer("0", (0.0, 0.0, 0.0), "Solid")

Expand Down

0 comments on commit 7eda70c

Please sign in to comment.