Updated the CadQuery lib.

This commit is contained in:
Jeremy Wright 2014-12-12 15:27:14 -05:00
parent 50bc84c3eb
commit a3beced8d1
4 changed files with 26 additions and 32 deletions

View File

@ -678,9 +678,9 @@ class CQ(object):
def _rot(obj): def _rot(obj):
startPt = obj.Center() startPt = obj.Center()
endPt = startPt + endVec endPt = startPt + endVec
obj.rotate(startPt,endPt,angleDegrees) return obj.rotate(startPt,endPt,angleDegrees)
return self.each(_rot,False) return self.each(_rot, False)
def translate(self,vec): def translate(self,vec):
""" """
@ -1437,7 +1437,6 @@ class Workplane(CQ):
else: else:
r = callBackFunction(obj) r = callBackFunction(obj)
if type(r) == Wire: if type(r) == Wire:
if not r.forConstruction: if not r.forConstruction:
self._addPendingWire(r) self._addPendingWire(r)

View File

@ -18,9 +18,6 @@
""" """
import math,sys import math,sys
#import FreeCAD
#from .verutil import fc_import
#FreeCAD = fc_import("FreeCAD")
import FreeCAD import FreeCAD
#Turns out we don't need the Part module here. #Turns out we don't need the Part module here.

View File

@ -21,9 +21,7 @@
""" """
import cadquery import cadquery
from .shapes import Shape from .shapes import Shape
#from .verutil import fc_import
# FreeCAD = fc_import("FreeCAD")
# Part = fc_import("FreeCAD.Part")
import FreeCAD import FreeCAD
import Part import Part
@ -34,31 +32,35 @@ class UNITS:
MM = "mm" MM = "mm"
IN = "in" IN = "in"
def importShape(importType,fileName):
"""
Imports a file based on the type (STEP, STL, etc)
:param importType: The type of file that we're importing
:param fileName: THe name of the file that we're importing
"""
#Check to see what type of file we're working with def importShape(importType, fileName):
if importType == ImportTypes.STEP: """
return importStep(fileName) Imports a file based on the type (STEP, STL, etc)
:param importType: The type of file that we're importing
:param fileName: THe name of the file that we're importing
"""
#Loads a STEP file into a CQ object #Check to see what type of file we're working with
if importType == ImportTypes.STEP:
return importStep(fileName)
#Loads a STEP file into a CQ.Workplane object
def importStep(fileName): def importStep(fileName):
""" """
Accepts a file name and loads the STEP file into a cadquery shape Accepts a file name and loads the STEP file into a cadquery shape
:param fileName: The path and name of the STEP file to be imported :param fileName: The path and name of the STEP file to be imported
""" """
#Now read and return the shape #Now read and return the shape
try: try:
rshape = Part.read(fileName) rshape = Part.read(fileName)
r = Shape.cast(rshape) #Make sure that we extract all the solids
#print "loadStep: " + str(r) solids = []
#print "Faces=%d" % cadquery.CQ(r).solids().size() for solid in rshape.Solids:
return cadquery.CQ(r) solids.append(Shape.cast(solid))
except:
raise ValueError("STEP File Could not be loaded") return cadquery.Workplane("XY").newObject(solids)
except:
raise ValueError("STEP File Could not be loaded")

View File

@ -49,10 +49,6 @@
""" """
from cadquery import Vector, BoundBox from cadquery import Vector, BoundBox
import FreeCAD import FreeCAD
#from .verutil import fc_import
#FreeCADPart = fc_import("FreeCAD.Part")
import Part as FreeCADPart import Part as FreeCADPart