Draft: Avoid import of whole Draft module (#25386)
This commit is contained in:
@@ -48,7 +48,6 @@ import PySide.QtWidgets as QtWidgets
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Draft
|
||||
import DraftVecUtils
|
||||
import WorkingPlane
|
||||
from draftutils import params
|
||||
|
||||
@@ -36,7 +36,6 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
import Draft
|
||||
import DraftVecUtils
|
||||
from FreeCAD import Units as U
|
||||
from draftguitools import gui_base
|
||||
|
||||
@@ -39,8 +39,6 @@ import PySide.QtCore as QtCore
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCADGui as Gui
|
||||
import Draft
|
||||
import Draft_rc
|
||||
from draftguitools import gui_base_original
|
||||
from draftguitools import gui_tool_utils
|
||||
from draftmake import make_fillet
|
||||
@@ -49,9 +47,6 @@ from draftutils import utils
|
||||
from draftutils.messages import _err, _toolmsg
|
||||
from draftutils.translate import translate
|
||||
|
||||
# The module is used to prevent complaints from code checkers (flake8)
|
||||
True if Draft_rc.__name__ else False
|
||||
|
||||
|
||||
class Fillet(gui_base_original.Creator):
|
||||
"""Gui command for the Fillet tool."""
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCADGui as Gui
|
||||
import Draft
|
||||
import draftguitools.gui_base as gui_base
|
||||
from draftfunctions import heal
|
||||
from draftguitools import gui_base
|
||||
|
||||
from draftutils.translate import translate
|
||||
|
||||
@@ -50,7 +50,7 @@ class Heal(gui_base.GuiCommandSimplest):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(Heal, self).__init__(name=translate("draft", "Heal"))
|
||||
super().__init__(name=translate("draft", "Heal"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
@@ -67,14 +67,14 @@ class Heal(gui_base.GuiCommandSimplest):
|
||||
|
||||
def Activated(self):
|
||||
"""Execute when the command is called."""
|
||||
super(Heal, self).Activated()
|
||||
super().Activated()
|
||||
|
||||
s = Gui.Selection.getSelection()
|
||||
self.doc.openTransaction("Heal")
|
||||
if s:
|
||||
Draft.heal(s)
|
||||
heal.heal(s)
|
||||
else:
|
||||
Draft.heal()
|
||||
heal.heal()
|
||||
self.doc.commitTransaction()
|
||||
|
||||
|
||||
|
||||
@@ -40,21 +40,21 @@ import collections as coll
|
||||
import inspect
|
||||
import itertools
|
||||
import math
|
||||
import pivy.coin as coin
|
||||
import PySide.QtCore as QtCore
|
||||
import PySide.QtGui as QtGui
|
||||
import PySide.QtWidgets as QtWidgets
|
||||
from pivy import coin
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
from PySide import QtWidgets
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
import Part
|
||||
import Draft
|
||||
import DraftVecUtils
|
||||
import DraftGeomUtils
|
||||
import WorkingPlane
|
||||
from draftguitools import gui_trackers as trackers
|
||||
from draftutils import gui_utils
|
||||
from draftutils import params
|
||||
from draftutils import utils
|
||||
from draftutils.init_tools import get_draft_snap_commands
|
||||
from draftutils.messages import _wrn
|
||||
from draftutils.translate import translate
|
||||
@@ -90,6 +90,7 @@ class Snapper:
|
||||
|
||||
def __init__(self):
|
||||
self.activeview = None
|
||||
self.toolbar = None
|
||||
self.lastObj = []
|
||||
self.lastObjSubelements = []
|
||||
self.radius = 0
|
||||
@@ -315,7 +316,7 @@ class Snapper:
|
||||
|
||||
# Check if we have an object under the cursor and try to
|
||||
# snap to it
|
||||
_view = Draft.get3DView()
|
||||
_view = gui_utils.get_3d_view()
|
||||
objectsUnderCursor = _view.getObjectsInfo((screenpos[0], screenpos[1]))
|
||||
if objectsUnderCursor:
|
||||
if self.snapObjectIndex >= len(objectsUnderCursor):
|
||||
@@ -370,7 +371,7 @@ class Snapper:
|
||||
|
||||
if (
|
||||
not obj
|
||||
or Draft.getType(obj) in UNSNAPPABLES
|
||||
or utils.get_type(obj) in UNSNAPPABLES
|
||||
or not getattr(obj.ViewObject, "Selectable", True)
|
||||
):
|
||||
# increase snapObjectIndex to find other objects under the cursor:
|
||||
@@ -385,11 +386,11 @@ class Snapper:
|
||||
if not shape.isNull():
|
||||
snaps.extend(self.snapToSpecials(obj, lastpoint, eline))
|
||||
|
||||
if Draft.getType(obj) == "Polygon":
|
||||
if utils.get_type(obj) == "Polygon":
|
||||
# Special snapping for polygons: add the center
|
||||
snaps.extend(self.snapToPolygon(obj))
|
||||
|
||||
elif Draft.getType(obj) == "BuildingPart" and self.isEnabled("Center"):
|
||||
elif utils.get_type(obj) == "BuildingPart" and self.isEnabled("Center"):
|
||||
# snap to the base placement of empty BuildingParts
|
||||
snaps.append([obj.Placement.Base, "center", self.toWP(obj.Placement.Base)])
|
||||
|
||||
@@ -433,30 +434,30 @@ class Snapper:
|
||||
# or vertices.
|
||||
snaps.extend(self.snapToNearUnprojected(point))
|
||||
|
||||
elif Draft.getType(obj) in ("LinearDimension", "AngularDimension"):
|
||||
elif utils.get_type(obj) in ("LinearDimension", "AngularDimension"):
|
||||
# for dimensions we snap to their 2 points:
|
||||
snaps.extend(self.snapToDim(obj))
|
||||
|
||||
elif Draft.getType(obj) == "Axis":
|
||||
elif utils.get_type(obj) == "Axis":
|
||||
for edge in obj.Shape.Edges:
|
||||
snaps.extend(self.snapToEndpoints(edge))
|
||||
snaps.extend(self.snapToIntersection(edge))
|
||||
|
||||
elif Draft.getType(obj).startswith("Mesh::"):
|
||||
elif utils.get_type(obj).startswith("Mesh::"):
|
||||
snaps.extend(self.snapToNearUnprojected(point))
|
||||
snaps.extend(self.snapToEndpoints(obj.Mesh))
|
||||
|
||||
elif Draft.getType(obj).startswith("Points::"):
|
||||
elif utils.get_type(obj).startswith("Points::"):
|
||||
snaps.extend(self.snapToEndpoints(obj.Points, point))
|
||||
|
||||
elif Draft.getType(obj) in ("WorkingPlaneProxy", "BuildingPart") and self.isEnabled(
|
||||
elif utils.get_type(obj) in ("WorkingPlaneProxy", "BuildingPart") and self.isEnabled(
|
||||
"Center"
|
||||
):
|
||||
# snap to the center of WPProxies or to the base
|
||||
# placement of no empty BuildingParts
|
||||
snaps.append([obj.Placement.Base, "center", self.toWP(obj.Placement.Base)])
|
||||
|
||||
elif Draft.getType(obj) == "SectionPlane":
|
||||
elif utils.get_type(obj) == "SectionPlane":
|
||||
# snap to corners of section planes
|
||||
snaps.extend(self.snapToEndpoints(obj.Shape))
|
||||
|
||||
@@ -498,7 +499,7 @@ class Snapper:
|
||||
if winner_not_near is None or shortest_not_near == shortest_all:
|
||||
winner = winner_all
|
||||
else:
|
||||
view = Draft.get3DView()
|
||||
view = gui_utils.get_3d_view()
|
||||
# get screen points with pixel coordinates
|
||||
scr_win_not_near_pt = App.Vector(*view.getPointOnScreen(winner_not_near[0]), 0)
|
||||
scr_cursor_pt = App.Vector(*view.getPointOnScreen(cursor_pt), 0)
|
||||
@@ -539,7 +540,7 @@ class Snapper:
|
||||
|
||||
def getApparentPoint(self, x, y):
|
||||
"""Return a 3D point, projected on the current working plane."""
|
||||
view = Draft.get3DView()
|
||||
view = gui_utils.get_3d_view()
|
||||
pt = view.getPoint(x, y)
|
||||
if self.mask != "z":
|
||||
if view.getCameraType() == "Perspective":
|
||||
@@ -618,9 +619,9 @@ class Snapper:
|
||||
if not ob.isDerivedFrom("Part::Feature"):
|
||||
continue
|
||||
edges = ob.Shape.Edges
|
||||
if Draft.getType(ob) == "Wall":
|
||||
if utils.get_type(ob) == "Wall":
|
||||
for so in [ob] + ob.Additions:
|
||||
if Draft.getType(so) == "Wall":
|
||||
if utils.get_type(so) == "Wall":
|
||||
if so.Base:
|
||||
edges.extend(so.Base.Shape.Edges)
|
||||
edges.reverse()
|
||||
@@ -1055,7 +1056,7 @@ class Snapper:
|
||||
# get the stored objects to calculate intersections
|
||||
for obj_name, sub_name in zip(self.lastObj, self.lastObjSubelements):
|
||||
obj = App.ActiveDocument.getObject(obj_name)
|
||||
if obj and (obj.isDerivedFrom("Part::Feature") or (Draft.getType(obj) == "Axis")):
|
||||
if obj and (obj.isDerivedFrom("Part::Feature") or utils.get_type(obj) == "Axis"):
|
||||
# obj sub is face, shape is edge:
|
||||
if "Face" in sub_name and shape.ShapeType == "Edge":
|
||||
face = obj.Shape.Faces[int(sub_name[4:]) - 1]
|
||||
@@ -1126,14 +1127,14 @@ class Snapper:
|
||||
snaps = []
|
||||
if self.isEnabled("Special"):
|
||||
|
||||
if Draft.getType(obj) == "Wall":
|
||||
if utils.get_type(obj) == "Wall":
|
||||
# special snapping for wall: snap to its base shape if it is linear
|
||||
if obj.Base:
|
||||
if not obj.Base.Shape.Solids:
|
||||
for v in obj.Base.Shape.Vertexes:
|
||||
snaps.append([v.Point, "special", self.toWP(v.Point)])
|
||||
|
||||
elif Draft.getType(obj) == "Structure":
|
||||
elif utils.get_type(obj) == "Structure":
|
||||
# special snapping for struct: only to its base point
|
||||
if obj.Base:
|
||||
if not obj.Base.Shape.Solids:
|
||||
@@ -1159,7 +1160,7 @@ class Snapper:
|
||||
|
||||
def getScreenDist(self, dist, cursor):
|
||||
"""Return a distance in 3D space from a screen pixels distance."""
|
||||
view = Draft.get3DView()
|
||||
view = gui_utils.get_3d_view()
|
||||
p1 = view.getPoint(cursor)
|
||||
p2 = view.getPoint((cursor[0] + dist, cursor[1]))
|
||||
return (p2.sub(p1)).Length
|
||||
@@ -1428,7 +1429,7 @@ class Snapper:
|
||||
self.pt = None
|
||||
self.holdPoints = []
|
||||
self.ui = Gui.draftToolBar
|
||||
self.view = Draft.get3DView()
|
||||
self.view = gui_utils.get_3d_view()
|
||||
|
||||
# remove any previous leftover callbacks
|
||||
try:
|
||||
@@ -1561,11 +1562,10 @@ class Snapper:
|
||||
|
||||
def get_snap_toolbar(self):
|
||||
"""Get the snap toolbar."""
|
||||
if not (hasattr(self, "toolbar") and self.toolbar):
|
||||
if self.toolbar is None:
|
||||
mw = Gui.getMainWindow()
|
||||
self.toolbar = mw.findChild(QtWidgets.QToolBar, "Draft Snap")
|
||||
if self.toolbar:
|
||||
return self.toolbar
|
||||
return self.toolbar
|
||||
|
||||
def toggleGrid(self):
|
||||
"""Toggle FreeCAD Draft Grid."""
|
||||
@@ -1587,22 +1587,21 @@ class Snapper:
|
||||
|
||||
def toggle_snap(self, snap, set_to=None):
|
||||
"""Sets the given snap on/off according to the given parameter"""
|
||||
if set_to: # set mode
|
||||
if set_to is True:
|
||||
if not snap in self.active_snaps:
|
||||
self.active_snaps.append(snap)
|
||||
status = True
|
||||
elif set_to is False:
|
||||
if snap in self.active_snaps:
|
||||
self.active_snaps.remove(snap)
|
||||
status = False
|
||||
else: # toggle mode, default
|
||||
if set_to is None: # toggle mode, default
|
||||
if not snap in self.active_snaps:
|
||||
self.active_snaps.append(snap)
|
||||
status = True
|
||||
elif snap in self.active_snaps:
|
||||
else:
|
||||
self.active_snaps.remove(snap)
|
||||
status = False
|
||||
elif set_to is True:
|
||||
if not snap in self.active_snaps:
|
||||
self.active_snaps.append(snap)
|
||||
status = True
|
||||
else:
|
||||
if snap in self.active_snaps:
|
||||
self.active_snaps.remove(snap)
|
||||
status = False
|
||||
self.save_snap_state()
|
||||
return status
|
||||
|
||||
@@ -1654,7 +1653,7 @@ class Snapper:
|
||||
|
||||
def setTrackers(self, update_grid=True):
|
||||
"""Set the trackers."""
|
||||
v = Draft.get3DView()
|
||||
v = gui_utils.get_3d_view()
|
||||
if v is None:
|
||||
return
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ import pivy.coin as coin
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Draft
|
||||
import DraftVecUtils
|
||||
from FreeCAD import Vector
|
||||
from draftutils import grid_observer
|
||||
@@ -95,7 +94,7 @@ class Tracker:
|
||||
|
||||
def get_scene_graph(self):
|
||||
"""Returns the current scenegraph or None if this is not a 3D view"""
|
||||
v = Draft.get3DView()
|
||||
v = gui_utils.get_3d_view()
|
||||
if v:
|
||||
return v.getSceneGraph()
|
||||
else:
|
||||
@@ -518,7 +517,7 @@ class bsplineTracker(Tracker):
|
||||
c = Part.BSplineCurve()
|
||||
# DNC: allows one to close the curve by placing ends close to each other
|
||||
if len(self.points) >= 3 and (
|
||||
(self.points[0] - self.points[-1]).Length < Draft.tolerance()
|
||||
(self.points[0] - self.points[-1]).Length < utils.tolerance()
|
||||
):
|
||||
# YVH: Added a try to bypass some hazardous situations
|
||||
try:
|
||||
@@ -1049,8 +1048,8 @@ class PlaneTracker(Tracker):
|
||||
|
||||
def __init__(self):
|
||||
# getting screen distance
|
||||
p1 = Draft.get3DView().getPoint((100, 100))
|
||||
p2 = Draft.get3DView().getPoint((110, 100))
|
||||
p1 = gui_utils.get_3d_view().getPoint((100, 100))
|
||||
p2 = gui_utils.get_3d_view().getPoint((110, 100))
|
||||
bl = (p2.sub(p1)).Length * (params.get_param("snapRange") / 2.0)
|
||||
pick = coin.SoPickStyle()
|
||||
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
|
||||
@@ -1670,7 +1669,7 @@ class archDimTracker(Tracker):
|
||||
self.param2 = self.dimnode.param2
|
||||
self.pnts = self.dimnode.pnts
|
||||
self.string = self.dimnode.string
|
||||
self.view = Draft.get3DView()
|
||||
self.view = gui_utils.get_3d_view()
|
||||
self.camera = self.view.getCameraNode()
|
||||
self.setMode(mode)
|
||||
self.setString()
|
||||
|
||||
@@ -44,21 +44,16 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
import Draft
|
||||
import Draft_rc
|
||||
import DraftVecUtils
|
||||
import draftutils.utils as utils
|
||||
import draftutils.gui_utils as gui_utils
|
||||
import draftguitools.gui_base_original as gui_base_original
|
||||
import draftguitools.gui_tool_utils as gui_tool_utils
|
||||
import draftguitools.gui_trackers as trackers
|
||||
|
||||
from draftfunctions import extrude
|
||||
from draftguitools import gui_base_original
|
||||
from draftguitools import gui_tool_utils
|
||||
from draftguitools import gui_trackers as trackers
|
||||
from draftutils import gui_utils
|
||||
from draftutils import utils
|
||||
from draftutils.messages import _msg, _err, _toolmsg
|
||||
from draftutils.translate import translate
|
||||
|
||||
# The module is used to prevent complaints from code checkers (flake8)
|
||||
True if Draft_rc.__name__ else False
|
||||
|
||||
|
||||
class Trimex(gui_base_original.Modifier):
|
||||
"""Gui Command for the Trimex tool.
|
||||
@@ -427,7 +422,7 @@ class Trimex(gui_base_original.Modifier):
|
||||
# print("delta", delta)
|
||||
self.doc.openTransaction("Extrude")
|
||||
Gui.addModule("Draft")
|
||||
obj = Draft.extrude(self.obj, delta, solid=True)
|
||||
obj = extrude.extrude(self.obj, delta, solid=True)
|
||||
self.doc.commitTransaction()
|
||||
self.obj = obj
|
||||
else:
|
||||
|
||||
@@ -41,16 +41,13 @@ depending on the desired result.
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCADGui as Gui
|
||||
import Draft_rc
|
||||
import Draft
|
||||
import draftutils.utils as utils
|
||||
import draftguitools.gui_base_original as gui_base_original
|
||||
|
||||
from draftguitools import gui_base_original
|
||||
from draftmake import make_bspline
|
||||
from draftmake import make_wire
|
||||
from draftutils import gui_utils
|
||||
from draftutils import utils
|
||||
from draftutils.translate import translate
|
||||
|
||||
# The module is used to prevent complaints from code checkers (flake8)
|
||||
True if Draft_rc.__name__ else False
|
||||
|
||||
|
||||
class WireToBSpline(gui_base_original.Modifier):
|
||||
"""Gui Command for the Wire to BSpline tool."""
|
||||
@@ -96,12 +93,12 @@ class WireToBSpline(gui_base_original.Modifier):
|
||||
self.closed = self.obj.Closed
|
||||
n = None
|
||||
if utils.getType(self.obj) == "Wire":
|
||||
n = Draft.make_bspline(
|
||||
n = make_bspline.make_bspline(
|
||||
self.Points, closed=self.closed, placement=self.pl
|
||||
)
|
||||
elif utils.getType(self.obj) == "BSpline":
|
||||
self.bs2wire = True
|
||||
n = Draft.make_wire(
|
||||
n = make_wire.make_wire(
|
||||
self.Points,
|
||||
closed=self.closed,
|
||||
placement=self.pl,
|
||||
@@ -110,7 +107,7 @@ class WireToBSpline(gui_base_original.Modifier):
|
||||
bs2wire=self.bs2wire,
|
||||
)
|
||||
if n:
|
||||
Draft.formatObject(n, self.obj)
|
||||
gui_utils.format_object(n, self.obj)
|
||||
self.doc.recompute()
|
||||
else:
|
||||
self.finish()
|
||||
|
||||
@@ -567,22 +567,7 @@ class ViewProviderLayerContainer:
|
||||
|
||||
def add_layer(self):
|
||||
"""Creates a new layer"""
|
||||
import Draft
|
||||
|
||||
doc = App.ActiveDocument
|
||||
doc.openTransaction(translate("draft", "Add New Layer"))
|
||||
|
||||
Draft.make_layer(
|
||||
name=None,
|
||||
line_color=None,
|
||||
shape_color=None,
|
||||
line_width=None,
|
||||
draw_style=None,
|
||||
transparency=None,
|
||||
)
|
||||
|
||||
doc.recompute()
|
||||
doc.commitTransaction()
|
||||
Gui.runCommand("Draft_Layer")
|
||||
|
||||
def reassign_props(self):
|
||||
for obj in self.Object.Group:
|
||||
|
||||
@@ -41,10 +41,10 @@ __url__ = "https://www.freecad.org"
|
||||
import re
|
||||
import os
|
||||
import FreeCAD
|
||||
import Draft
|
||||
import Part
|
||||
from FreeCAD import Vector
|
||||
from FreeCAD import Console as FCC
|
||||
from draftmake import make_wire
|
||||
from draftutils.utils import pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
@@ -175,7 +175,7 @@ def process(filename):
|
||||
|
||||
# do we use the parametric Draft Wire?
|
||||
if useDraftWire:
|
||||
obj = Draft.make_wire(coords, True)
|
||||
obj = make_wire.make_wire(coords, True)
|
||||
# obj.label = airfoilname
|
||||
else:
|
||||
# alternate solution, uses common Part Faces
|
||||
|
||||
+87
-63
@@ -59,15 +59,30 @@ import re
|
||||
import time
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Draft
|
||||
import Mesh
|
||||
import DraftVecUtils
|
||||
import DraftGeomUtils
|
||||
import WorkingPlane
|
||||
from FreeCAD import Vector
|
||||
from FreeCAD import Console as FCC
|
||||
from Draft import LinearDimension
|
||||
from draftobjects.dimension import _Dimension
|
||||
from draftfunctions import dxf
|
||||
from draftfunctions import rotate
|
||||
from draftmake import make_bezcurve
|
||||
from draftmake import make_bspline
|
||||
from draftmake import make_clone
|
||||
from draftmake import make_circle
|
||||
from draftmake import make_ellipse
|
||||
from draftmake import make_layer
|
||||
from draftmake import make_point
|
||||
from draftmake import make_sketch
|
||||
from draftmake import make_text
|
||||
from draftmake import make_wire
|
||||
from draftobjects import circle
|
||||
from draftobjects import dimension
|
||||
from draftobjects import ellipse
|
||||
from draftobjects import point
|
||||
from draftobjects import wire
|
||||
from draftutils import groups
|
||||
from draftutils import params
|
||||
from draftutils import utils
|
||||
from draftutils.utils import pyopen
|
||||
@@ -316,7 +331,7 @@ def locateLayer(wantedLayer, color=None, drawstyle=None, visibility=True):
|
||||
|
||||
See also
|
||||
--------
|
||||
Draft.make_layer
|
||||
make_layer.make_layer
|
||||
|
||||
To do
|
||||
-----
|
||||
@@ -330,7 +345,7 @@ def locateLayer(wantedLayer, color=None, drawstyle=None, visibility=True):
|
||||
if layer.Label == wantedLayer:
|
||||
return layer
|
||||
if dxfUseDraftVisGroups:
|
||||
newLayer = Draft.make_layer(
|
||||
newLayer = make_layer.make_layer(
|
||||
name=wantedLayer,
|
||||
line_color=(0.0, 0.0, 0.0) if not color else color,
|
||||
draw_style="Solid" if not drawstyle else drawstyle,
|
||||
@@ -444,7 +459,7 @@ def getGroup(ob):
|
||||
"""
|
||||
all_objs = FreeCAD.ActiveDocument.Objects
|
||||
if dxfUseDraftVisGroups:
|
||||
for layer in [o for o in all_objs if Draft.getType(o) == "Layer"]:
|
||||
for layer in [o for o in all_objs if utils.get_type(o) == "Layer"]:
|
||||
if ob in layer.Group:
|
||||
return layer.Label
|
||||
for i in all_objs:
|
||||
@@ -485,7 +500,7 @@ def getACI(ob, text=False):
|
||||
else:
|
||||
# detect if we need to set "BYLAYER"
|
||||
for parent in ob.InList:
|
||||
if Draft.getType(parent) == "Layer":
|
||||
if utils.get_type(parent) == "Layer":
|
||||
if ob in parent.Group:
|
||||
if hasattr(parent, "ViewObject") and hasattr(
|
||||
parent.ViewObject, "OverrideChildren"
|
||||
@@ -738,7 +753,7 @@ def vec(pt):
|
||||
-----
|
||||
Use local variables, not global variables.
|
||||
"""
|
||||
pre = Draft.precision()
|
||||
pre = utils.precision()
|
||||
if isinstance(pt, (int, float)):
|
||||
v = round(pt, pre)
|
||||
if resolvedScale != 1:
|
||||
@@ -851,7 +866,7 @@ def drawLine(line, forceShape=False):
|
||||
if not DraftVecUtils.equals(v1, v2):
|
||||
try:
|
||||
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
|
||||
return Draft.make_wire([v1, v2], face=False)
|
||||
return make_wire.make_wire([v1, v2], face=False)
|
||||
else:
|
||||
return Part.LineSegment(v1, v2).toShape()
|
||||
except Part.OCCError:
|
||||
@@ -968,7 +983,7 @@ def drawPolyline(polyline, forceShape=False, num=None):
|
||||
return Part.Face(w1)
|
||||
elif (dxfCreateDraft or dxfCreateSketch) and (not curves) and (not forceShape):
|
||||
# Create parametric Draft.Wire for straight polylines
|
||||
ob = Draft.make_wire(verts, face=False)
|
||||
ob = make_wire.make_wire(verts, face=False)
|
||||
ob.Closed = polyline.closed
|
||||
ob.Placement = placementFromDXFOCS(polyline)
|
||||
return ob
|
||||
@@ -1012,14 +1027,16 @@ def drawArc(arc, forceShape=False):
|
||||
-----
|
||||
Use local variables, not global variables.
|
||||
"""
|
||||
pre = Draft.precision()
|
||||
pre = utils.precision()
|
||||
pl = placementFromDXFOCS(arc)
|
||||
rad = vec(arc.radius)
|
||||
firstangle = round(arc.start_angle % 360, pre)
|
||||
lastangle = round(arc.end_angle % 360, pre)
|
||||
try:
|
||||
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
|
||||
return Draft.make_circle(rad, pl, face=False, startangle=firstangle, endangle=lastangle)
|
||||
return make_circle.make_circle(
|
||||
rad, pl, face=False, startangle=firstangle, endangle=lastangle
|
||||
)
|
||||
else:
|
||||
circle = Part.Circle()
|
||||
circle.Radius = rad
|
||||
@@ -1066,7 +1083,7 @@ def drawCircle(circle, forceShape=False):
|
||||
rad = vec(circle.radius)
|
||||
try:
|
||||
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
|
||||
return Draft.make_circle(rad, pl, face=False)
|
||||
return make_circle.make_circle(rad, pl, face=False)
|
||||
else:
|
||||
curve = Part.Circle()
|
||||
curve.Radius = rad
|
||||
@@ -1110,7 +1127,7 @@ def drawEllipse(ellipse, forceShape=False):
|
||||
Use local variables, not global variables.
|
||||
"""
|
||||
try:
|
||||
pre = Draft.precision()
|
||||
pre = utils.precision()
|
||||
c = vec(ellipse.loc)
|
||||
start = round(ellipse.start_angle, pre)
|
||||
end = round(ellipse.end_angle, pre)
|
||||
@@ -1130,7 +1147,7 @@ def drawEllipse(ellipse, forceShape=False):
|
||||
shape.Placement = pl
|
||||
return shape
|
||||
else:
|
||||
return Draft.make_ellipse(majr, minr, pl, face=False)
|
||||
return make_ellipse.make_ellipse(majr, minr, pl, face=False)
|
||||
else:
|
||||
shape = el.toShape(start, end)
|
||||
shape.Placement = pl
|
||||
@@ -1332,9 +1349,9 @@ def drawSplineIterpolation(verts, closed=False, forceShape=False, alwaysDiscreti
|
||||
"""
|
||||
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
|
||||
if dxfDiscretizeCurves or alwaysDiscretize:
|
||||
ob = Draft.make_wire(verts, face=False)
|
||||
ob = make_wire.make_wire(verts, face=False)
|
||||
else:
|
||||
ob = Draft.make_bspline(verts, face=False)
|
||||
ob = make_bspline.make_bspline(verts, face=False)
|
||||
ob.Closed = closed
|
||||
return ob
|
||||
else:
|
||||
@@ -1429,7 +1446,7 @@ def drawSpline(spline, forceShape=False):
|
||||
-------
|
||||
Part::Feature or Part::TopoShape ('Edge', 'Face')
|
||||
The returned object is normally a `Draft BezCurve`
|
||||
created with `Draft.make_bezcurve(controlpoints, degree=degree)`,
|
||||
created with `make_bezcurve.make_bezcurve(controlpoints, degree=degree)`,
|
||||
if `forceShape` is `False` and there are no weights.
|
||||
|
||||
Otherwise it tries to return a `Part.Shape` of type `'Wire'`,
|
||||
@@ -1459,7 +1476,7 @@ def drawSpline(spline, forceShape=False):
|
||||
|
||||
See also
|
||||
--------
|
||||
drawBlock, Draft.make_bezcurve, Part.BezierCurve, drawSplineIterpolation,
|
||||
drawBlock, make_bezcurve.make_bezcurve, Part.BezierCurve, drawSplineIterpolation,
|
||||
Part.BSplineCurve.buildFromPolesMultsKnots
|
||||
|
||||
To do
|
||||
@@ -1551,7 +1568,7 @@ def drawSpline(spline, forceShape=False):
|
||||
if not forceShape and weights is None:
|
||||
points = controlpoints[:]
|
||||
del points[degree + 1 :: degree + 1]
|
||||
return Draft.make_bezcurve(points, degree=degree)
|
||||
return make_bezcurve.make_bezcurve(points, degree=degree)
|
||||
else:
|
||||
poles = controlpoints[:]
|
||||
edges = []
|
||||
@@ -1780,7 +1797,7 @@ def drawInsert(insert, num=None, clone=False):
|
||||
addText(a, attrib=True)
|
||||
if clone:
|
||||
if insert.block in blockobjects:
|
||||
newob = Draft.make_clone(blockobjects[insert.block])
|
||||
newob = make_clone.make_clone(blockobjects[insert.block])
|
||||
tsf = FreeCAD.Matrix()
|
||||
rot = math.radians(insert.rotation)
|
||||
pos = vec(insert.loc)
|
||||
@@ -1851,7 +1868,6 @@ def drawLayerBlock(objlist, name="LayerBlock"):
|
||||
obj = None
|
||||
if (dxfCreateDraft or dxfCreateSketch) and isObj:
|
||||
try:
|
||||
# obj = Draft.make_block(objlist)
|
||||
obj = doc.addObject("Part::Compound", name)
|
||||
obj.Links = objlist
|
||||
except Part.OCCError:
|
||||
@@ -1999,7 +2015,7 @@ def addText(text, attrib=False):
|
||||
|
||||
See also
|
||||
--------
|
||||
locateLayer, drawBlock, Draft.make_text
|
||||
locateLayer, drawBlock, make_text.make_text
|
||||
|
||||
To do
|
||||
-----
|
||||
@@ -2021,7 +2037,7 @@ def addText(text, attrib=False):
|
||||
else:
|
||||
name = "Text"
|
||||
val = deformat(val)
|
||||
newob = Draft.make_text(val.split("\n"))
|
||||
newob = make_text.make_text(val.split("\n"))
|
||||
if hasattr(lay, "addObject"):
|
||||
lay.addObject(newob)
|
||||
elif hasattr(lay, "Proxy") and hasattr(lay.Proxy, "addObject"):
|
||||
@@ -2038,16 +2054,16 @@ def addText(text, attrib=False):
|
||||
if DraftVecUtils.isNull(ax):
|
||||
ax = Vector(0, 0, 1)
|
||||
ang = -math.degrees(DraftVecUtils.angle(xv, Vector(1, 0, 0), ax))
|
||||
Draft.rotate(newob, ang, axis=ax)
|
||||
rotate.rotate(newob, ang, axis=ax)
|
||||
if ax == Vector(0, 0, -1):
|
||||
ax = Vector(0, 0, 1)
|
||||
elif hasattr(text, "rotation"):
|
||||
if text.rotation:
|
||||
Draft.rotate(newob, text.rotation)
|
||||
rotate.rotate(newob, text.rotation)
|
||||
if attrib:
|
||||
attrot = rawValue(text, 50)
|
||||
if attrot:
|
||||
Draft.rotate(newob, attrot)
|
||||
rotate.rotate(newob, attrot)
|
||||
if gui and draftui and dxfUseStandardSize:
|
||||
fsize = draftui.fontsize
|
||||
else:
|
||||
@@ -2246,7 +2262,7 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
resolvedScale = getScaleFromDXF(drawing.header) * dxfScaling
|
||||
global layers
|
||||
typ = "Layer" if dxfUseDraftVisGroups else "App::DocumentObjectGroup"
|
||||
layers = [o for o in FreeCAD.ActiveDocument.Objects if Draft.getType(o) == typ]
|
||||
layers = [o for o in FreeCAD.ActiveDocument.Objects if utils.get_type(o) == typ]
|
||||
global doc
|
||||
doc = document
|
||||
global blockshapes
|
||||
@@ -2292,12 +2308,14 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
if dxfMakeBlocks or dxfJoin:
|
||||
if sketch:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True, addTo=sketch)
|
||||
shape = make_sketch.make_sketch(
|
||||
shape, autoconstraints=True, addTo=sketch
|
||||
)
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
sketch = shape
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
elif dxfJoin or getShapes:
|
||||
if isinstance(shape, Part.Shape):
|
||||
shapes.append(shape)
|
||||
@@ -2338,12 +2356,14 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
if dxfMakeBlocks or dxfJoin:
|
||||
if sketch:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True, addTo=sketch)
|
||||
shape = make_sketch.make_sketch(
|
||||
shape, autoconstraints=True, addTo=sketch
|
||||
)
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
sketch = shape
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
elif dxfJoin or getShapes:
|
||||
if isinstance(shape, Part.Shape):
|
||||
shapes.append(shape)
|
||||
@@ -2369,12 +2389,14 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
if dxfMakeBlocks or dxfJoin:
|
||||
if sketch:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True, addTo=sketch)
|
||||
shape = make_sketch.make_sketch(
|
||||
shape, autoconstraints=True, addTo=sketch
|
||||
)
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
sketch = shape
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
elif dxfJoin or getShapes:
|
||||
if isinstance(shape, Part.Shape):
|
||||
shapes.append(shape)
|
||||
@@ -2427,12 +2449,14 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
if dxfMakeBlocks or dxfJoin:
|
||||
if sketch:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True, addTo=sketch)
|
||||
shape = make_sketch.make_sketch(
|
||||
shape, autoconstraints=True, addTo=sketch
|
||||
)
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
sketch = shape
|
||||
else:
|
||||
shape = Draft.make_sketch(shape, autoconstraints=True)
|
||||
shape = make_sketch.make_sketch(shape, autoconstraints=True)
|
||||
elif dxfMakeBlocks:
|
||||
addToBlock(shape, circle.layer)
|
||||
elif getShapes:
|
||||
@@ -2617,11 +2641,11 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
lay.addObject(newob)
|
||||
elif hasattr(lay, "Proxy") and hasattr(lay.Proxy, "addObject"):
|
||||
lay.Proxy.addObject(lay, newob)
|
||||
_Dimension(newob)
|
||||
dimension.LinearDimension(newob)
|
||||
if gui:
|
||||
from Draft import _ViewProviderDimension
|
||||
from draftviewproviders import view_dimension
|
||||
|
||||
_ViewProviderDimension(newob.ViewObject)
|
||||
view_dimension.ViewProviderLinearDimension(newob.ViewObject)
|
||||
newob.Start = p1
|
||||
newob.End = p2
|
||||
newob.Dimline = pt
|
||||
@@ -2657,7 +2681,7 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
shape = Part.Vertex(x, y, z)
|
||||
addToBlock(shape, lay)
|
||||
else:
|
||||
newob = Draft.make_point(x, y, z)
|
||||
newob = make_point.make_point(x, y, z)
|
||||
lay = locateLayer(lay)
|
||||
lay.addObject(newob)
|
||||
if gui:
|
||||
@@ -2673,7 +2697,7 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
for leader in leaders:
|
||||
if dxfImportLayouts or (not rawValue(leader, 67)):
|
||||
points = getMultiplePoints(leader)
|
||||
newob = Draft.make_wire(points)
|
||||
newob = make_wire.make_wire(points)
|
||||
lay = locateLayer(rawValue(leader, 8))
|
||||
lay.addObject(newob)
|
||||
if gui:
|
||||
@@ -2704,7 +2728,7 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True):
|
||||
if gui:
|
||||
formatObject(newob, hatch)
|
||||
else:
|
||||
newob = Draft.make_wire(points)
|
||||
newob = make_wire.make_wire(points)
|
||||
locateLayer(lay).addObject(newob)
|
||||
if gui:
|
||||
formatObject(newob, hatch)
|
||||
@@ -2889,7 +2913,7 @@ def _import_dxf_file(filename, doc_name=None):
|
||||
draft_postprocessor = DxfDraftPostProcessor(doc, newly_created_objects, import_mode)
|
||||
draft_postprocessor.run()
|
||||
|
||||
Draft.convert_draft_texts() # This is a general utility that should run for both importers
|
||||
make_text.convert_draft_texts() # This is a general utility that should run for both importers
|
||||
doc.recompute()
|
||||
|
||||
processing_end_time = time.perf_counter()
|
||||
@@ -3705,12 +3729,12 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
getDXFlibs()
|
||||
if dxfLibrary:
|
||||
global exportList
|
||||
exportList = Draft.get_group_contents(objectslist, spaces=True)
|
||||
exportList = groups.get_group_contents(objectslist, spaces=True)
|
||||
|
||||
nlist = []
|
||||
exportLayers = []
|
||||
for ob in exportList:
|
||||
t = Draft.getType(ob)
|
||||
t = utils.get_type(ob)
|
||||
if t == "AxisSystem":
|
||||
nlist.extend(ob.Axes)
|
||||
elif t == "Layer":
|
||||
@@ -3723,7 +3747,7 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
nlist.append(ob)
|
||||
exportList = nlist
|
||||
|
||||
if (len(exportList) == 1) and (Draft.getType(exportList[0]) == "ArchSectionView"):
|
||||
if (len(exportList) == 1) and (utils.get_type(exportList[0]) == "ArchSectionView"):
|
||||
# arch view: export it "as is"
|
||||
dxf = exportList[0].Proxy.getDXF()
|
||||
if dxf:
|
||||
@@ -3761,7 +3785,7 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
)
|
||||
base_sketch_pla = None # Placement of the 1st sketch.
|
||||
for ob in exportList:
|
||||
obtype = Draft.getType(ob)
|
||||
obtype = utils.get_type(ob)
|
||||
# print("processing " + str(ob.Name))
|
||||
if obtype == "PanelSheet":
|
||||
if not hasattr(ob.Proxy, "sheetborder"):
|
||||
@@ -3775,7 +3799,7 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
ss.Placement = ob.Placement.multiply(ss.Placement)
|
||||
writeShape(ss, ob, dxf, nospline, lwPoly, layer="SheetTags", color=1)
|
||||
for subob in ob.Group:
|
||||
if Draft.getType(subob) == "PanelCut":
|
||||
if utils.get_type(subob) == "PanelCut":
|
||||
writePanelCut(subob, dxf, nospline, lwPoly, parent=ob)
|
||||
elif subob.isDerivedFrom("Part::Feature"):
|
||||
shp = subob.Shape.copy()
|
||||
@@ -4243,7 +4267,7 @@ def getViewDXF(view):
|
||||
blockcount = 1
|
||||
|
||||
if view.isDerivedFrom("TechDraw::DrawViewDraft"):
|
||||
geom = Draft.get_dxf(view)
|
||||
geom = dxf.get_dxf(view)
|
||||
block, insert, blockcount = getViewBlock(geom, view, blockcount)
|
||||
|
||||
elif view.isDerivedFrom("TechDraw::DrawViewArch"):
|
||||
@@ -4590,7 +4614,7 @@ class DxfDraftPostProcessor:
|
||||
# Transfer the TopoDS_Shape from the original Part::Line to the new object's Shape
|
||||
# property.
|
||||
new_obj.Shape = part_obj.Shape
|
||||
Draft.Wire(new_obj) # Attach the Python proxy. It will find Shape, Placement.
|
||||
wire.Wire(new_obj) # Attach the Python proxy. It will find Shape, Placement.
|
||||
|
||||
# Manually transfer the parametric data from the Part::Line primitive
|
||||
# to the new Draft.Wire's 'Points' property.
|
||||
@@ -4613,10 +4637,10 @@ class DxfDraftPostProcessor:
|
||||
|
||||
# Attach the Python proxy
|
||||
# This call will add properties like Radius, FirstAngle, LastAngle to new_obj.
|
||||
Draft.Circle(new_obj)
|
||||
circle.Circle(new_obj)
|
||||
|
||||
# Transfer data *after* proxy attachment.
|
||||
# Now that Draft.Circle(new_obj) has run and added the properties, we can assign values
|
||||
# Now that circle.Circle(new_obj) has run and added the properties, we can assign values
|
||||
# to them.
|
||||
# Part::Circle has Radius, Angle1, Angle2 properties.
|
||||
# Draft.Circle proxy uses FirstAngle and LastAngle instead of Angle1 and Angle2.
|
||||
@@ -4657,7 +4681,7 @@ class DxfDraftPostProcessor:
|
||||
new_obj.Placement = part_obj.Placement
|
||||
else:
|
||||
new_obj.Placement = FreeCAD.Placement()
|
||||
Draft.Point(new_obj) # Attach the Python proxy.
|
||||
point.Point(new_obj) # Attach the Python proxy.
|
||||
obj_type_str = "Point"
|
||||
|
||||
elif part_obj.isDerivedFrom("Part::Ellipse"):
|
||||
@@ -4673,7 +4697,7 @@ class DxfDraftPostProcessor:
|
||||
)
|
||||
|
||||
# Attach the parametric Draft.Ellipse Python proxy.
|
||||
Draft.Ellipse(new_obj)
|
||||
ellipse.Ellipse(new_obj)
|
||||
|
||||
# Transfer the parametric properties from the imported primitive to the new Draft
|
||||
# object. The proxy will handle recomputing the shape.
|
||||
@@ -4688,7 +4712,7 @@ class DxfDraftPostProcessor:
|
||||
new_obj = self.doc.addObject(
|
||||
"Part::Part2DObjectPython", self.doc.getUniqueObjectName("EllipticalArc")
|
||||
)
|
||||
Draft.Wire(new_obj) # Attach proxy.
|
||||
wire.Wire(new_obj) # Attach proxy.
|
||||
|
||||
# Re-create geometry at the origin using parametric properties.
|
||||
# Convert degrees back to radians for the geometry kernel.
|
||||
@@ -4725,7 +4749,7 @@ class DxfDraftPostProcessor:
|
||||
"Part::Part2DObjectPython", self.doc.getUniqueObjectName("Wire")
|
||||
)
|
||||
new_obj.Shape = shape # Transfer the TopoDS_Wire from the original Part::Feature.
|
||||
Draft.Wire(new_obj) # Attach Python proxy. It will find Shape, Placement.
|
||||
wire.Wire(new_obj) # Attach Python proxy. It will find Shape, Placement.
|
||||
|
||||
# Check if all segments of the wire are straight lines.
|
||||
# If so, we can safely populate the .Points property to make it parametric.
|
||||
@@ -4826,7 +4850,7 @@ class DxfDraftPostProcessor:
|
||||
layer_obj = None
|
||||
if found_layers:
|
||||
for l_obj in found_layers:
|
||||
if Draft.get_type(l_obj) == "Layer":
|
||||
if utils.get_type(l_obj) == "Layer":
|
||||
layer_obj = l_obj
|
||||
break
|
||||
|
||||
@@ -4866,7 +4890,7 @@ class DxfDraftPostProcessor:
|
||||
if placeholder.DxfEntityType == "DIMENSION":
|
||||
# 1. Create the base object and attach the proxy, which adds the needed properties.
|
||||
dim = self.doc.addObject("App::FeaturePython", "Dimension")
|
||||
_Dimension(dim)
|
||||
dimension.LinearDimension(dim)
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
ViewProviderLinearDimension(dim.ViewObject)
|
||||
@@ -4910,7 +4934,7 @@ class DxfDraftPostProcessor:
|
||||
dim.Direction = direction_vector
|
||||
|
||||
elif placeholder.DxfEntityType == "TEXT":
|
||||
text_obj = Draft.make_text(placeholder.Text)
|
||||
text_obj = make_text.make_text(placeholder.Text)
|
||||
text_obj.Placement = placeholder.Placement
|
||||
if FreeCAD.GuiUp:
|
||||
text_obj.addProperty("App::PropertyFloat", "DxfTextHeight", "Internal")
|
||||
|
||||
@@ -57,9 +57,11 @@ import xml.sax
|
||||
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Draft
|
||||
from DraftVecUtils import equals
|
||||
from FreeCAD import Vector
|
||||
from draftfunctions.svg import get_svg
|
||||
from draftmake import make_dimension
|
||||
from draftutils import gui_utils
|
||||
from draftutils import params
|
||||
from draftutils import utils
|
||||
from draftutils.utils import svg_precision
|
||||
@@ -752,7 +754,7 @@ class svgHandler(xml.sax.ContentHandler):
|
||||
p2 = Vector(float(p2[0]), -float(p2[1]), 0)
|
||||
p3 = data["freecad:dimpoint"]
|
||||
p3 = Vector(float(p3[0]), -float(p3[1]), 0)
|
||||
obj = Draft.make_dimension(p1, p2, p3)
|
||||
obj = make_dimension.make_dimension(p1, p2, p3)
|
||||
self.applyTrans(obj)
|
||||
self.format(obj)
|
||||
self.lastdim = obj
|
||||
@@ -1014,7 +1016,7 @@ class svgHandler(xml.sax.ContentHandler):
|
||||
for transform in self.grouptransform[::-1]:
|
||||
sh = transformCopyShape(sh, transform)
|
||||
return sh
|
||||
elif Draft.getType(sh) in ["Dimension", "LinearDimension"]:
|
||||
elif utils.get_type(sh) in ["Dimension", "LinearDimension"]:
|
||||
pts = []
|
||||
for p in [sh.Start, sh.End, sh.Dimline]:
|
||||
cp = Vector(p)
|
||||
@@ -1290,9 +1292,9 @@ def export(exportList, filename):
|
||||
if hasattr(obj, "Shape") and obj.Shape and obj.Shape.BoundBox.isValid():
|
||||
bb.add(obj.Shape.BoundBox)
|
||||
else:
|
||||
# if Draft.get_type(obj) in ("Text", "LinearDimension", ...)
|
||||
# if utils.get_type(obj) in ("Text", "LinearDimension", ...)
|
||||
_wrn("'{}': no Shape, " "calculate manual bounding box".format(obj.Label))
|
||||
bb.add(Draft.get_bbox(obj))
|
||||
bb.add(gui_utils.get_bbox(obj))
|
||||
|
||||
if not bb.isValid():
|
||||
_err(
|
||||
@@ -1360,7 +1362,7 @@ def export(exportList, filename):
|
||||
# raw-style exports do not translate the sketch
|
||||
svg.write('<g id="%s" transform="scale(1,-1)">\n' % ob.Name)
|
||||
|
||||
svg.write(Draft.get_svg(ob, override=False))
|
||||
svg.write(get_svg(ob, override=False))
|
||||
_label_enc = str(ob.Label.encode("utf8"))
|
||||
_label = _label_enc.replace("<", "<").replace(">", ">")
|
||||
# replace('"', """)
|
||||
|
||||
Reference in New Issue
Block a user