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:
Yorik van Havre
2011-12-31 17:16:51 -02:00
parent 2943f2d3ed
commit 4918fd32f1
16 changed files with 89 additions and 30 deletions

View File

@@ -21,8 +21,8 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent,math
from draftlibs import fcgeo,fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent,math
from draftlibs import fcvec
from FreeCAD import Vector
from PyQt4 import QtCore
from pivy import coin
@@ -81,6 +81,7 @@ class _Axis(ArchComponent.Component):
self.createGeometry(obj)
def createGeometry(self,obj):
import Part
pl = obj.Placement
geoms = []
dist = 0
@@ -121,6 +122,7 @@ class _ViewProviderAxis(ArchComponent.ViewProviderComponent):
self.bubbles = None
def makeBubbles(self):
import Part
rn = self.ViewObject.RootNode.getChild(2).getChild(0).getChild(0)
if self.bubbles:
rn.removeChild(self.bubbles)

View File

@@ -56,7 +56,7 @@ class _CommandBuilding:
if Draft.getType(sel[0]) in ["Cell","Site","Floor"]:
FreeCAD.ActiveDocument.openTransaction("Type conversion")
nobj = makeBuilding()
Commands.copyProperties(sel[0],nobj)
ArchCommands.copyProperties(sel[0],nobj)
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
FreeCAD.ActiveDocument.commitTransaction()
ok = True

View File

@@ -21,7 +21,7 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent,ArchCommands
import FreeCAD,FreeCADGui,Draft,ArchComponent,ArchCommands
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -58,7 +58,7 @@ class _CommandCell:
if Draft.getType(sel[0]) in ["Floor","Site","Building"]:
FreeCAD.ActiveDocument.openTransaction("Type conversion")
nobj = makeCell()
Commands.copyProperties(sel[0],nobj)
ArchCommands.copyProperties(sel[0],nobj)
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
FreeCAD.ActiveDocument.commitTransaction()
ok = True
@@ -86,6 +86,7 @@ class _Cell(ArchComponent.Component):
self.createGeometry(obj)
def createGeometry(self,obj):
import Part
pl = obj.Placement
if obj.Components:
if obj.JoinMode:

View File

@@ -21,8 +21,8 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part,Draft,MeshPart,ArchComponent
from draftlibs import fcgeo,fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -138,6 +138,8 @@ def splitMesh(obj,mark=True):
def meshToShape(obj,mark=True):
'''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'''
import Part,MeshPart
from draftlibs import fcgeo
if "Mesh" in obj.PropertiesList:
faces = []
mesh = obj.Mesh
@@ -195,6 +197,7 @@ def meshToShape(obj,mark=True):
def removeShape(objs,mark=True):
'''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.'''
from draftlibs import fcgeo
if not isinstance(objs,list):
objs = [objs]
for obj in objs:

View File

@@ -57,7 +57,7 @@ class _CommandFloor:
if Draft.getType(sel[0]) in ["Cell","Site","Building"]:
FreeCAD.ActiveDocument.openTransaction("Type conversion")
nobj = makeFloor()
Commands.copyProperties(sel[0],nobj)
ArchCommands.copyProperties(sel[0],nobj)
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
FreeCAD.ActiveDocument.commitTransaction()
ok = True

View File

@@ -1,8 +1,8 @@
import FreeCAD,FreeCADGui,Part,ArchComponent,WorkingPlane,Drawing,math
import FreeCAD,FreeCADGui,ArchComponent,WorkingPlane,Drawing,math
from FreeCAD import Vector
from PyQt4 import QtCore
from pivy import coin
from draftlibs import fcvec,fcgeo
from draftlibs import fcvec
class _CommandSectionPlane:
@@ -46,6 +46,7 @@ class _SectionPlane:
self.Type = "SectionPlane"
def execute(self,obj):
import Part
pl = obj.Placement
l = obj.ViewObject.DisplaySize
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)
def getPath(self,face,plane):
import Part
from draftlibs import fcgeo
"returns a svg path from a face"
svg ='<path '
edges = fcgeo.sortEdges(face.Edges)

View File

@@ -54,7 +54,7 @@ class _CommandSite:
if Draft.getType(sel[0]) in ["Cell","Building","Floor"]:
FreeCAD.ActiveDocument.openTransaction("Type conversion")
nobj = makeSite()
Commands.copyProperties(sel[0],nobj)
ArchCommands.copyProperties(sel[0],nobj)
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
FreeCAD.ActiveDocument.commitTransaction()
ok = True

View File

@@ -21,8 +21,8 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent
from draftlibs import fcgeo,fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -94,6 +94,8 @@ class _Structure(ArchComponent.Component):
self.createGeometry(obj)
def createGeometry(self,obj):
import Part
from draftlibs import fcgeo
# getting default values
height = normal = None
if obj.Length:

View File

@@ -21,8 +21,8 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent
from draftlibs import fcgeo,fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -93,6 +93,9 @@ class _Wall(ArchComponent.Component):
self.createGeometry(obj)
def createGeometry(self,obj):
import Part
from draftlibs import fcgeo
def getbase(wire):
"returns a full shape from a base wire"

View File

@@ -21,8 +21,8 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part,Draft,ArchComponent
from draftlibs import fcgeo,fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -88,6 +88,8 @@ class _Window(ArchComponent.Component):
self.createGeometry(obj)
def createGeometry(self,obj):
import Part
from draftlibs import fcgeo
pl = obj.Placement
if obj.Base:
if obj.Base.isDerivedFrom("Part::Feature"):