From 3f7d38cdeb5dad6acdbcfa7cde07ad42851ff923 Mon Sep 17 00:00:00 2001 From: Dave Cowden Date: Mon, 15 Apr 2013 21:46:52 -0400 Subject: [PATCH] now at least you can import --- cadquery/CQ.py | 1 - cadquery/__init__.py | 12 +++++++----- cadquery/freecad_impl/__init__.py | 6 ------ cadquery/freecad_impl/exporters.py | 14 ++++++++------ cadquery/freecad_impl/geom.py | 12 +++++++----- cadquery/freecad_impl/shapes.py | 6 ++++-- cadquery/plugins/__init__.py | 5 ----- cadquery/workplane.py | 2 +- 8 files changed, 27 insertions(+), 31 deletions(-) diff --git a/cadquery/CQ.py b/cadquery/CQ.py index 5edfe08..e356018 100644 --- a/cadquery/CQ.py +++ b/cadquery/CQ.py @@ -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.tolerance = 0.0001 #user specified tolerance - class CQ(object): """ Provides enhanced functionality for a wrapped CAD primitive. diff --git a/cadquery/__init__.py b/cadquery/__init__.py index 61280a0..c3354a6 100644 --- a/cadquery/__init__.py +++ b/cadquery/__init__.py @@ -16,17 +16,19 @@ You should have received a copy of the GNU Lesser General Public License along with this library; If not, see """ -#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 from .freecad_impl.geom import Plane,BoundBox,Vector from .freecad_impl.shapes import Shape,Vertex,Edge,Wire,Solid,Shell,Compound 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__ = [ 'CQ','Workplane','plugins','selectors','Plane','BoundBox', 'Shape','Vertex','Edge','Wire','Solid','Shell','Compound', diff --git a/cadquery/freecad_impl/__init__.py b/cadquery/freecad_impl/__init__.py index 99d8ddb..306de0e 100644 --- a/cadquery/freecad_impl/__init__.py +++ b/cadquery/freecad_impl/__init__.py @@ -16,9 +16,3 @@ You should have received a copy of the GNU Lesser General Public License along with this library; If not, see """ - -import FreeCAD -from FreeCAD import Part -from FreeCAD import Base -FreeCADVector = Base.Vector -DEFAULT_TOLERANCE = 0.0001 \ No newline at end of file diff --git a/cadquery/freecad_impl/exporters.py b/cadquery/freecad_impl/exporters.py index efb174f..0a01498 100644 --- a/cadquery/freecad_impl/exporters.py +++ b/cadquery/freecad_impl/exporters.py @@ -57,12 +57,12 @@ def guessUnitOfMeasure(shape): class Exporter(object): 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() -class AMFExporter(Exporter): +class AmfExporter(Exporter): def __init__(self,tessellation): self.units = "mm" @@ -135,8 +135,10 @@ class JsonExporter(Exporter): 'nFaces' : self.nFaces }; -class SVGExporter(Exporter): - +class SvgExporter(Exporter): + + def export(self): + pass def getPaths(freeCadSVG): """ diff --git a/cadquery/freecad_impl/geom.py b/cadquery/freecad_impl/geom.py index 3eef580..9de4ae5 100644 --- a/cadquery/freecad_impl/geom.py +++ b/cadquery/freecad_impl/geom.py @@ -18,6 +18,8 @@ """ import math,sys +import FreeCAD +import FreeCAD.Part def sortWiresByBuildOrder(wireList,plane,result=[]): """ @@ -95,11 +97,11 @@ class Vector(object): def __init__(self,*args): 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: if type(args[0]) is tuple: - fV = FreeCADVector(args[0][0],args[0][1],args[0][2]) - elif type(args[0] is FreeCADVector): + fV = FreeCAD.Base.Vector(args[0][0],args[0][1],args[0][2]) + elif type(args[0] is FreeCAD.Base.Vector): fV = args[0] elif type(args[0] is Vector): fV = args[0].wrapped @@ -137,7 +139,7 @@ class Vector(object): Note: FreeCAD has a bug here, where the base is also modified """ - tmp = FreeCADVector(self.wrapped) + tmp = FreeCAD.Base.Vector(self.wrapped) return Vector( tmp.multiply(scale)) def normalize(self): @@ -147,7 +149,7 @@ class Vector(object): Note: FreeCAD has a bug here, where the base is also modified """ - tmp = FreeCADVector(self.wrapped) + tmp = FreeCAD.Base.Vector(self.wrapped) tmp.normalize() return Vector( tmp ) diff --git a/cadquery/freecad_impl/shapes.py b/cadquery/freecad_impl/shapes.py index 0221bde..a41f342 100644 --- a/cadquery/freecad_impl/shapes.py +++ b/cadquery/freecad_impl/shapes.py @@ -47,7 +47,9 @@ 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 ? """ - +from cadquery import Vector +import FreeCAD +import FreeCAD.Part class Shape(object): """ @@ -63,7 +65,7 @@ class Shape(object): def cast(cls,obj,forConstruction = False): "Returns the right type of wrapper, given a FreeCAD object" s = obj.ShapeType - if type(obj) == FreeCADVector: + if type(obj) == Base.Vector: return Vector(obj) tr = None diff --git a/cadquery/plugins/__init__.py b/cadquery/plugins/__init__.py index 49f9a9d..7965eb3 100644 --- a/cadquery/plugins/__init__.py +++ b/cadquery/plugins/__init__.py @@ -16,8 +16,3 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """ - -from .CQ import CQ -from .workplane import Workplane - -__version__ = 0.9 \ No newline at end of file diff --git a/cadquery/workplane.py b/cadquery/workplane.py index 3932918..1a946d1 100644 --- a/cadquery/workplane.py +++ b/cadquery/workplane.py @@ -18,8 +18,8 @@ """ import math - from . import CQ +from cadquery import Vector class Workplane(CQ): """