Skip to content

Commit

Permalink
Correct placementFromDXFOCS()
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoMesina committed Dec 13, 2020
1 parent 68eba58 commit d89c869
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Mod/Draft/importDXF.py
Expand Up @@ -785,7 +785,7 @@ def placementFromDXFOCS(ent):
Parameters
----------
ent : A DXF entity
It could be of several types, like `lwpolyline`, `polynine`,
It could be of several types, like `lwpolyline`, `polyline`,
and others, and with `ent.extrusion`, `ent.elevation`
or `ent.loc` attributes.
Expand All @@ -802,6 +802,27 @@ def placementFromDXFOCS(ent):
draftWPlane = FreeCAD.DraftWorkingPlane
draftWPlane.alignToPointAndAxis(Vector(0.0, 0.0, 0.0),
vec(ent.extrusion), 0.0)

# Riferimenti dell'algoritmo dell'asse arbitrario
# http://docs.autodesk.com/ACD/2011/ITA/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-7941.htm
# http://docs.autodesk.com/ACD/2011/ITA/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-793d.htm#WSc30cd3d5faa8f6d81cb25f1ffb755717d-7ff5
if (draftWPlane.axis == FreeCAD.Vector(1.0, 0.0, 0.0)):
draftWPlane.u = FreeCAD.Vector(0.0, 1.0, 0.0)
draftWPlane.v = FreeCAD.Vector(0.0, 0.0, 1.0)
elif (draftWPlane.axis == FreeCAD.Vector(-1.0, 0.0, 0.0)):
draftWPlane.u = FreeCAD.Vector(0.0, -1.0, 0.0)
draftWPlane.v = FreeCAD.Vector(0.0, 0.0, 1.0)
else:
if ((abs(ent.extrusion[0]) < (1.0 / 64.0)) and (abs(ent.extrusion[1]) < (1.0 / 64.0))):
draftWPlane.u = FreeCAD.Vector(0.0, 1.0, 0.0).cross(draftWPlane.axis)
else:
draftWPlane.u = FreeCAD.Vector(0.0, 0.0, 1.0).cross(draftWPlane.axis)
draftWPlane.u.normalize()
draftWPlane.v = draftWPlane.axis.cross(draftWPlane.u)
draftWPlane.v.normalize()
draftWPlane.position = Vector(0.0, 0.0, 0.0)
draftWPlane.weak = False

pl = FreeCAD.Placement()
pl = draftWPlane.getPlacement()
if ((ent.type == "lwpolyline") or (ent.type == "polyline")):
Expand Down

0 comments on commit d89c869

Please sign in to comment.