def test_read_iges_45_shapes(self): all_shapes = read_iges_file(IGES_45_FACES, return_as_shapes=True, verbosity=True) self.assertEqual(len(all_shapes), 1) topo_explorer = TopologyExplorer(all_shapes[0]) self.assertEqual(topo_explorer.number_of_faces(), 45)
def read_cadfile(self, fileName, disp=True): print(fileName) base_dir = os.path.dirname(fileName) basename = os.path.basename(fileName) rootname, extname = os.path.splitext(fileName) if extname in [".stp", ".step"]: shpe = read_step_file(fileName) elif extname in [".igs", ".iges"]: shpe = read_iges_file(fileName) elif extname in [".stl"]: shpe = read_stl_file(fileName) elif extname in [".brep"]: shpe = TopoDS_Shape() builder = BRep_Builder() breptools_Read(shpe, fileName, builder) elif extname in [".geo"]: stlfile = self.import_geofile(fileName, 0.1) shpe = read_stl_file(stlfile) else: print("Incorrect file index") # sys.exit(0) if disp == True: self.display.DisplayShape(shpe, update=True) return shpe
def readExtGeometry(self): self.shape = TopoDS_Shape extg = self.object.find(self.dict['externalgeometryref']) if extg == None: if self.logging == True: OCXCommon.Message(self.object, 'has no external geometry') else: extfile = str(extg.get(self.dict['externalref']) ) # Relative path to the input ocxfile extfile = extfile.replace('\\', '/') #Fix for UNIX systems gfile = Path(extfile) # Build the full file path file = self.ocxfile.parent for part in gfile.parts: file = file / part filename = file.resolve() format = extg.get('geometryFormat') if filename.is_file(): if format == 'STEP': self.shape = read_step_file(str(filename)) self.done = True elif format == '.igs': # TODO: S3D export must change to 'IGES' self.shape = read_iges_file(str(filename)) self.done = True else: print('Unknown geometry format') else: print(file + ' not exist') return
def convert_iges_handler(file_path, is_bin=False): # 1. read iges file and convert to stl convert_stl_path = file_path + '.stl' shapes = read_iges_file(file_path) write_stl_by_shapes(shapes, convert_stl_path) result = convert_stl_to_draco_gltf(file_path, convert_stl_path, is_bin) if not config['app']['save_convert_temp_file']: clear_file(convert_stl_path) return result
def handler(self, file_path, is_bin): super(IgesModel, self).handler(file_path, is_bin) # read iges file and convert to stl convert_stl_path = file_path + '.stl' try: shapes = read_iges_file(file_path) StlModel.write_by_shapes(shapes, convert_stl_path) result = StlModel.convert_to_draco_gltf(file_path, convert_stl_path, is_bin, True) finally: self.clear_file(convert_stl_path) return result
def build_curve_network(event=None): ''' mimic the curve network surfacing command from rhino ''' print('Importing IGES file...') iges_file = os.path.join('..', 'assets', 'models', 'curve_geom_plate.igs') iges = read_iges_file(iges_file) print('Building geomplate...') topo = TopologyExplorer(iges) edges_list = list(topo.edges()) face = build_geom_plate(edges_list) print('done.') display.EraseAll() display.DisplayShape(edges_list) display.DisplayShape(face) display.FitAll() print('Cutting out of edges...')
def Simulate_raster_from_offset(): path=Generating_Path() path_offset=path[0] path_z_level=path[1] display.EraseAll() stl_shp = read_stl_file('mymodel3.stl') #stl_shp2 = read_stl_file('mymodel2.stl') # for reading IGS files stl_shp2=read_iges_file('mymodel4.igs') all_points=[] hieght=z_max_finder(stl_shp) #making chamber box material_box = BRepPrimAPI_MakeBox(gp_Pnt(-70, -70, 0),130, 130, hieght) display.DisplayShape(stl_shp) #display.DisplayShape(box_shape,color = "BLACK", transparency = 0.7) for i in range(len(path_z_level)-1): my_path=raster_from_offset(-70,-70,65,65,path_z_level[-i-1],10,path_offset[-i-1]) show_path_from_points(my_path) all_points=my_connector(my_path,all_points) simulate(all_points,90,material_box)
def convert_iges_handler(file_path): # 1. read iges file and convert to stl convert_stl_path = file_path + '.stl' shapes = read_iges_file(file_path) write_stl_by_shapes(shapes, convert_stl_path) return convert_stl_to_draco_gltf(file_path, convert_stl_path)
def test_read_iges_file(self): read_iges_file(IGES_SAMPLE_FILE)
##Copyright 2010-2014 Thomas Paviot ([email protected]) ## ##This file is part of pythonOCC. ## ##pythonOCC is free software: you can redistribute it and/or modify ##it under the terms of the GNU Lesser General Public License as published by ##the Free Software Foundation, either version 3 of the License, or ##(at your option) any later version. ## ##pythonOCC is distributed in the hope that it will be useful, ##but WITHOUT ANY WARRANTY; without even the implied warranty of ##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##GNU Lesser General Public License for more details. ## ##You should have received a copy of the GNU Lesser General Public License ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function from OCC.Display.SimpleGui import init_display from OCC.Extend.DataExchange import read_iges_file shapes = read_iges_file('models/surf114.igs') display, start_display, add_menu, add_function_to_menu = init_display() display.DisplayShape(shapes, update=True) start_display()
from OCC.Display.SimpleGui import init_display from OCC.Extend.DataExchange import read_iges_file, read_step_file, read_stl_file shapes = read_iges_file(fileName1) #shapes=read_step_file(fileName1) #shapes=read_stl_file(fileName1) display, start_display, add_menu, add_function_to_menu = init_display() display.DisplayShape(shapes, update=True)
from OCC.Core.TopAbs import * from OCC.Core.TopoDS import TopoDS_Shape, topods from OCC.Core.BRep import BRep_Tool, BRep_Tool_Pnt, BRep_Tool_IsGeometric, BRep_Tool_Parameter, BRep_Tool_Curve from OCC.Core.BRepAdaptor import BRepAdaptor_Curve from OCC.Core.GeomTools import GeomTools_CurveSet from OCC.Core.ShapeAnalysis import * from OCC.Core.GeomAdaptor import * import matplotlib import matplotlib.pyplot as plt REALFIRST = -20000000000000000318057822195198360936721617127890562779562655115495677544340762121626939971713630208 # I don't like this either, mate. shape = read_iges_file('tubes_splined.iges') #print(dir(shape.Location())) #print(shape.Location().Identity()) #print(dir(GeomTools_CurveSet())) topExp = TopExp_Explorer() topExp.Init(shape, TopAbs_EDGE) def print_vertex(va): pt = BRep_Tool().Pnt(va) print("%.3f, %.3f, %.3f" % (pt.Coord(1), pt.Coord(2), pt.Coord(3))) return [pt.Coord(1), pt.Coord(2), pt.Coord(3)]
wires.pop(index_max) wire_dict['inner'] = wires plane_outer_normal = get_direction_of_wire(wire_dict['outer']) if plane_outer_normal.Z() < 0: wire_dict['outer'].Reverse() make_face = OCC_Brep_Builder.BRepBuilderAPI_MakeFace(wire_dict['outer']) for wire_inner in wire_dict['inner']: plane_inner_normal = get_direction_of_wire(wire_inner) if plane_inner_normal.Z() > 0: wire_inner.Reverse() make_face.Add(wire_inner) make_face.Build() return make_face.Shape() from src.base import plotocc, gen_ellipsoid, set_loc, spl_face from OCC.Extend.DataExchange import write_iges_file, read_iges_file box = read_iges_file("./box.iges") pln = load_section_from_iges("./box.iges") obj = plotocc() obj.show_axs_pln(scale=50) obj.display.DisplayShape(box, transparency=0.9) obj.display.DisplayShape(pln) obj.show()
def import_to_IGES(self, fileName): iges_shp = read_iges_file(fileName) return iges_shp
##Copyright 2010-2014 Thomas Paviot ([email protected]) ## ##This file is part of pythonOCC. ## ##pythonOCC is free software: you can redistribute it and/or modify ##it under the terms of the GNU Lesser General Public License as published by ##the Free Software Foundation, either version 3 of the License, or ##(at your option) any later version. ## ##pythonOCC is distributed in the hope that it will be useful, ##but WITHOUT ANY WARRANTY; without even the implied warranty of ##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##GNU Lesser General Public License for more details. ## ##You should have received a copy of the GNU Lesser General Public License ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function from OCC.Display.SimpleGui import init_display from OCC.Extend.DataExchange import read_iges_file shapes = read_iges_file('../assets/models/surf114.igs') display, start_display, add_menu, add_function_to_menu = init_display() display.DisplayShape(shapes, update=True) start_display()