def test_import_badformat(self): filename = 'test-files/bad_format.step' # file exists, but is not a valid STEP file thing = Part.importer('step')(filename) # exception not raised before object is formed with self.assertRaises(ValueError): with suppress_stdout_stderr(): thing.local_obj
def test_import_unicode(self): filename = u'test-files/cube.step' with suppress_stdout_stderr(): cube = Part.importer('step')(filename) self.assertEqual(type(cube).__name__, 'cube_step') self.assertAlmostEqual(cube.bounding_box.xmin, -0.5) self.assertAlmostEqual(cube.bounding_box.xmax, 0.5)
def test_multipart_part(self): # When imported as a Part, geometry is unioned together filename = 'test-files/red_cube_blue_cylinder.step' with suppress_stdout_stderr(): thing = Part.importer('step')(filename) # cylinder {5 < x < 15}, box {-10 < x < 0} # combined they should be {-10 < x < 15} self.assertAlmostEqual(thing.bounding_box.xmin, -10) self.assertAlmostEqual(thing.bounding_box.xmax, 15)
def test_import_nofile(self): filename = 'test-files/noexist.step' with self.assertRaises(ValueError): # exception raised before Part.importer('step')(filename)
def test_mangle_numberstart(self): filename = 'test-files/0123_noexist.step' part = Part.importer('step')(filename) self.assertEqual(type(part).__name__, '_0123_noexist_step')
def test_import(self): filename = 'test-files/cube.step' with suppress_stdout_stderr(): cube = Part.importer('step')(filename) self.assertAlmostEqual(cube.bounding_box.xmin, -0.5) self.assertAlmostEqual(cube.bounding_box.xmax, 0.5)
from cqparts import Part Part.importer('step')('module.step').exporter('gltf')('module.gltf')