1 # Restore presentation parameters and sub-shapes
7 # create a box and a cylinder
8 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
9 cyl = geompy.MakeCylinderRH(100, 300)
11 # create translated box
12 vec = geompy.MakeVectorDXDYDZ(100, 50, 0)
13 tra = geompy.MakeTranslationVector(box, vec)
15 # create partition objects
16 partition1 = geompy.MakePartition([box, cyl])
17 partition2 = geompy.MakePartition([box], [cyl])
18 partition3 = geompy.MakePartition([box], [tra])
21 box.SetColor(SALOMEDS.Color(1,0,0))
22 cyl.SetColor(SALOMEDS.Color(0,1,0))
24 # add objects in the study
25 geompy.addToStudy(box, "Box")
26 geompy.addToStudy(cyl, "Cylinder")
27 geompy.addToStudy(vec, "Vector")
28 geompy.addToStudy(tra, "Translation")
29 geompy.addToStudy(partition1, "Partition_1")
30 geompy.addToStudy(partition2, "Partition_2")
31 geompy.addToStudy(partition3, "Partition_3")
33 # Restore presentation parameters and sub-shapes
34 # different methods can be used to find the sub-shapes in the result:
35 # GetInPlace, GetSame, GetInPlaceByHistory, GetShapesOnShape.
36 # By default, GetInPlace method is used (GEOM.FSM_GetInPlace)
37 geompy.RestoreSubShapes(partition1)
39 geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace)
41 # The list of arguments can be used to avoid restoring all arguments,
42 # but restore only the passed.
43 geompy.RestoreSubShapes(partition3, [tra], GEOM.FSM_GetInPlaceByHistory)
45 # To find sub-shapes in a transformed shape only one method could be
46 # used: pass GEOM.FSM_Transformed for that.
47 # True passed for the last argument, means that the transformed shape
48 # will inherit colour and sub-shapes from its first argument (see above
50 geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True)
52 # Also we could do this directly with method addToStudy:
53 partition4 = geompy.MakePartition([box, tra])
54 geompy.addToStudy(partition4, "Partition_4", True, [],
55 GEOM.FSM_GetInPlaceByHistory, False)