From b4c20bce205e8e8bc2862652e3ce4e4f11a3d155 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sun, 20 Feb 2022 16:09:28 -0300 Subject: [PATCH] Draft: Replace Drawing functions with TechDraw functions --- src/Mod/Draft/draftfunctions/dxf.py | 9 ++------- src/Mod/Draft/draftfunctions/svg.py | 6 ------ src/Mod/Draft/draftfunctions/svgshapes.py | 9 ++------- src/Mod/Draft/draftobjects/shape2dview.py | 6 +++--- src/Mod/Draft/importDXF.py | 12 ++++++------ 5 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/Mod/Draft/draftfunctions/dxf.py b/src/Mod/Draft/draftfunctions/dxf.py index f926987199..5464fa4d34 100644 --- a/src/Mod/Draft/draftfunctions/dxf.py +++ b/src/Mod/Draft/draftfunctions/dxf.py @@ -21,11 +21,6 @@ # * * # *************************************************************************** """Provides functions to return the DXF representation of various shapes. - -Warning: this still uses the `Drawing.projectToDXF` method to provide -the DXF representation of certain objects. -Therefore, even if the Drawing Workbench is obsolete, the `Drawing` module -may not be removed completely yet. This must be checked. """ ## @package dxf # \ingroup draftfunctions @@ -43,7 +38,7 @@ from draftutils.messages import _wrn # Delay import of module until first use because it is heavy Part = lz.LazyLoader("Part", globals(), "Part") DraftGeomUtils = lz.LazyLoader("DraftGeomUtils", globals(), "DraftGeomUtils") -Drawing = lz.LazyLoader("Drawing", globals(), "Drawing") +TechDraw = lz.LazyLoader("TechDraw", globals(), "TechDraw") ## \addtogroup draftfunctions @@ -119,7 +114,7 @@ def get_dxf(obj, direction=None): direction = App.Vector(0, 0, -1) try: - d = Drawing.projectToDXF(obj.Shape, direction) + d = TechDraw.projectToDXF(obj.Shape, direction) except Exception: # TODO: trap only specific exception. # Impossible to generate DXF from Shape? Which exception is throw? diff --git a/src/Mod/Draft/draftfunctions/svg.py b/src/Mod/Draft/draftfunctions/svg.py index 42760f18ca..cc37545235 100644 --- a/src/Mod/Draft/draftfunctions/svg.py +++ b/src/Mod/Draft/draftfunctions/svg.py @@ -22,11 +22,6 @@ # * * # *************************************************************************** """Provides functions to return the SVG representation of various shapes. - -Warning: this still uses the `Drawing.projectToSVG` method to provide -the SVG representation of certain objects. -Therefore, even if the Drawing Workbench is obsolete, the `Drawing` module -may not be removed completely yet. This must be checked. """ ## @package svg # \ingroup draftfunctions @@ -48,7 +43,6 @@ from draftutils.messages import _wrn, _err # Delay import of module until first use because it is heavy Part = lz.LazyLoader("Part", globals(), "Part") DraftGeomUtils = lz.LazyLoader("DraftGeomUtils", globals(), "DraftGeomUtils") -# Drawing = lz.LazyLoader("Drawing", globals(), "Drawing") ## \addtogroup draftfunctions diff --git a/src/Mod/Draft/draftfunctions/svgshapes.py b/src/Mod/Draft/draftfunctions/svgshapes.py index d119f2414a..e14645cc7b 100644 --- a/src/Mod/Draft/draftfunctions/svgshapes.py +++ b/src/Mod/Draft/draftfunctions/svgshapes.py @@ -22,11 +22,6 @@ # * * # *************************************************************************** """Provides functions to return the SVG representation of some shapes. - -Warning: this still uses the `Drawing.projectToSVG` method to provide -the SVG representation of certain objects. -Therefore, even if the Drawing Workbench is obsolete, the `Drawing` module -may not be removed completely yet. This must be checked. """ ## @package svgshapes # \ingroup draftfunctions @@ -45,7 +40,7 @@ from draftutils.messages import _msg, _wrn # Delay import of module until first use because it is heavy Part = lz.LazyLoader("Part", globals(), "Part") DraftGeomUtils = lz.LazyLoader("DraftGeomUtils", globals(), "DraftGeomUtils") -Drawing = lz.LazyLoader("Drawing", globals(), "Drawing") +TechDraw = lz.LazyLoader("TechDraw", globals(), "TechDraw") ## \addtogroup draftfunctions # @{ @@ -151,7 +146,7 @@ def _get_path_circ_ellipse(plane, edge, vertex, edata, done = False if int(occversion[0]) >= 7 and int(occversion[1]) >= 1: # if using occ >= 7.1, use HLR algorithm - snip = Drawing.projectToSVG(edge, drawing_plane_normal) + snip = TechDraw.projectToSVG(edge, drawing_plane_normal) if snip: try: diff --git a/src/Mod/Draft/draftobjects/shape2dview.py b/src/Mod/Draft/draftobjects/shape2dview.py index 279e8d338a..5183da27ce 100644 --- a/src/Mod/Draft/draftobjects/shape2dview.py +++ b/src/Mod/Draft/draftobjects/shape2dview.py @@ -140,9 +140,9 @@ class Shape2DView(DraftObject): def getProjected(self,obj,shape,direction): "returns projected edges from a shape and a direction" - import Part, Drawing, DraftGeomUtils + import Part, TechDraw, DraftGeomUtils edges = [] - _groups = Drawing.projectEx(shape, direction) + _groups = TechDraw.projectEx(shape, direction) for g in _groups[0:5]: if g: edges.append(g) @@ -210,7 +210,7 @@ class Shape2DView(DraftObject): onlysolids = obj.Base.OnlySolids if hasattr(obj,"OnlySolids"): # override base object onlysolids = obj.OnlySolids - import Arch, Part, Drawing + import Arch objs = groups.get_group_contents(objs, walls=True) if getattr(obj,"VisibleOnly",True): objs = gui_utils.remove_hidden(objs) diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index 8d23a3f1fc..4163174834 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -2877,7 +2877,7 @@ def getShapes(filename): def projectShape(shape, direction, tess=None): """Project shape in a given direction. - It uses `Drawing.projectEx(shape, direction)` + It uses `TechDraw.projectEx(shape, direction)` to return a list with all the parts of the projection. The first five elements are added to a list of edges, which are then put in a `Part.Compound`. @@ -2908,12 +2908,12 @@ def projectShape(shape, direction, tess=None): See also -------- - Drawing.projectEx, DraftGeomUtils.cleanProjection + TechDraw.projectEx, DraftGeomUtils.cleanProjection """ - import Drawing + import TechDraw edges = [] try: - groups = Drawing.projectEx(shape, direction) + groups = TechDraw.projectEx(shape, direction) except Part.OCCError: print("unable to project shape on direction ", direction) return shape @@ -4131,8 +4131,8 @@ def getViewDXF(view, blocks=True): r = view.Rotation if r != 0: r = -r # fix rotation direction - import Drawing - proj = Drawing.projectToDXF(view.Source.Shape, view.Direction) + import TechDraw + proj = TechDraw.projectToDXF(view.Source.Shape, view.Direction) if dxfExportBlocks: # change layer and set color and ltype to BYBLOCK (0) proj = proj.replace("sheet_layer\n",