Draft: Updates related to the PlaneGui class (step 2)

Related issue:
#5603.

Additionally:
Fixed the issue where the texts of Arch_Space objects were not exported to DXF.
This commit is contained in:
Roy-043
2023-10-20 12:46:52 +02:00
parent 03aa8309db
commit ca06e87a38
9 changed files with 67 additions and 119 deletions

View File

@@ -77,8 +77,8 @@ def get_dxf(obj, direction=None):
if direction and isinstance(direction, App.Vector):
if direction != App.Vector(0, 0, 0):
plane = WorkingPlane.Plane()
plane.alignToPointAndAxis(App.Vector(0, 0, 0), direction)
plane = WorkingPlane.PlaneBase()
plane.align_to_point_and_axis(App.Vector(0, 0, 0), direction)
if utils.get_type(obj) in ("Dimension", "LinearDimension"):
p1 = _get_proj(obj.Start, plane=plane)

View File

@@ -33,9 +33,10 @@ It just creates a `Part::Mirroring` object, and sets the appropriate
## \addtogroup draftfunctions
# @{
import FreeCAD as App
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
import WorkingPlane
from draftutils import gui_utils
from draftutils import utils
from draftutils.messages import _err
from draftutils.translate import translate
@@ -48,14 +49,7 @@ def mirror(objlist, p1, p2):
It creates a `Part::Mirroring` object from the given `objlist` using
a plane that is defined by the two given points `p1` and `p2`,
and either
- the Draft working plane normal, or
- the negative normal provided by the camera direction
if the working plane normal does not exist and the graphical interface
is available.
If neither of these two is available, it uses as normal the +Z vector.
and the Draft working plane normal.
Parameters
----------
@@ -67,7 +61,7 @@ def mirror(objlist, p1, p2):
of the resulting object.
p2: Base::Vector3
Point 1 of the mirror plane.
Point 2 of the mirror plane.
Returns
-------
@@ -97,13 +91,7 @@ def mirror(objlist, p1, p2):
if not isinstance(objlist, list):
objlist = [objlist]
if hasattr(App, "DraftWorkingPlane"):
norm = App.DraftWorkingPlane.getNormal()
elif App.GuiUp:
norm = Gui.ActiveDocument.ActiveView.getViewDirection().negative()
else:
norm = App.Vector(0, 0, 1)
norm = WorkingPlane.get_working_plane(update=False).axis
pnorm = p2.sub(p1).cross(norm).normalize()
result = []

View File

@@ -396,7 +396,7 @@ def get_svg(obj,
direction: Base::Vector3, optional
It defaults to `None`.
It is an arbitrary projection vector or a `WorkingPlane.Plane`
It is an arbitrary projection vector or a `WorkingPlane.PlaneBase`
instance.
linestyle: optional
@@ -462,13 +462,13 @@ def get_svg(obj,
if direction:
if isinstance(direction, App.Vector):
if direction != App.Vector(0, 0, 0):
plane = WorkingPlane.plane()
plane.alignToPointAndAxis_SVG(App.Vector(0, 0, 0),
direction.negative().negative(),
0)
plane = WorkingPlane.PlaneBase()
plane.align_to_point_and_axis_svg(App.Vector(0, 0, 0),
direction.negative().negative(),
0)
else:
raise ValueError("'direction' cannot be: Vector(0, 0, 0)")
elif isinstance(direction, WorkingPlane.plane):
elif isinstance(direction, WorkingPlane.PlaneBase):
plane = direction
stroke = "#000000"

View File

@@ -32,6 +32,7 @@ import lazy_loader.lazy_loader as lz
import FreeCAD as App
import DraftVecUtils
import WorkingPlane
import draftutils.utils as utils
from draftutils.messages import _msg, _wrn
@@ -58,8 +59,8 @@ def get_proj(vec, plane=None):
vec: Base::Vector3
An arbitrary vector that will be projected on the U and V directions.
plane: WorkingPlane.Plane
An object of type `WorkingPlane`.
plane: WorkingPlane.PlaneBase
Working plane.
"""
if not plane:
return vec
@@ -124,13 +125,10 @@ def _get_path_circ_ellipse(plane, edge, verts, edata,
iscircle, isellipse,
fill, stroke, linewidth, lstyle):
"""Get the edge data from a path that is a circle or ellipse."""
if hasattr(App, "DraftWorkingPlane"):
drawing_plane_normal = App.DraftWorkingPlane.axis
else:
drawing_plane_normal = App.Vector(0, 0, 1)
if plane:
drawing_plane_normal = plane.axis
else:
drawing_plane_normal = WorkingPlane.get_working_plane(update=False).axis
center = edge.Curve
ax = center.Axis
@@ -272,13 +270,10 @@ def get_circle(plane,
cen = get_proj(edge.Curve.Center, plane)
rad = edge.Curve.Radius
if hasattr(App, "DraftWorkingPlane"):
drawing_plane_normal = App.DraftWorkingPlane.axis
else:
drawing_plane_normal = App.Vector(0, 0, 1)
if plane:
drawing_plane_normal = plane.axis
else:
drawing_plane_normal = WorkingPlane.get_working_plane(update=False).axis
if round(edge.Curve.Axis.getAngle(drawing_plane_normal), 2) in [0, 3.14]:
# Perpendicular projection: circle