1 # Copyright (C) 2014-2021 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from salome.shaper import model
21 from SketchAPI import *
25 partSet = model.moduleDocument()
27 ###===========Test with chamfer on face=========================================================
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
34 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
37 Chamfer_1 = model.addChamfer(Part_1_doc, [model.selection("FACE", "Box_1_1/Left")], True, 2, 2, keepSubResults = True)
40 Filters = model.filters(Part_1_doc, [model.addFilter(name = "FeatureEdges", args = [ 5.0 ])])
44 ResultChamfer_1_1 = Chamfer_1.result().resultSubShapePair()[0]
45 exp = GeomAPI_ShapeExplorer(ResultChamfer_1_1.shape(), GeomAPI_Shape.EDGE)
47 Reference[model.selection(ResultChamfer_1_1, exp.current())] = True
49 model.checkFilter(Part_1_doc, model, Filters, Reference)
53 ###===========Test with fillet on solide===========================================================
56 Part_2 = model.addPart(partSet)
57 Part_2_doc = Part_2.document()
60 Box_2 = model.addBox(Part_2_doc, 10, 10, 10)
63 Fillet_1_objects_4 = [model.selection("FACE", "Box_1_1/Left"),
64 model.selection("FACE", "Box_1_1/Front"),
65 model.selection("FACE", "Box_1_1/Top"),
66 model.selection("FACE", "Box_1_1/Right"),
67 model.selection("FACE", "Box_1_1/Bottom")]
68 Fillet_1 = model.addFillet(Part_2_doc, Fillet_1_objects_4, 2, keepSubResults = True)
73 Filters = model.filters(Part_2_doc, [model.addFilter(name = "FeatureEdges", args = [ 5.0 ])])
77 ###===========Test with Chamfer by an angle of 43° and filters with angle 30 and 50 ===========
79 ResultFillet_1_1 = Fillet_1.result().resultSubShapePair()[0]
80 exp = GeomAPI_ShapeExplorer(ResultFillet_1_1.shape(), GeomAPI_Shape.EDGE)
82 Reference[model.selection(ResultFillet_1_1, exp.current())] = False
84 model.checkFilter(Part_2_doc, model, Filters, Reference)
87 Part_3 = model.addPart(partSet)
88 Part_3_doc = Part_3.document()
91 Box_3 = model.addBox(Part_3_doc, 10, 10, 10)
94 Chamfer_1_objects = [model.selection("FACE", "Box_1_1/Left"),
95 model.selection("FACE", "Box_1_1/Front"),
96 model.selection("FACE", "Box_1_1/Top"),
97 model.selection("FACE", "Box_1_1/Right"),
98 model.selection("FACE", "Box_1_1/Bottom")]
99 Chamfer_2 = model.addChamfer(Part_3_doc, Chamfer_1_objects, False, 2, 43, keepSubResults = True)
104 Filters = model.filters(Part_3_doc, [model.addFilter(name = "FeatureEdges", args = [ 30.0 ])])
108 ResultChamfer_2_1 = Chamfer_2.result().resultSubShapePair()[0]
109 exp = GeomAPI_ShapeExplorer(ResultChamfer_2_1.shape(), GeomAPI_Shape.EDGE)
111 Reference[model.selection(ResultChamfer_2_1, exp.current())] = True
113 model.checkFilter(Part_3_doc, model, Filters, Reference)
116 Filters = model.filters(Part_3_doc, [model.addFilter(name = "FeatureEdges", args = [ 50.0 ])])
120 exp = GeomAPI_ShapeExplorer(ResultChamfer_2_1.shape(), GeomAPI_Shape.EDGE)
122 Reference[model.selection(ResultChamfer_2_1, exp.current())] = False
124 model.checkFilter(Part_3_doc, model, Filters, Reference)