now at least you can import

This commit is contained in:
Dave Cowden
2013-04-15 21:46:52 -04:00
parent ef92f654c7
commit 3f7d38cdeb
8 changed files with 27 additions and 31 deletions

View File

@ -30,7 +30,6 @@ class CQContext(object):
self.firstPoint = None #a reference to the first point for a set of edges. used to determine how to behave when close() is called self.firstPoint = None #a reference to the first point for a set of edges. used to determine how to behave when close() is called
self.tolerance = 0.0001 #user specified tolerance self.tolerance = 0.0001 #user specified tolerance
class CQ(object): class CQ(object):
""" """
Provides enhanced functionality for a wrapped CAD primitive. Provides enhanced functionality for a wrapped CAD primitive.

View File

@ -16,17 +16,19 @@
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; If not, see <http://www.gnu.org/licenses/> License along with this library; If not, see <http://www.gnu.org/licenses/>
""" """
#these items are the common implementation
from .CQ import CQ
from .workplane import Workplane
from . import plugins
from . import selectors
#these items point to the freecad implementation #these items point to the freecad implementation
from .freecad_impl.geom import Plane,BoundBox,Vector from .freecad_impl.geom import Plane,BoundBox,Vector
from .freecad_impl.shapes import Shape,Vertex,Edge,Wire,Solid,Shell,Compound from .freecad_impl.shapes import Shape,Vertex,Edge,Wire,Solid,Shell,Compound
from .freecad_impl.exporters import SvgExporter, AmfExporter, JsonExporter from .freecad_impl.exporters import SvgExporter, AmfExporter, JsonExporter
#these items are the common implementation
from .CQ import CQ
from .workplane import Workplane
from . import plugins
from . import selectors
__all__ = [ __all__ = [
'CQ','Workplane','plugins','selectors','Plane','BoundBox', 'CQ','Workplane','plugins','selectors','Plane','BoundBox',
'Shape','Vertex','Edge','Wire','Solid','Shell','Compound', 'Shape','Vertex','Edge','Wire','Solid','Shell','Compound',

View File

@ -16,9 +16,3 @@
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; If not, see <http://www.gnu.org/licenses/> License along with this library; If not, see <http://www.gnu.org/licenses/>
""" """
import FreeCAD
from FreeCAD import Part
from FreeCAD import Base
FreeCADVector = Base.Vector
DEFAULT_TOLERANCE = 0.0001

View File

@ -57,12 +57,12 @@ def guessUnitOfMeasure(shape):
class Exporter(object): class Exporter(object):
def export(self): def export(self):
""" """
return a string representing the model exported in the specified format return a string representing the model exported in the specified format
""" """
raise NotImplementedError() raise NotImplementedError()
class AMFExporter(Exporter): class AmfExporter(Exporter):
def __init__(self,tessellation): def __init__(self,tessellation):
self.units = "mm" self.units = "mm"
@ -135,8 +135,10 @@ class JsonExporter(Exporter):
'nFaces' : self.nFaces 'nFaces' : self.nFaces
}; };
class SVGExporter(Exporter): class SvgExporter(Exporter):
def export(self):
pass
def getPaths(freeCadSVG): def getPaths(freeCadSVG):
""" """

View File

@ -18,6 +18,8 @@
""" """
import math,sys import math,sys
import FreeCAD
import FreeCAD.Part
def sortWiresByBuildOrder(wireList,plane,result=[]): def sortWiresByBuildOrder(wireList,plane,result=[]):
""" """
@ -95,11 +97,11 @@ class Vector(object):
def __init__(self,*args): def __init__(self,*args):
if len(args) == 3: if len(args) == 3:
fV = FreeCADVector(args[0],args[1],args[2]) fV = FreeCAD.Base.Vector(args[0],args[1],args[2])
elif len(args) == 1: elif len(args) == 1:
if type(args[0]) is tuple: if type(args[0]) is tuple:
fV = FreeCADVector(args[0][0],args[0][1],args[0][2]) fV = FreeCAD.Base.Vector(args[0][0],args[0][1],args[0][2])
elif type(args[0] is FreeCADVector): elif type(args[0] is FreeCAD.Base.Vector):
fV = args[0] fV = args[0]
elif type(args[0] is Vector): elif type(args[0] is Vector):
fV = args[0].wrapped fV = args[0].wrapped
@ -137,7 +139,7 @@ class Vector(object):
Note: FreeCAD has a bug here, where the Note: FreeCAD has a bug here, where the
base is also modified base is also modified
""" """
tmp = FreeCADVector(self.wrapped) tmp = FreeCAD.Base.Vector(self.wrapped)
return Vector( tmp.multiply(scale)) return Vector( tmp.multiply(scale))
def normalize(self): def normalize(self):
@ -147,7 +149,7 @@ class Vector(object):
Note: FreeCAD has a bug here, where the Note: FreeCAD has a bug here, where the
base is also modified base is also modified
""" """
tmp = FreeCADVector(self.wrapped) tmp = FreeCAD.Base.Vector(self.wrapped)
tmp.normalize() tmp.normalize()
return Vector( tmp ) return Vector( tmp )

View File

@ -47,7 +47,9 @@
object each one returns, so these are better grouped by the type of object they return. object each one returns, so these are better grouped by the type of object they return.
(who would know that Part.makeCircle() returns an Edge, but Part.makePolygon() returns a Wire ? (who would know that Part.makeCircle() returns an Edge, but Part.makePolygon() returns a Wire ?
""" """
from cadquery import Vector
import FreeCAD
import FreeCAD.Part
class Shape(object): class Shape(object):
""" """
@ -63,7 +65,7 @@ class Shape(object):
def cast(cls,obj,forConstruction = False): def cast(cls,obj,forConstruction = False):
"Returns the right type of wrapper, given a FreeCAD object" "Returns the right type of wrapper, given a FreeCAD object"
s = obj.ShapeType s = obj.ShapeType
if type(obj) == FreeCADVector: if type(obj) == Base.Vector:
return Vector(obj) return Vector(obj)
tr = None tr = None

View File

@ -16,8 +16,3 @@
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
""" """
from .CQ import CQ
from .workplane import Workplane
__version__ = 0.9

View File

@ -18,8 +18,8 @@
""" """
import math import math
from . import CQ from . import CQ
from cadquery import Vector
class Workplane(CQ): class Workplane(CQ):
""" """