importShape in importers.py was not returning anything.

This commit is contained in:
Jeremy Wright 2014-08-18 15:50:07 -04:00
parent ceadc87bde
commit 8994493b7b
3 changed files with 20 additions and 13 deletions

View File

@ -637,6 +637,14 @@ class CQ(object):
"""
exporters.exportSVG(self,fileName)
def importStep(self,fileName):
"""
Reads and imports a solid(s) from a STEP file
:param fileName: The location and name of the STEP file to load
"""
importers.importStep(self, fileName)
def rotateAboutCenter(self,axisEndPoint,angleDegrees):
"""
Rotates all items on the stack by the specified angle, about the specified axis

View File

@ -41,7 +41,7 @@ def importShape(importType,fileName):
#Check to see what type of file we're working with
if importType == ImportTypes.STEP:
importStep(fileName)
return importStep(fileName)
#Loads a STEP file into a CQ object
def importStep(fileName):
@ -51,16 +51,12 @@ def importStep(fileName):
"""
#Now read and return the shape
# try:
rshape = Part.read(fileName)
try:
rshape = Part.read(fileName)
r = Shape.cast(rshape)
#print "loadStep: " + str(r)
#print "Faces=%d" % cadquery.CQ(r).solids().size()
return cadquery.CQ(r)
# except:
# raise ValueError("STEP File Could not be loaded")
if __name__ == '__main__':
import unittest
unittest.main()
r = Shape.cast(rshape)
#print "loadStep: " + str(r)
#print "Faces=%d" % cadquery.CQ(r).solids().size()
return cadquery.CQ(r)
except:
raise ValueError("STEP File Could not be loaded")

View File

@ -35,6 +35,9 @@ class TestImporters(BaseTest):
# Reimport the shape from the new STEP file
importedShape = importers.importShape(importType,fileName)
#Check to make sure we got a shape back
if not importedShape.ShapeType:
raise TypeError("Wrong type imported from STEP file.")
def testSTEP(self):
"""
Tests STEP file import