fixed bug #556 - Premature loading of modules
The Draft and Arch modules now load heavy modules such as Part or Sketch only when they use them, not anymore at Init time.
This commit is contained in:
parent
a9d2f1c678
commit
b8bcb43b66
|
@ -21,8 +21,8 @@
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent,math
|
import FreeCAD,FreeCADGui,Draft,ArchComponent,math
|
||||||
from draftlibs import fcgeo,fcvec
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
from pivy import coin
|
from pivy import coin
|
||||||
|
@ -81,6 +81,7 @@ class _Axis(ArchComponent.Component):
|
||||||
self.createGeometry(obj)
|
self.createGeometry(obj)
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
|
import Part
|
||||||
pl = obj.Placement
|
pl = obj.Placement
|
||||||
geoms = []
|
geoms = []
|
||||||
dist = 0
|
dist = 0
|
||||||
|
@ -121,6 +122,7 @@ class _ViewProviderAxis(ArchComponent.ViewProviderComponent):
|
||||||
self.bubbles = None
|
self.bubbles = None
|
||||||
|
|
||||||
def makeBubbles(self):
|
def makeBubbles(self):
|
||||||
|
import Part
|
||||||
rn = self.ViewObject.RootNode.getChild(2).getChild(0).getChild(0)
|
rn = self.ViewObject.RootNode.getChild(2).getChild(0).getChild(0)
|
||||||
if self.bubbles:
|
if self.bubbles:
|
||||||
rn.removeChild(self.bubbles)
|
rn.removeChild(self.bubbles)
|
||||||
|
|
|
@ -56,7 +56,7 @@ class _CommandBuilding:
|
||||||
if Draft.getType(sel[0]) in ["Cell","Site","Floor"]:
|
if Draft.getType(sel[0]) in ["Cell","Site","Floor"]:
|
||||||
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
||||||
nobj = makeBuilding()
|
nobj = makeBuilding()
|
||||||
Commands.copyProperties(sel[0],nobj)
|
ArchCommands.copyProperties(sel[0],nobj)
|
||||||
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
ok = True
|
ok = True
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent,ArchCommands
|
import FreeCAD,FreeCADGui,Draft,ArchComponent,ArchCommands
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class _CommandCell:
|
||||||
if Draft.getType(sel[0]) in ["Floor","Site","Building"]:
|
if Draft.getType(sel[0]) in ["Floor","Site","Building"]:
|
||||||
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
||||||
nobj = makeCell()
|
nobj = makeCell()
|
||||||
Commands.copyProperties(sel[0],nobj)
|
ArchCommands.copyProperties(sel[0],nobj)
|
||||||
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
ok = True
|
ok = True
|
||||||
|
@ -86,6 +86,7 @@ class _Cell(ArchComponent.Component):
|
||||||
self.createGeometry(obj)
|
self.createGeometry(obj)
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
|
import Part
|
||||||
pl = obj.Placement
|
pl = obj.Placement
|
||||||
if obj.Components:
|
if obj.Components:
|
||||||
if obj.JoinMode:
|
if obj.JoinMode:
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import FreeCAD,FreeCADGui,Part,Draft,MeshPart,ArchComponent
|
import FreeCAD,FreeCADGui,Draft,ArchComponent
|
||||||
from draftlibs import fcgeo,fcvec
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
@ -138,6 +138,8 @@ def splitMesh(obj,mark=True):
|
||||||
def meshToShape(obj,mark=True):
|
def meshToShape(obj,mark=True):
|
||||||
'''meshToShape(object,[mark]): turns a mesh into a shape, joining coplanar facets. If
|
'''meshToShape(object,[mark]): turns a mesh into a shape, joining coplanar facets. If
|
||||||
mark is True (default), non-solid objects will be marked in red'''
|
mark is True (default), non-solid objects will be marked in red'''
|
||||||
|
import Part,MeshPart
|
||||||
|
from draftlibs import fcgeo
|
||||||
if "Mesh" in obj.PropertiesList:
|
if "Mesh" in obj.PropertiesList:
|
||||||
faces = []
|
faces = []
|
||||||
mesh = obj.Mesh
|
mesh = obj.Mesh
|
||||||
|
@ -195,6 +197,7 @@ def meshToShape(obj,mark=True):
|
||||||
def removeShape(objs,mark=True):
|
def removeShape(objs,mark=True):
|
||||||
'''takes an arch object (wall or structure) built on a cubic shape, and removes
|
'''takes an arch object (wall or structure) built on a cubic shape, and removes
|
||||||
the inner shape, keeping its length, width and height as parameters.'''
|
the inner shape, keeping its length, width and height as parameters.'''
|
||||||
|
from draftlibs import fcgeo
|
||||||
if not isinstance(objs,list):
|
if not isinstance(objs,list):
|
||||||
objs = [objs]
|
objs = [objs]
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
|
|
|
@ -57,7 +57,7 @@ class _CommandFloor:
|
||||||
if Draft.getType(sel[0]) in ["Cell","Site","Building"]:
|
if Draft.getType(sel[0]) in ["Cell","Site","Building"]:
|
||||||
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
||||||
nobj = makeFloor()
|
nobj = makeFloor()
|
||||||
Commands.copyProperties(sel[0],nobj)
|
ArchCommands.copyProperties(sel[0],nobj)
|
||||||
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
ok = True
|
ok = True
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import FreeCAD,FreeCADGui,Part,ArchComponent,WorkingPlane,Drawing,math
|
import FreeCAD,FreeCADGui,ArchComponent,WorkingPlane,Drawing,math
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
from pivy import coin
|
from pivy import coin
|
||||||
from draftlibs import fcvec,fcgeo
|
from draftlibs import fcvec
|
||||||
|
|
||||||
|
|
||||||
class _CommandSectionPlane:
|
class _CommandSectionPlane:
|
||||||
|
@ -46,6 +46,7 @@ class _SectionPlane:
|
||||||
self.Type = "SectionPlane"
|
self.Type = "SectionPlane"
|
||||||
|
|
||||||
def execute(self,obj):
|
def execute(self,obj):
|
||||||
|
import Part
|
||||||
pl = obj.Placement
|
pl = obj.Placement
|
||||||
l = obj.ViewObject.DisplaySize
|
l = obj.ViewObject.DisplaySize
|
||||||
p = Part.makePlane(l,l,Vector(l/2,-l/2,0),Vector(0,0,-1))
|
p = Part.makePlane(l,l,Vector(l/2,-l/2,0),Vector(0,0,-1))
|
||||||
|
@ -183,6 +184,8 @@ class _ArchDrawingView:
|
||||||
return Vector(lx,ly,0)
|
return Vector(lx,ly,0)
|
||||||
|
|
||||||
def getPath(self,face,plane):
|
def getPath(self,face,plane):
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
"returns a svg path from a face"
|
"returns a svg path from a face"
|
||||||
svg ='<path '
|
svg ='<path '
|
||||||
edges = fcgeo.sortEdges(face.Edges)
|
edges = fcgeo.sortEdges(face.Edges)
|
||||||
|
|
|
@ -54,7 +54,7 @@ class _CommandSite:
|
||||||
if Draft.getType(sel[0]) in ["Cell","Building","Floor"]:
|
if Draft.getType(sel[0]) in ["Cell","Building","Floor"]:
|
||||||
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
FreeCAD.ActiveDocument.openTransaction("Type conversion")
|
||||||
nobj = makeSite()
|
nobj = makeSite()
|
||||||
Commands.copyProperties(sel[0],nobj)
|
ArchCommands.copyProperties(sel[0],nobj)
|
||||||
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
ok = True
|
ok = True
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent
|
import FreeCAD,FreeCADGui,Draft,ArchComponent
|
||||||
from draftlibs import fcgeo,fcvec
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ class _Structure(ArchComponent.Component):
|
||||||
self.createGeometry(obj)
|
self.createGeometry(obj)
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
# getting default values
|
# getting default values
|
||||||
height = normal = None
|
height = normal = None
|
||||||
if obj.Length:
|
if obj.Length:
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent
|
import FreeCAD,FreeCADGui,Draft,ArchComponent
|
||||||
from draftlibs import fcgeo,fcvec
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
@ -94,6 +94,9 @@ class _Wall(ArchComponent.Component):
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
|
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
|
|
||||||
def getbase(wire):
|
def getbase(wire):
|
||||||
"returns a full shape from a base wire"
|
"returns a full shape from a base wire"
|
||||||
dvec = fcgeo.vec(wire.Edges[0]).cross(normal)
|
dvec = fcgeo.vec(wire.Edges[0]).cross(normal)
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent
|
import FreeCAD,FreeCADGui,Draft,ArchComponent
|
||||||
from draftlibs import fcgeo,fcvec
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
@ -88,6 +88,8 @@ class _Window(ArchComponent.Component):
|
||||||
self.createGeometry(obj)
|
self.createGeometry(obj)
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
pl = obj.Placement
|
pl = obj.Placement
|
||||||
if obj.Base:
|
if obj.Base:
|
||||||
if obj.Base.isDerivedFrom("Part::Feature"):
|
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||||
|
|
|
@ -73,9 +73,9 @@ How it works / how to extend:
|
||||||
|
|
||||||
# import FreeCAD modules
|
# import FreeCAD modules
|
||||||
|
|
||||||
import FreeCAD, FreeCADGui, Part, math, sys, os, Image, Drawing, WorkingPlane
|
import FreeCAD, FreeCADGui, math, sys, os, WorkingPlane
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from draftlibs import fcvec, fcgeo
|
from draftlibs import fcvec
|
||||||
from pivy import coin
|
from pivy import coin
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@ -145,6 +145,7 @@ def getRealName(name):
|
||||||
|
|
||||||
def getType(obj):
|
def getType(obj):
|
||||||
"getType(object): returns the Draft type of the given object"
|
"getType(object): returns the Draft type of the given object"
|
||||||
|
import Part
|
||||||
if isinstance(obj,Part.Shape):
|
if isinstance(obj,Part.Shape):
|
||||||
return "Shape"
|
return "Shape"
|
||||||
if "Proxy" in obj.PropertiesList:
|
if "Proxy" in obj.PropertiesList:
|
||||||
|
@ -390,6 +391,7 @@ def makeWire(pointslist,closed=False,placement=None,face=True,support=None):
|
||||||
and last points are identical, the wire is closed. If face is
|
and last points are identical, the wire is closed. If face is
|
||||||
true (and wire is closed), the wire will appear filled. Instead of
|
true (and wire is closed), the wire will appear filled. Instead of
|
||||||
a pointslist, you can also pass a Part Wire.'''
|
a pointslist, you can also pass a Part Wire.'''
|
||||||
|
from draftlibs import fcgeo
|
||||||
if not isinstance(pointslist,list):
|
if not isinstance(pointslist,list):
|
||||||
nlist = []
|
nlist = []
|
||||||
for v in pointslist.Vertexes:
|
for v in pointslist.Vertexes:
|
||||||
|
@ -589,6 +591,7 @@ def fuse(object1,object2):
|
||||||
the union of the 2 given objects. If the objects are
|
the union of the 2 given objects. If the objects are
|
||||||
coplanar, a special Draft Wire is used, otherwise we use
|
coplanar, a special Draft Wire is used, otherwise we use
|
||||||
a standard Part fuse.'''
|
a standard Part fuse.'''
|
||||||
|
from draftlibs import fcgeo
|
||||||
if fcgeo.isCoplanar(object1.Shape.fuse(object2.Shape).Faces):
|
if fcgeo.isCoplanar(object1.Shape.fuse(object2.Shape).Faces):
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Fusion")
|
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Fusion")
|
||||||
_Wire(obj)
|
_Wire(obj)
|
||||||
|
@ -704,6 +707,7 @@ def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False)
|
||||||
omitted, the rotation will be around the vertical Z axis.
|
omitted, the rotation will be around the vertical Z axis.
|
||||||
If copy is True, the actual objects are not moved, but copies
|
If copy is True, the actual objects are not moved, but copies
|
||||||
are created instead. The objects (or their copies) are returned.'''
|
are created instead. The objects (or their copies) are returned.'''
|
||||||
|
import Part
|
||||||
typecheck([(copy,bool)], "rotate")
|
typecheck([(copy,bool)], "rotate")
|
||||||
if not isinstance(objectslist,list): objectslist = [objectslist]
|
if not isinstance(objectslist,list): objectslist = [objectslist]
|
||||||
newobjlist = []
|
newobjlist = []
|
||||||
|
@ -797,6 +801,8 @@ def offset(obj,delta,copy=False,bind=False,sym=False,occ=False):
|
||||||
and the offsetted wires will be bound by their endpoints, forming a face
|
and the offsetted wires will be bound by their endpoints, forming a face
|
||||||
if sym is True, bind must be true too, and the offset is made on both
|
if sym is True, bind must be true too, and the offset is made on both
|
||||||
sides, the total width being the given delta length.'''
|
sides, the total width being the given delta length.'''
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
|
|
||||||
def getRect(p,obj):
|
def getRect(p,obj):
|
||||||
"returns length,heigh,placement"
|
"returns length,heigh,placement"
|
||||||
|
@ -910,6 +916,7 @@ def draftify(objectslist,makeblock=False):
|
||||||
'''draftify(objectslist,[makeblock]): turns each object of the given list
|
'''draftify(objectslist,[makeblock]): turns each object of the given list
|
||||||
(objectslist can also be a single object) into a Draft parametric
|
(objectslist can also be a single object) into a Draft parametric
|
||||||
wire. If makeblock is True, multiple objects will be grouped in a block'''
|
wire. If makeblock is True, multiple objects will be grouped in a block'''
|
||||||
|
from draftlibs import fcgeo
|
||||||
if not isinstance(objectslist,list):
|
if not isinstance(objectslist,list):
|
||||||
objectslist = [objectslist]
|
objectslist = [objectslist]
|
||||||
newobjlist = []
|
newobjlist = []
|
||||||
|
@ -949,6 +956,8 @@ def getSVG(obj,modifier=100,textmodifier=100,linestyle="continuous",fillstyle="s
|
||||||
specifies a scale factor for linewidths in %, and textmodifier specifies
|
specifies a scale factor for linewidths in %, and textmodifier specifies
|
||||||
a scale factor for texts, in % (both default = 100). You can also supply
|
a scale factor for texts, in % (both default = 100). You can also supply
|
||||||
an arbitrary projection vector.'''
|
an arbitrary projection vector.'''
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
svg = ""
|
svg = ""
|
||||||
tmod = ((textmodifier-100)/2)+100
|
tmod = ((textmodifier-100)/2)+100
|
||||||
if tmod == 0: tmod = 0.01
|
if tmod == 0: tmod = 0.01
|
||||||
|
@ -1179,7 +1188,8 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None,name="Sketch"):
|
||||||
constraints will be automatically added to wire nodes, rectangles
|
constraints will be automatically added to wire nodes, rectangles
|
||||||
and circles. If addTo is an existing sketch, geometry will be added to it instead of
|
and circles. If addTo is an existing sketch, geometry will be added to it instead of
|
||||||
creating a new one.'''
|
creating a new one.'''
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
from Sketcher import Constraint
|
from Sketcher import Constraint
|
||||||
|
|
||||||
StartPoint = 1
|
StartPoint = 1
|
||||||
|
@ -1382,6 +1392,8 @@ class _ViewProviderDimension:
|
||||||
obj.Override = ''
|
obj.Override = ''
|
||||||
|
|
||||||
def calcGeom(self,obj):
|
def calcGeom(self,obj):
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
p1 = obj.Start
|
p1 = obj.Start
|
||||||
p4 = obj.End
|
p4 = obj.End
|
||||||
base = Part.Line(p1,p4).toShape()
|
base = Part.Line(p1,p4).toShape()
|
||||||
|
@ -1732,6 +1744,8 @@ class _ViewProviderAngularDimension:
|
||||||
self.onChanged(vobj,"FontName")
|
self.onChanged(vobj,"FontName")
|
||||||
|
|
||||||
def calcGeom(self,obj):
|
def calcGeom(self,obj):
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
rad = (obj.Dimline.sub(obj.Center)).Length
|
rad = (obj.Dimline.sub(obj.Center)).Length
|
||||||
cir = Part.makeCircle(rad,obj.Center,Vector(0,0,1),obj.FirstAngle,obj.LastAngle)
|
cir = Part.makeCircle(rad,obj.Center,Vector(0,0,1),obj.FirstAngle,obj.LastAngle)
|
||||||
cp = fcgeo.findMidpoint(cir.Edges[0])
|
cp = fcgeo.findMidpoint(cir.Edges[0])
|
||||||
|
@ -1856,6 +1870,7 @@ class _Rectangle:
|
||||||
self.createGeometry(fp)
|
self.createGeometry(fp)
|
||||||
|
|
||||||
def createGeometry(self,fp):
|
def createGeometry(self,fp):
|
||||||
|
import Part
|
||||||
plm = fp.Placement
|
plm = fp.Placement
|
||||||
p1 = Vector(0,0,0)
|
p1 = Vector(0,0,0)
|
||||||
p2 = Vector(p1.x+fp.Length,p1.y,p1.z)
|
p2 = Vector(p1.x+fp.Length,p1.y,p1.z)
|
||||||
|
@ -1910,6 +1925,7 @@ class _Circle:
|
||||||
self.createGeometry(fp)
|
self.createGeometry(fp)
|
||||||
|
|
||||||
def createGeometry(self,fp):
|
def createGeometry(self,fp):
|
||||||
|
import Part
|
||||||
plm = fp.Placement
|
plm = fp.Placement
|
||||||
shape = Part.makeCircle(fp.Radius,Vector(0,0,0),
|
shape = Part.makeCircle(fp.Radius,Vector(0,0,0),
|
||||||
Vector(0,0,1),fp.FirstAngle,fp.LastAngle)
|
Vector(0,0,1),fp.FirstAngle,fp.LastAngle)
|
||||||
|
@ -1967,6 +1983,8 @@ class _Wire:
|
||||||
fp.Points = pts
|
fp.Points = pts
|
||||||
|
|
||||||
def createGeometry(self,fp):
|
def createGeometry(self,fp):
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
plm = fp.Placement
|
plm = fp.Placement
|
||||||
if fp.Base and (not fp.Tool):
|
if fp.Base and (not fp.Tool):
|
||||||
if fp.Base.isDerivedFrom("Sketcher::SketchObject"):
|
if fp.Base.isDerivedFrom("Sketcher::SketchObject"):
|
||||||
|
@ -2065,6 +2083,7 @@ class _Polygon:
|
||||||
self.createGeometry(fp)
|
self.createGeometry(fp)
|
||||||
|
|
||||||
def createGeometry(self,fp):
|
def createGeometry(self,fp):
|
||||||
|
import Part
|
||||||
plm = fp.Placement
|
plm = fp.Placement
|
||||||
angle = (math.pi*2)/fp.FacesNumber
|
angle = (math.pi*2)/fp.FacesNumber
|
||||||
if fp.DrawMode == 'inscribed':
|
if fp.DrawMode == 'inscribed':
|
||||||
|
@ -2142,6 +2161,7 @@ class _BSpline:
|
||||||
self.createGeometry(fp)
|
self.createGeometry(fp)
|
||||||
|
|
||||||
def createGeometry(self,fp):
|
def createGeometry(self,fp):
|
||||||
|
import Part
|
||||||
plm = fp.Placement
|
plm = fp.Placement
|
||||||
if fp.Points:
|
if fp.Points:
|
||||||
if fp.Points[0] == fp.Points[-1]:
|
if fp.Points[0] == fp.Points[-1]:
|
||||||
|
@ -2209,6 +2229,7 @@ class _Block:
|
||||||
self.createGeometry(fp)
|
self.createGeometry(fp)
|
||||||
|
|
||||||
def createGeometry(self,fp):
|
def createGeometry(self,fp):
|
||||||
|
import Part
|
||||||
plm = fp.Placement
|
plm = fp.Placement
|
||||||
shps = []
|
shps = []
|
||||||
for c in fp.Components:
|
for c in fp.Components:
|
||||||
|
@ -2247,6 +2268,8 @@ class _Shape2DView:
|
||||||
self.createGeometry(obj)
|
self.createGeometry(obj)
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
|
import Drawing
|
||||||
|
from draftlibs import fcgeo
|
||||||
pl = obj.Placement
|
pl = obj.Placement
|
||||||
if obj.Base:
|
if obj.Base:
|
||||||
if obj.Base.isDerivedFrom("Part::Feature"):
|
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||||
|
@ -2296,6 +2319,7 @@ class _Array:
|
||||||
self.createGeometry(obj)
|
self.createGeometry(obj)
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
|
from draftlibs import fcgeo
|
||||||
if obj.Base:
|
if obj.Base:
|
||||||
pl = obj.Placement
|
pl = obj.Placement
|
||||||
if obj.ArrayType == "ortho":
|
if obj.ArrayType == "ortho":
|
||||||
|
@ -2307,6 +2331,7 @@ class _Array:
|
||||||
obj.Placement = pl
|
obj.Placement = pl
|
||||||
|
|
||||||
def rectArray(self,shape,xvector,yvector,xnum,ynum):
|
def rectArray(self,shape,xvector,yvector,xnum,ynum):
|
||||||
|
import Part
|
||||||
base = [shape.copy()]
|
base = [shape.copy()]
|
||||||
for xcount in range(xnum):
|
for xcount in range(xnum):
|
||||||
currentxvector=fcvec.scale(xvector,xcount)
|
currentxvector=fcvec.scale(xvector,xcount)
|
||||||
|
@ -2324,6 +2349,7 @@ class _Array:
|
||||||
return Part.makeCompound(base)
|
return Part.makeCompound(base)
|
||||||
|
|
||||||
def polarArray(self,shape,center,angle,num):
|
def polarArray(self,shape,center,angle,num):
|
||||||
|
import Part
|
||||||
fraction = angle/num
|
fraction = angle/num
|
||||||
base = [shape.copy()]
|
base = [shape.copy()]
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
|
@ -2356,6 +2382,7 @@ class _Point:
|
||||||
self.createGeometry(fp)
|
self.createGeometry(fp)
|
||||||
|
|
||||||
def createGeometry(self,fp):
|
def createGeometry(self,fp):
|
||||||
|
import Part
|
||||||
shape = Part.Vertex(Vector(fp.X,fp.Y,fp.Z))
|
shape = Part.Vertex(Vector(fp.X,fp.Y,fp.Z))
|
||||||
fp.Shape = shape
|
fp.Shape = shape
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ __author__ = "Yorik van Havre"
|
||||||
__url__ = "http://free-cad.sourceforge.net"
|
__url__ = "http://free-cad.sourceforge.net"
|
||||||
|
|
||||||
|
|
||||||
import FreeCAD, FreeCADGui, math, Draft, DraftGui, DraftTrackers, Part, SketcherGui
|
import FreeCAD, FreeCADGui, math, Draft, DraftGui, DraftTrackers
|
||||||
from DraftGui import todo
|
from DraftGui import todo
|
||||||
from draftlibs import fcvec,fcgeo
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from pivy import coin
|
from pivy import coin
|
||||||
from PyQt4 import QtCore,QtGui
|
from PyQt4 import QtCore,QtGui
|
||||||
|
@ -101,6 +101,10 @@ class Snapper:
|
||||||
be True to constrain the point against the closest working plane axis.
|
be True to constrain the point against the closest working plane axis.
|
||||||
Screenpos can be a list, a tuple or a coin.SbVec2s object."""
|
Screenpos can be a list, a tuple or a coin.SbVec2s object."""
|
||||||
|
|
||||||
|
global Part,fcgeo
|
||||||
|
import Part, SketcherGui
|
||||||
|
from draftlibs import fcgeo
|
||||||
|
|
||||||
def cstr(point):
|
def cstr(point):
|
||||||
"constrains if needed"
|
"constrains if needed"
|
||||||
if constrain:
|
if constrain:
|
||||||
|
|
|
@ -29,9 +29,9 @@ __url__ = "http://free-cad.sourceforge.net"
|
||||||
# Generic stuff
|
# Generic stuff
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
import os, FreeCAD, FreeCADGui, Part, WorkingPlane, math, re, importSVG, Draft, Draft_rc
|
import os, FreeCAD, FreeCADGui, WorkingPlane, math, re, importSVG, Draft, Draft_rc
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from draftlibs import fcvec,fcgeo
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from DraftGui import todo,QtCore,QtGui
|
from DraftGui import todo,QtCore,QtGui
|
||||||
from DraftSnap import *
|
from DraftSnap import *
|
||||||
|
@ -311,6 +311,9 @@ class Creator:
|
||||||
def Activated(self,name="None"):
|
def Activated(self,name="None"):
|
||||||
if FreeCAD.activeDraftCommand:
|
if FreeCAD.activeDraftCommand:
|
||||||
FreeCAD.activeDraftCommand.finish()
|
FreeCAD.activeDraftCommand.finish()
|
||||||
|
global Part, fcgeo
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
self.ui = None
|
self.ui = None
|
||||||
self.call = None
|
self.call = None
|
||||||
self.doc = None
|
self.doc = None
|
||||||
|
@ -1624,6 +1627,9 @@ class Modifier:
|
||||||
def Activated(self,name="None"):
|
def Activated(self,name="None"):
|
||||||
if FreeCAD.activeDraftCommand:
|
if FreeCAD.activeDraftCommand:
|
||||||
FreeCAD.activeDraftCommand.finish()
|
FreeCAD.activeDraftCommand.finish()
|
||||||
|
global Part, fcgeo
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
self.ui = None
|
self.ui = None
|
||||||
self.call = None
|
self.call = None
|
||||||
self.commitList = []
|
self.commitList = []
|
||||||
|
|
|
@ -25,15 +25,18 @@ __title__="FreeCAD Draft Trackers"
|
||||||
__author__ = "Yorik van Havre"
|
__author__ = "Yorik van Havre"
|
||||||
__url__ = "http://free-cad.sourceforge.net"
|
__url__ = "http://free-cad.sourceforge.net"
|
||||||
|
|
||||||
import FreeCAD,FreeCADGui,math,Draft,Part
|
import FreeCAD,FreeCADGui,math,Draft
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from draftlibs import fcvec,fcgeo
|
from draftlibs import fcvec
|
||||||
from pivy import coin
|
from pivy import coin
|
||||||
from DraftGui import todo
|
from DraftGui import todo
|
||||||
|
|
||||||
class Tracker:
|
class Tracker:
|
||||||
"A generic Draft Tracker, to be used by other specific trackers"
|
"A generic Draft Tracker, to be used by other specific trackers"
|
||||||
def __init__(self,dotted=False,scolor=None,swidth=None,children=[],ontop=False):
|
def __init__(self,dotted=False,scolor=None,swidth=None,children=[],ontop=False):
|
||||||
|
global Part, fcgeo
|
||||||
|
import Part
|
||||||
|
from draftlibs import fcgeo
|
||||||
self.ontop = ontop
|
self.ontop = ontop
|
||||||
color = coin.SoBaseColor()
|
color = coin.SoBaseColor()
|
||||||
color.rgb = scolor or FreeCADGui.draftToolBar.getDefaultColor("ui")
|
color.rgb = scolor or FreeCADGui.draftToolBar.getDefaultColor("ui")
|
||||||
|
@ -228,6 +231,7 @@ class dimTracker(Tracker):
|
||||||
self.calc()
|
self.calc()
|
||||||
|
|
||||||
def calc(self):
|
def calc(self):
|
||||||
|
import Part
|
||||||
if (self.p1 != None) and (self.p2 != None):
|
if (self.p1 != None) and (self.p2 != None):
|
||||||
points = [fcvec.tup(self.p1,True),fcvec.tup(self.p2,True),\
|
points = [fcvec.tup(self.p1,True),fcvec.tup(self.p2,True),\
|
||||||
fcvec.tup(self.p1,True),fcvec.tup(self.p2,True)]
|
fcvec.tup(self.p1,True),fcvec.tup(self.p2,True)]
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
import FreeCAD, FreeCADGui, Part, math
|
import FreeCAD, FreeCADGui, math
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
from draftlibs import fcvec
|
from draftlibs import fcvec
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ paths, lines, arcs and rects.
|
||||||
Bezier curves are skipped.
|
Bezier curves are skipped.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import xml.sax, string, FreeCAD, os, Part, math, re, Draft
|
import xml.sax, string, FreeCAD, os, math, re, Draft
|
||||||
from draftlibs import fcvec, fcgeo
|
from draftlibs import fcvec
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
|
|
||||||
try: import FreeCADGui
|
try: import FreeCADGui
|
||||||
|
@ -242,6 +242,8 @@ class svgHandler(xml.sax.ContentHandler):
|
||||||
self.grouptransform = []
|
self.grouptransform = []
|
||||||
self.lastdim = None
|
self.lastdim = None
|
||||||
|
|
||||||
|
import Part
|
||||||
|
|
||||||
if gui and draftui:
|
if gui and draftui:
|
||||||
r = float(draftui.color.red()/255.0)
|
r = float(draftui.color.red()/255.0)
|
||||||
g = float(draftui.color.green()/255.0)
|
g = float(draftui.color.green()/255.0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user