Version: 8.3.0
Home
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
geomBuilder Python module

Modules

 Publishing results in SALOME study
 
 Auxiliary data structures and methods
 
 All package methods, grouped by their purpose
 

Detailed Description

By default, all functions of geomBuilder Python module do not publish resulting geometrical objects. This can be done in the Python script by means of addToStudy() or addToStudyInFather() functions.

However, it is possible to publish result data in the study automatically. For this, almost each function of geomBuilder class has an additional theName parameter (None by default). As soon as non-empty string value is passed to this parameter, the result object is published in the study automatically.

For example, consider the following Python script:

1 import salome
2 from salome.geom import geomBuilder
3 geompy = geomBuilder.New(salome.myStudy)
4 box = geompy.MakeBoxDXDYDZ(100, 100, 100) # box is not published in the study yet
5 geompy.addToStudy(box, "box") # explicit publishing

Last two lines can be replaced by one-line instruction:

1 box = geompy.MakeBoxDXDYDZ(100, 100, 100, theName="box") # box is published in the study with "box" name

... or simply

1 box = geompy.MakeBoxDXDYDZ(100, 100, 100, "box") # box is published in the study with "box" name

Note, that some functions produce more than one geometrical objects. For example, GetNonBlocks() function returns two objects: group of all non-hexa solids and group of all non-quad faces. For such functions it is possible to specify separate names for results.

For example

1 # create and publish cylinder
2 cyl = geompy.MakeCylinderRH(100, 100, "cylinder")
3 # get non blocks from cylinder
4 g1, g2 = geompy.GetNonBlocks(cyl, theName="nonblock")

Above example will publish both result compounds (first with non-hexa solids and second with non-quad faces) as two items, both named "nonblock". However, if second command is invoked as

1 g1, g2 = geompy.GetNonBlocks(cyl, theName=("nonhexa", "nonquad"))

... the first compound will be published with "nonhexa" name, and second will be named "nonquad".

Automatic publication of all results can be also enabled/disabled by means of the function addToStudyAuto(). The automatic publishing is managed by the numeric parameter passed to this function:

When automatic publishing is enabled, you even do not need to pass theName parameter to the functions creating objects, instead default names will be used. However, you can always change the behavior, by passing explicit name to the theName parameter and it will be used instead default one. The publishing of the collections of objects will be done according to the above mentioned rules (maximum allowed number of sub-shapes).

For example:

1 import salome
2 from salome.geom import geomBuilder
3 geompy = geomBuilder.New(salome.myStudy)
4 geompy.addToStudyAuto() # enable automatic publication
5 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
6 # the box is created and published in the study with default name
7 geompy.addToStudyAuto(5) # set max allowed number of sub-shapes to 5
8 vertices = geompy.SubShapeAll(box, geomBuilder.ShapeType['VERTEX'])
9 # only 5 first vertices will be published, with default names
10 print len(vertices)
11 # note, that result value still containes all 8 vertices
12 geompy.addToStudyAuto(-1) # disable automatic publication

This feature can be used, for example, for debugging purposes.

Note
  • Use automatic publication feature with caution. When it is enabled, any function of geomBuilder class publishes the results in the study, that can lead to the huge size of the study data tree. For example, repeating call of SubShapeAll() command on the same main shape each time will publish all child objects, that will lead to a lot of duplicated items in the study.
  • Sub-shapes are automatically published as child items of the parent main shape in the study if main shape was also published before. Otherwise, sub-shapes are published as top-level objects.
  • Some functions of geomBuilder class do not have theName parameter (and, thus, do not support automatic publication). For example, some transformation operations like TranslateDXDYDZ(). Refer to the documentation to check if some function has such possibility.

It is possible to customize the representation of the geometrical data in the data tree; this can be done by using folders. A folder can be created in the study tree using function NewFolder() (by default it is created under the "Geometry" root object). As soon as folder is created, any published geometry object can be moved into it.

For example:

1 import salome
2 from salome.geom import geomBuilder
3 geompy = geomBuilder.New(salome.myStudy)
4 box = geompy.MakeBoxDXDYDZ(100, 100, 100, "Box")
5 # the box was created and published in the study
6 folder = geompy.NewFolder("Primitives")
7 # an empty "Primitives" folder was created under default "Geometry" root object
8 geompy.PutToFolder(box, folder)
9 # the box was moved into "Primitives" folder

Subfolders are also can be created by specifying another folder as a parent:

1 subfolder = geompy.NewFolder("3D", folder)
2 # "3D" folder was created under "Primitives" folder
Note
  • Folder container is just a representation layer object that deals with already published objects only. So, any geometry object should be published in the study (for example, with addToStudy() function) BEFORE moving it into any existing folder.
  • PutToFolder() function does not change physical position of geometry object in the study tree, it only affects on the representation of the data tree.
  • It is impossible to publish geometry object using any folder as father.