# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2010-2022 CEA/DEN, EDF R&D, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# Helper functions to add/remove a geometrical shape in/from the study
# ======================================================================
-def addToStudy(study,shape,shapeName,folderName=None):
+def addToStudy(shape,shapeName,folderName=None):
"""
Add a GEOM shape in the study. It returns the associated entry
that corresponds to the identifier of the entry in the study. This
created in the Geometry part of the study, and the shape study
object is stored in this folder of the study.
"""
- studyId = study._get_StudyId()
- geompy = geomtools.getGeompy(studyId)
+ geompy = geomtools.getGeompy()
if folderName is None:
# Insert the shape in the study by the standard way
# A folder name has been specified to embed this shape. Find
# or create a folder with this name in the Geometry study, and
# then store the shape in this folder.
- studyEditor = getStudyEditor(studyId)
+ studyEditor = getStudyEditor()
geomStudyFolder = studyEditor.findOrCreateComponent("GEOM")
shapeStudyFolder = studyEditor.findOrCreateItem(geomStudyFolder,folderName)
return entry
-def removeFromStudy(study,shapeStudyEntry):
+def removeFromStudy(shapeStudyEntry):
"""
This removes the specified entry from the study. Note that this
operation does not destroy the underlying GEOM object, neither
erase the drawing in the viewer.
The underlying GEOM object is returned (so that it can be destroyed)
"""
- studyId = study._get_StudyId()
shape = IDToObject(shapeStudyEntry)
studyObject = IDToSObject(shapeStudyEntry)
- studyEditor = getStudyEditor(studyId)
+ studyEditor = getStudyEditor()
studyEditor.removeItem(studyObject,True)
return shape
# Helper functions for a complete suppression of a shape from the
# SALOME session.
# ======================================================================
-def deleteShape(study,shapeStudyEntry):
+def deleteShape(shapeStudyEntry):
"""
This completly deletes a geom shape.
3. destroy the underlying geom object
"""
eraseShape(shapeStudyEntry)
- shape = removeFromStudy(study, shapeStudyEntry)
+ shape = removeFromStudy(shapeStudyEntry)
if shape is not None:
shape.Destroy()
"""
import salome
salome.salome_init()
- study = salome.myStudy
- studyId = salome.myStudyId
+ study = salome.myStudy
from salome.geom import geomtools
- geompy = geomtools.getGeompy(studyId)
+ geompy = geomtools.getGeompy()
# --------------------------------------------------
# Create a first shape (GEOM object)
# folder. A name must be specified. The register operation
# (addToStudy) returns an identifier of the entry in the study.
cylinderName = "cyl.r%s.l%s"%(radius,length)
- cylinderStudyEntry = addToStudy(study, cylinder, cylinderName)
+ cylinderStudyEntry = addToStudy(cylinder, cylinderName)
# Display the registered shape in a viewer
displayShape(cylinderStudyEntry)
radius = 10
sphere = geompy.MakeSphereR(radius)
sphereName = "sph.r%s"%radius
- sphereStudyEntry = addToStudy(study, sphere, sphereName)
+ sphereStudyEntry = addToStudy(sphere, sphereName)
displayShape(sphereStudyEntry)
# --------------------------------------------------
box = geompy.MakeBoxDXDYDZ(length,length,length)
boxName = "box.l%s"%length
folderName = "boxset"
- boxStudyEntry = addToStudy(study, box, boxName, folderName)
+ boxStudyEntry = addToStudy(box, boxName, folderName)
displayShape(boxStudyEntry,PreviewColor)
# --------------------------------------------------
# SALOME session (erase from viewer, remove from study and finnaly
# destroy the object). This is done by a simple call to
# deleteShape().
- deleteShape(study,cylinderStudyEntry)
+ deleteShape(cylinderStudyEntry)
# --------------------------------------------------
# At the end of the executioon of this test, you should have in