On Fri, 11 Feb 2011 13:45:54 +0100 "Balint Balassa" <balint.bala...@gmx.de> wrote:
> Hi everyone, > I'm trying to boolean cut a profile surface out of another surface. > Unfortunately boolean cut doesn't seem to do anything. Can the cuttingShape > be a kind of surface at all?! > Thanks, > Balint > > > > > from OCC.Utils.DataExchange.STEP import * > from OCC.BRepAlgoAPI import * > from OCC.Display.SimpleGui import * > display, start_display, add_menu, add_function_to_menu = init_display() > > def boolean_cut(shapeToCutFrom, cuttingShape): > try: > cut = BRepAlgoAPI_Cut(shapeToCutFrom, cuttingShape) > print 'can work?', cut.BuilderCanWork() > _error = { > 0: '- Ok', > 1: '- The Object is created but Nothing is Done', > 2: '- Null source shapes is not allowed', > 3: '- Check types of the arguments', > 4: '- Can not allocate memory for the DSFiller', > 5: '- The Builder can not work with such types of > arguments', > 6: '- Unknown operation is not allowed', > 7: '- Can not allocate memory for the Builder', > } > print 'error status:', _error[cut.ErrorStatus()] > cut.RefineEdges() > cut.FuseEdges() > shp = cut.Shape() > cut.Destroy() > return shp > except: > print 'FAILED TO BOOLEAN CUT' > return shapeToCutFrom > > > # STEP IMPORTS: > HubImporter = STEPImporter("hub1.stp") > HubImporter.ReadFile() > shapeList = HubImporter.GetShapes() > hubSurface = shapeList[0] > #display.DisplayShape(hubSurface) > > CutImporter = STEPImporter("cuttingProfile.stp") > CutImporter.ReadFile() > shapeList = CutImporter.GetShapes() > cuttingProfile = shapeList[0] > display.DisplayShape(cuttingProfile) > > > # CUT: > hubWithHole = boolean_cut(hubSurface, cuttingProfile) > display.DisplayShape(hubWithHole) > > start_display() > > -- > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de Hello Balint, Try this code... def cut_face (self): HubImporter = STEPImporter("/home/arch/hub1.stp") HubImporter.read_file() shapeList = HubImporter.get_shapes() hubSurface = shapeList[0] CutImporter = STEPImporter("/home/arch/cuttingProfile.stp") CutImporter.read_file() shapeList = CutImporter.get_shapes() cuttingProfile = shapeList[0] splitter = GEOMAlgo_Splitter(); splitter.AddShape(hubSurface); splitter.AddTool(cuttingProfile); splitter.Perform(); splitter_shape = splitter.Shape(); topo = Topology.Topo( splitter_shape ) topo.number_of_faces() mod_shape = topo.faces().next() self._display.DisplayShape( mod_shape ) good luck! -- Goran Lukic <goranl...@gmail.com> _______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users