From 6a3b2a02f52db4c623e20a14eeef59aabe6f18ab Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 21 May 2020 15:24:31 -0400 Subject: [PATCH] [Draft]Post-review changes --- src/Mod/Draft/draftmake/make_patharray.py | 2 +- src/Mod/Draft/draftobjects/patharray.py | 46 +++++++++++------------ 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/Mod/Draft/draftmake/make_patharray.py b/src/Mod/Draft/draftmake/make_patharray.py index cf18a84e80..9ea3c7751c 100644 --- a/src/Mod/Draft/draftmake/make_patharray.py +++ b/src/Mod/Draft/draftmake/make_patharray.py @@ -27,7 +27,6 @@ # \brief This module provides the code for Draft make_path_array function. import FreeCAD as App -import FreeCADGui as Gui import draftutils.utils as utils import draftutils.gui_utils as gui_utils @@ -73,6 +72,7 @@ def make_path_array(baseobject,pathobject,count,xlate=None,align=False,pathobjsu use_link : TODO: Complete documentation """ + if not App.ActiveDocument: App.Console.PrintError("No active document. Aborting\n") return diff --git a/src/Mod/Draft/draftobjects/patharray.py b/src/Mod/Draft/draftobjects/patharray.py index c6cce29262..bd115e09e1 100644 --- a/src/Mod/Draft/draftobjects/patharray.py +++ b/src/Mod/Draft/draftobjects/patharray.py @@ -26,8 +26,6 @@ # \ingroup DRAFT # \brief This module provides the object code for the Draft PathArray object. -#from PySide.QtCore import _tr - import FreeCAD as App import DraftVecUtils @@ -38,9 +36,24 @@ from draftutils.translate import _tr, translate from draftobjects.draftlink import DraftLink class PathArray(DraftLink): - """The Draft Path Array object""" - def __init__(self, obj, use_link=False): - self.use_link = use_link + """The Draft Path Array object - distributes copies of an object along a path. + Original mode is the historic "Align" for old (v0.18) documents. It is not + really the Fernat alignment. Uses the normal parameter from getNormal (or the + default) as a constant - it does not calculate curve normal. + X is curve tangent, Y is normal parameter, Z is (X x Y) + + Tangent mode is similar to Original, but includes a pre-rotation (in execute) to + align the Base object's X to the TangentVector, then X follows curve tangent, + normal input parameter is the Z component. + + If the ForceVertical option is applied, the normal parameter from getNormal is + ignored, and X is curve tangent, Z is VerticalVector, Y is (X x Z) + + Frenet mode orients the copies to a coordinate system along the path. + X is tangent to curve, Y is curve normal, Z is curve binormal. + if normal can not be computed (ex a straight line), the default is used.""" + + def __init__(self, obj): super(PathArray, self).__init__(obj, "PathArray") #For PathLinkArray, DraftLink.attach creates the link to the Base object. @@ -128,7 +141,7 @@ class PathArray(DraftLink): elif obj.PathObj.Shape.Edges: w = Part.Wire(obj.PathObj.Shape.Edges) else: - Gui.Console.PrintLog ("PathArray.execute: path " + obj.PathObj.Name + " has no edges\n") + App.Console.PrintLog ("PathArray.execute: path " + obj.PathObj.Name + " has no edges\n") return if (hasattr(obj, "TangentVector")) and (obj.AlignMode == "Tangent") and (obj.Align): basePlacement = obj.Base.Shape.Placement @@ -183,8 +196,7 @@ def calculatePlacementsOnPath(shapeRotation, pathwire, count, xlate, align, closedpath = DraftGeomUtils.isReallyClosed(pathwire) normal = DraftGeomUtils.getNormal(pathwire) - if (forceNormal): - if not normalOverride is None: + if forceNormal and normalOverride: normal = normalOverride path = Part.__sortEdges__(pathwire.Edges) @@ -269,22 +281,6 @@ def calculatePlacement(globalRotation, edge, offset, RefPt, xlate, align, normal _msg("Draft CalculatePlacement - Cannot calculate Path tangent. Copy not aligned\n") return placement -#Original mode is the historic "Align" for old (v0.18) documents. It is not -#really the Fernat alignment. Uses the normal parameter from getNormal (or the -#default) as a constant - it does not calculate curve normal. -#X is curve tangent, Y is normal parameter, Z is (X x Y) - -#Tangent mode is similar to Original, but includes a pre-rotation (in execute) to -#align the Base object's X to the TangentVector, then X follows curve tangent, -#normal input parameter is the Z component. - -#If the ForceVertical option is applied, the normal parameter from getNormal is -#ignored, and X is curve tangent, Z is VerticalVector, Y is (X x Z) - -#Frenet mode orients the copies to a coordinate system along the path. -# X is tangent to curve, Y is curve normal, Z is curve binormal. -# if normal can not be computed (ex a straight line), the default is used. - if (mode == 'Original') or (mode == 'Tangent'): if normal is None: n = defNormal @@ -308,7 +304,7 @@ def calculatePlacement(globalRotation, edge, offset, RefPt, xlate, align, normal try: n = edge.normalAt(getParameterFromV0(edge, offset)) n.normalize() - except Gui.Base.FreeCADError: # no/infinite normals here + except App.Base.FreeCADError: # no/infinite normals here n = defNormal _msg("PathArray computePlacement - Cannot calculate Path normal, using default\n") try: