Documentation of the programming interface (API)

This section describes the python packages and modules of the salome.geom python package. The main part is generated from the code documentation included in source python files.

salome.geom – Package containing the GEOM python utilities

geomtools – Tools to access GEOM engine and objects

This module provides tools to facilitate the use of geom engine and geom objects in Salome.

class salome.geom.geomtools.GeomStudyTools(studyEditor=None)

This class provides several methods to manipulate geom objects in Salome study. The parameter studyEditor defines a StudyEditor object used to access the study. If None, the method returns a StudyEditor object on the current study.

editor

This instance attribute contains the underlying StudyEditor object. It can be used to access the study but the attribute itself should not be modified.

displayShapeByName(shapeName, color=None)

Display the geometrical shape whose name in the study is shapeName.

Parameters:
  • shapeName (string) – name of the geometrical shape
  • color (tuple (triplet)) – RGB components of the color of the shape
Returns:

True if the shape was found, False otherwise

salome.geom.geomtools.getGeompy(studyId=None)

Return an object behaving exactly like geompy module, except that it is associated with the study studyId. If studyId is None, return a pseudo geompy object for the current study.

structelem – Structural elements package

This package is used to create and visualize structural elements. It contains three modules:

A structural element is a set of geometric shapes (beams, grids, etc.) that are built semi-automatically along a set of geometric primitives (edges for instance). They are visualized with the same color as their base primitives in the geom viewer.

Structural elements are generally created by the StructuralElementManager class, from a list of commands describing the element to create.

Example:

commandList = [('VisuPoutreGenerale', {'Group_Maille': 'Edge_1'}),
               ('VisuBarreCercle',
                {'R': 30, 'Group_Maille': 'Edge_1', 'EP': 15}),
              ]

structElemManager = StructuralElementManager()
elem = structElemManager.createElement(commandList)
elem.display()
salome.sg.updateObjBrowser(True)
class salome.geom.structelem.StructuralElementManager(studyId=None)

This class manages the structural elements in the study. It is used to create a new structural element from a list of commands. The parameter studyId defines the ID of the study in which the manager will create structural elements. If it is None or not specified, it will use the ID of the current study as defined by salome.kernel.studyedit.getActiveStudyId() function.

createElement(commandList)

Create a structural element from the list of commands commandList. Each command in this list represent a part of the structural element, that is a specific kind of shape (circular beam, grid, etc.) associated with one or several geometrical primitives. A command must be a tuple. The first element is the structural element part class name or alias name. The second element is a dictionary containing the parameters describing the part. Valid class names are all the classes defined in the module parts and inheriting class StructuralElementPart. There are also several aliases for backward compatibility. Here is the complete list:

The valid parameters in the dictionary depend on the type of the structural element part, and are detailed in the documentation of the corresponding class. The only parameter that is common to all the classes is “MeshGroups” (that can also be named “Group_Maille”). It defines the name of the geometrical object(s) in the study that will be used as primitives to build the structural element part. This parameter can be either a list of strings or a single string with comma separated names.

class salome.geom.structelem.StructuralElement(studyId=None)

This class represents a structural element, i.e. a set of geometrical objects built along geometrical primitives. The parameter studyId defines the ID of the study that will contain the structural element. If it is None or not specified, the constructor will use the ID of the active study as defined by salome.kernel.studyedit.getActiveStudyId() function. Structural elements are normally created by the class StructuralElementManager, so this class should not be instantiated directly in the general case.

addOrientation(meshGroup, orientParams)

Add orientation information to a part in the structural element. This information will be used to build the corresponding markers.

Parameters:
  • meshGroup (string) – the name of a geometrical primitive. The orientation information will apply to the structural element part built along this primitive.
  • orientParams (dictionary) – parameters defining the orientation of the structural element part. Those parameters are detailed in class Orientation1D.
addPart(newpart)

Add a part to the structural element.

Parameters:newpart (StructuralElementPart) – the part to add to the structural element.
build()

Build the geometric shapes and the markers corresponding to the different parts of the structural element, and add them to the study.

display()

Display the structural element in the geom view.

static showElement(theSObject)

Display the structural element corresponding to the study object theSObject

structelem.parts – Structural element parts

This module defines the different structural element parts. It is used to build the geometric shapes of the structural elements. It should not be used directly in the general case. Structural elements should be created by the class StructuralElementManager.

class salome.geom.structelem.parts.Beam(studyId, groupName, groupGeomObj, parameters, name='Beam')

Bases: salome.geom.structelem.parts.StructuralElementPart

This class is an “abstract” class for all 1D structural element parts. It should not be instantiated directly. See class StructuralElementPart for the description of the parameters.

class salome.geom.structelem.parts.CircularBeam(studyId, groupName, groupGeomObj, parameters, name='Beam')

Bases: salome.geom.structelem.parts.Beam

This class defines a beam with a circular section. It can be full or hollow, and its radius and thickness can vary from one end of the beam to the other. The valid parameters for circular beams are:

  • “R1” or “R”: radius at the first end of the beam.
  • “R2” or “R”: radius at the other end of the beam.
  • “EP1” or “EP” (optional): thickness at the first end of the beam. If not specified or equal to 0, the beam is considered full.
  • “EP2” or “EP” (optional): thickness at the other end of the beam. If not specified or equal to 0, the beam is considered full.

See class StructuralElementPart for the description of the other parameters.

class salome.geom.structelem.parts.GeneralBeam(studyId, groupName, groupGeomObj, parameters, name='Beam')

Bases: salome.geom.structelem.parts.Beam

This class defines a beam with a generic section. It is represented only as the underlying wire. See class StructuralElementPart for the description of the parameters.

class salome.geom.structelem.parts.Grid(studyId, groupName, groupGeomObj, parameters, name='Grid')

Bases: salome.geom.structelem.parts.StructuralElementPart2D

This class defines a grid. A grid is represented by a 2D face patterned with small lines in the main direction of the grid frame. The valid parameters for grids are:

  • “Excentre”: offset of the grid from the base face.
  • “angleAlpha”: angle used to build the markers (see class Orientation2D)
  • “angleBeta”: angle used to build the markers (see class Orientation2D)
  • “Vecteur”: vector used instead of the angles to build the markers (see class Orientation2D)
  • “origAxeX”: X coordinate of the origin of the axis used to determine the orientation of the frame in the case of a cylindrical grid.
  • “origAxeY”: Y coordinate of the origin of the axis used to determine the orientation of the frame in the case of a cylindrical grid.
  • “origAxeZ”: Z coordinate of the origin of the axis used to determine the orientation of the frame in the case of a cylindrical grid.
  • “axeX”: X coordinate of the axis used to determine the orientation of the frame in the case of a cylindrical grid.
  • “axeY”: Y coordinate of the axis used to determine the orientation of the frame in the case of a cylindrical grid.
  • “axeZ”: Z coordinate of the axis used to determine the orientation of the frame in the case of a cylindrical grid.

See class StructuralElementPart for the description of the other parameters.

exception salome.geom.structelem.parts.InvalidParameterError(groupName, expression, minValue, value)

Bases: exceptions.Exception

This exception is raised when an invalid parameter is used to build a structural element part.

class salome.geom.structelem.parts.RectangularBeam(studyId, groupName, groupGeomObj, parameters, name='Beam')

Bases: salome.geom.structelem.parts.Beam

This class defines a beam with a rectangular section. It can be full or hollow, and its dimensions can vary from one end of the beam to the other. The valid parameters for rectangular beams are:

  • “HY1”, “HY”, “H1” or “H”: width at the first end of the beam.
  • “HZ1”, “HZ”, “H1” or “H”: height at the first end of the beam.
  • “HY2”, “HY”, “H2” or “H”: width at the other end of the beam.
  • “HZ2”, “HZ”, “H2” or “H”: height at the other end of the beam.
  • “EPY1”, “EPY”, “EP1” or “EP” (optional): thickness in the width direction at the first end of the beam. If not specified or equal to 0, the beam is considered full.
  • “EPZ1”, “EPZ”, “EP1” or “EP” (optional): thickness in the height direction at the first end of the beam. If not specified or equal to 0, the beam is considered full.
  • “EPY2”, “EPY”, “EP2” or “EP” (optional): thickness in the width direction at the other end of the beam. If not specified or equal to 0, the beam is considered full.
  • “EPZ2”, “EPZ”, “EP2” or “EP” (optional): thickness in the height direction at the other end of the beam. If not specified or equal to 0, the beam is considered full.

See class StructuralElementPart for the description of the other parameters.

class salome.geom.structelem.parts.StructuralElementPart(studyId, groupName, groupGeomObj, parameters, name='StructElemPart')

This class is the base class for all structural element parts. It should not be instantiated directly (consider it as an “abstract” class).

Parameters:
  • studyId (integer) – the ID of the study in which the part is created.
  • groupName (string) – the name of the underlying geometrical primitive in the study.
  • groupGeomObj (GEOM object) – the underlying geometrical primitive.
  • parameters (dictionary) – parameters defining the structural element (see subclasses for details).
  • name (string) – name to use for the created object in the study.
addOrientation(orientParams)

Add orientation information to the structural element part. See class Orientation1D for the description of the parameters.

build()

Build the geometric shapes and the markers corresponding to the structural element part in the study studyId.

class salome.geom.structelem.parts.StructuralElementPart2D(studyId, groupName, groupGeomObj, parameters, name='StructuralElementPart2D')

Bases: salome.geom.structelem.parts.StructuralElementPart

This class is an “abstract” class for all 2D structural element parts. It should not be instantiated directly. See class StructuralElementPart for the description of the parameters.

class salome.geom.structelem.parts.SubShapeID(mainShape, id)

This class enables the use of subshapes in sets or as dictionary keys. It implements __eq__ and __hash__ methods so that subshapes with the same CORBA object mainShape and the same id are considered equal.

getObj(geom)

Return the subshape (GEOM object). geom is a pseudo-geompy object used to find the geometrical object.

class salome.geom.structelem.parts.ThickShell(studyId, groupName, groupGeomObj, parameters, name='ThickShell')

Bases: salome.geom.structelem.parts.StructuralElementPart2D

This class defines a shell with a given thickness. It can be shifted from the base face. The valid parameters for thick shells are:

  • “Epais”: thickness of the shell.
  • “Excentre”: offset of the shell from the base face.
  • “angleAlpha”: angle used to build the markers (see class Orientation2D)
  • “angleBeta”: angle used to build the markers (see class Orientation2D)
  • “Vecteur”: vector used instead of the angles to build the markers (see class Orientation2D)

See class StructuralElementPart for the description of the other parameters.

salome.geom.structelem.parts.VisuBarreCercle(studyId, groupName, groupGeomObj, parameters, name='BARRE')

Alias for class CircularBeam.

salome.geom.structelem.parts.VisuBarreGenerale(studyId, groupName, groupGeomObj, parameters, name='BARRE')

Alias for class GeneralBeam.

salome.geom.structelem.parts.VisuBarreRectangle(studyId, groupName, groupGeomObj, parameters, name='BARRE')

Alias for class RectangularBeam.

salome.geom.structelem.parts.VisuCable(studyId, groupName, groupGeomObj, parameters, name='CABLE')

Alias for class CircularBeam.

salome.geom.structelem.parts.VisuCoque(studyId, groupName, groupGeomObj, parameters, name='COQUE')

Alias for class ThickShell.

salome.geom.structelem.parts.VisuGrille(studyId, groupName, groupGeomObj, parameters, name='GRILLE')

Alias for class Grid.

salome.geom.structelem.parts.VisuPoutreCercle(studyId, groupName, groupGeomObj, parameters, name='POUTRE')

Alias for class CircularBeam.

salome.geom.structelem.parts.VisuPoutreGenerale(studyId, groupName, groupGeomObj, parameters, name='POUTRE')

Alias for class GeneralBeam.

salome.geom.structelem.parts.VisuPoutreRectangle(studyId, groupName, groupGeomObj, parameters, name='POUTRE')

Alias for class RectangularBeam.

structelem.orientation – Structural element orientation

This module is used to compute the orientation of the different parts in a structural element and to build the corresponding markers (trihedrons).

class salome.geom.structelem.orientation.Orientation1D

This class is used to compute the orientation of 1D elements and to build the corresponding markers.

addParams(params)

Add orientation parameters. params is a dictionary containing one or several orientation parameters. The valid parameters are:

  • “VECT_Y”: Triplet defining the local Y axis (the X axis is the main direction of the 1D element).
  • “ANGL_VRIL”: Angle of rotation along the X axis to define the local coordinate system.

The parameters can be specified several times. In this case, only the first “VECT_Y” is taken into account, and the values of “ANGL_VRIL” are added to obtain the total rotation angle.

buildMarker(geom, center, vecX)

Create a marker with origin center and X axis vecX. geom is the pseudo-geompy object used to build the geometric shapes.

getVecYZ(geom, center, vecX)

Get the vectors Y and Z for the LCS with origin center and X axis vecX. geom is the pseudo-geompy object used to build the geometric shapes.

class salome.geom.structelem.orientation.Orientation2D(alpha, beta, vect)

This class is used to compute the orientation of 2D elements and to build the corresponding markers. Angles alpha and beta are used to determine the local coordinate system for the 2D element. If vect is not None, it is used instead of alpha and beta.

buildMarker(geom, center, normal, warnings=True)

Create a marker with origin center and normal as Z axis. The other axes are computed using the parameters alpha and beta of the Orientation2D instance. geom is the pseudo-geompy object used to build the geometric shapes. warnings can be used to enable or disable the logging of warning messages.