Merge pull request #6406 from marioalexis84/draft-drawing_techdraw
Draft: Replace Drawing functions with TechDraw functions
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user