<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN"> <html> <head> <title>Groups</title> <meta http-equiv="content-type" content="text/html; charset=windows-1252"> <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"> <link rel="stylesheet" href="default_ns.css"><script type="text/javascript" language="JavaScript" title="WebHelpSplitCss"> <!-- if (navigator.appName !="Netscape") { document.write("<link rel='stylesheet' href='default.css'>");} //--> </script> <style type="text/css"> <!-- p.whs1 { font-family:'Lucida Console' , monospace; } --> </style><script type="text/javascript" language="JavaScript" title="WebHelpInlineScript"> <!-- function reDo() { if (innerWidth != origWidth || innerHeight != origHeight) location.reload(); } if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) { origWidth = innerWidth; origHeight = innerHeight; onresize = reDo; } onerror = null; //--> </script> <style type="text/css"> <!-- div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; } p.WebHelpNavBar { text-align:right; } --> </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script> <script type="text/javascript" language="javascript" src="whver.js"></script> <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script> <script type="text/javascript" language="javascript1.2" src="whutils.js"></script> <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script> <script type="text/javascript" language="javascript1.2"> <!-- if (window.gbWhTopic) { if (window.setRelStartPage) { addTocInfo("Geometry module\nTUI Scripts\nCreating Geometric Objects\nWorking with Groups"); addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif"); addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif"); } if (window.setRelStartPage) { setRelStartPage("index.htm"); autoSync(1); sendSyncInfo(); sendAveInfoOut(); } } else if (window.gbIE4) document.location.reload(); //--> </script> </head> <body><script type="text/javascript" language="javascript1.2"> <!-- if (window.writeIntopicBar) writeIntopicBar(4); //--> </script> <h1>Groups</h1> <h3>Creation of a group</h3> <p class="whs1">import geompy</p> <p class="whs1">import salome</p> <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p> <p> </p> <p># create two vertices</p> <p class="whs1">p0 = geompy.MakeVertex(0. , 0. , 0. )</p> <p class="whs1">p200 = geompy.MakeVertex(200., 200., 200.)</p> <p> </p> <p># create a box from two points</p> <p class="whs1">Box = geompy.MakeBoxTwoPnt(p0, p200)</p> <p> </p> <p># create a group from the faces of the box</p> <p class="whs1">group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])</p> <p> </p> <p># add objects to the group</p> <p class="whs1">SubFaceList = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])</p> <p class="whs1">for i in [0, 3, 5] :</p> <p class="whs1"> FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])</p> <p class="whs1"> geompy.AddObject(group, FaceID)</p> <p> </p> <p># add all selected shapes from the list to the group </p> <p># (the program doesn't raise error, if some shapes are already included)</p> <p class="whs1">geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]])</p> <p> </p> <p># remove an object from the group</p> <p class="whs1">geompy.RemoveObject(group, FaceID)</p> <p> </p> <p># remove all selected shapes from the group </p> <p># (the program doesn't raise error, if some shapes are not included)</p> <p class="whs1">geompy.DifferenceList(group, [SubFaceList[2], SubFaceList[3], SubFaceList[4]])</p> <p class="whs1">id_group1 = geompy.addToStudy(group, "Group1")</p> <p> </p> <p># display the contents of the group</p> <p class="whs1">gg.createAndDisplayGO(id_group1)</p> <p><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span> </p> <h3>Adding an object to the group.</h3> <p class="whs1">import geompy</p> <p class="whs1">import salome</p> <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p> <p> </p> <p># create two vertices</p> <p class="whs1">p0 = geompy.MakeVertex(0. , 0. , 0. )</p> <p class="whs1">p200 = geompy.MakeVertex(200., 200., 200.)</p> <p> </p> <p># create a box from two points</p> <p class="whs1">Box = geompy.MakeBoxTwoPnt(p0, p200)</p> <p> </p> <p># create a group from the faces of the box</p> <p class="whs1">group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])</p> <p> </p> <p># add objects to the group</p> <p class="whs1">SubFaceList = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])</p> <p class="whs1">for i in [0, 3, 5] :</p> <p class="whs1"> FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])</p> <p class="whs1"> geompy.AddObject(group, FaceID)</p> <p class="whs1">id_group1 = geompy.addToStudy(group, "Group1")</p> <p> </p> <p># display the contents of the group</p> <p class="whs1">gg.createAndDisplayGO(id_group1)</p> <p><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span> </p> <p> </p> <h3>Removing an object from the group</h3> <p class="whs1">import geompy</p> <p class="whs1">import salome</p> <p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p> <p> </p> <p># create two vertices</p> <p class="whs1">p0 = geompy.MakeVertex(0. , 0. , 0. )</p> <p class="whs1">p200 = geompy.MakeVertex(200., 200., 200.)</p> <p> </p> <p># create a box from two points</p> <p class="whs1">Box = geompy.MakeBoxTwoPnt(p0, p200)</p> <p> </p> <p># create a group from the faces of the box</p> <p class="whs1">group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])</p> <p> </p> <p># add objects to the group</p> <p class="whs1">SubFaceList = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])</p> <p class="whs1">for i in [0, 3, 5] :</p> <p class="whs1"> FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])</p> <p class="whs1"> geompy.AddObject(group, FaceID)</p> <p> </p> <p># add all selected shapes from the list to the group </p> <p># (the program doesn't raise errors, if some shapes are already included)</p> <p class="whs1">geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]])</p> <p> </p> <p># remove an object from the group</p> <p class="whs1">geompy.RemoveObject(group, FaceID)</p> <p class="whs1">id_group1 = geompy.addToStudy(group, "Group1")</p> <p> </p> <p># display the contents of the group</p> <p class="whs1">gg.createAndDisplayGO(id_group1)</p> <p><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <script type="text/javascript" language="javascript1.2"> <!-- if (window.writeIntopicBar) writeIntopicBar(0); //--> </script> </body> </html>