X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Fsalome%2Fexamples%2Fbasic_operations_ex03.py;fp=doc%2Fsalome%2Fexamples%2Fbasic_operations_ex03.py;h=39b1dd22b24a1c008861a9f0f56ead7928a4c74f;hb=465e84c52edb243fa36d581abc659b1c97156c64;hp=0000000000000000000000000000000000000000;hpb=eb33929a623da3858f8105e54f0834f8393f5414;p=modules%2Fgeom.git diff --git a/doc/salome/examples/basic_operations_ex03.py b/doc/salome/examples/basic_operations_ex03.py new file mode 100644 index 000000000..39b1dd22b --- /dev/null +++ b/doc/salome/examples/basic_operations_ex03.py @@ -0,0 +1,55 @@ +# Restore presentation parameters and sub-shapes + +import geompy +import GEOM +import SALOMEDS + +# create a box and a cylinder +box = geompy.MakeBoxDXDYDZ(200, 200, 200) +cyl = geompy.MakeCylinderRH(100, 300) + +# create translated box +vec = geompy.MakeVectorDXDYDZ(100, 50, 0) +tra = geompy.MakeTranslationVector(box, vec) + +# create partition objects +partition1 = geompy.MakePartition([box, cyl]) +partition2 = geompy.MakePartition([box], [cyl]) +partition3 = geompy.MakePartition([box], [tra]) + +# set colours +box.SetColor(SALOMEDS.Color(1,0,0)) +cyl.SetColor(SALOMEDS.Color(0,1,0)) + +# add objects in the study +geompy.addToStudy(box, "Box") +geompy.addToStudy(cyl, "Cylinder") +geompy.addToStudy(vec, "Vector") +geompy.addToStudy(tra, "Translation") +geompy.addToStudy(partition1, "Partition_1") +geompy.addToStudy(partition2, "Partition_2") +geompy.addToStudy(partition3, "Partition_3") + +# Restore presentation parameters and sub-shapes +# different methods can be used to find the sub-shapes in the result: +# GetInPlace, GetSame, GetInPlaceByHistory, GetShapesOnShape. +# By default, GetInPlace method is used (GEOM.FSM_GetInPlace) +geompy.RestoreSubShapes(partition1) + +geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace) + +# The list of arguments can be used to avoid restoring all arguments, +# but restore only the passed. +geompy.RestoreSubShapes(partition3, [tra], GEOM.FSM_GetInPlaceByHistory) + +# To find sub-shapes in a transformed shape only one method could be +# used: pass GEOM.FSM_Transformed for that. +# True passed for the last argument, means that the transformed shape +# will inherit colour and sub-shapes from its first argument (see above +# MakeTranslation). +geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True) + +# Also we could do this directly with method addToStudy: +partition4 = geompy.MakePartition([box, tra]) +geompy.addToStudy(partition4, "Partition_4", True, [], + GEOM.FSM_GetInPlaceByHistory, False)