import SMESH

def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
    aMeshGen = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

    aFilterMgr = aMeshGen.CreateFilterManager()
    aFilter = aFilterMgr.CreateFilter()
   
    aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
    aLyingOnGeom.SetGeom(theShape)
    aLyingOnGeom.SetElementType(theElemType)
    
    aFilter.SetPredicate(aLyingOnGeom)
    anIds = aFilter.GetElementsId(theMesh)

    aGroup = theMesh.CreateGroup(theElemType, theName)
    aGroup.Add(anIds)

#Example
## from SMESH_test1 import *

## smesh.Compute(mesh, box)
## BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )

## salome.sg.updateObjBrowser(1);

from meshpy import *

def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
    aFilterMgr = smesh.CreateFilterManager()
    aFilter = aFilterMgr.CreateFilter()
   
    aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
    aLyingOnGeom.SetGeom(theShape)
    aLyingOnGeom.SetElementType(theElemType)
    
    aFilter.SetPredicate(aLyingOnGeom)
    anIds = aFilter.GetElementsId(theMesh)

    aGroup = theMesh.CreateGroup(theElemType, theName)
    aGroup.Add(anIds)

#Example
## from SMESH_test1 import *

## smesh.Compute(mesh, box)
## BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )

## salome.sg.updateObjBrowser(1);

Fix a bug - salome.py is not imported here and this causes run-time Python exception
Fix a bug - salome.py is not imported here and this causes run-time Python exception

- import SMESH
+ from meshpy import *
  
  def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
-     aMeshGen = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
- 
-     aFilterMgr = aMeshGen.CreateFilterManager()
+     aFilterMgr = smesh.CreateFilterManager()
      aFilter = aFilterMgr.CreateFilter()
     
      aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
      aLyingOnGeom.SetGeom(theShape)
      aLyingOnGeom.SetElementType(theElemType)
      
      aFilter.SetPredicate(aLyingOnGeom)
      anIds = aFilter.GetElementsId(theMesh)
  
      aGroup = theMesh.CreateGroup(theElemType, theName)
      aGroup.Add(anIds)
  
  #Example
  ## from SMESH_test1 import *
  
  ## smesh.Compute(mesh, box)
  ## BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )
  
  ## salome.sg.updateObjBrowser(1);
  
Fix a bug - salome.py is not imported here and this causes run-time Python exception
## Code Before:
import SMESH

def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
    aMeshGen = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

    aFilterMgr = aMeshGen.CreateFilterManager()
    aFilter = aFilterMgr.CreateFilter()
   
    aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
    aLyingOnGeom.SetGeom(theShape)
    aLyingOnGeom.SetElementType(theElemType)
    
    aFilter.SetPredicate(aLyingOnGeom)
    anIds = aFilter.GetElementsId(theMesh)

    aGroup = theMesh.CreateGroup(theElemType, theName)
    aGroup.Add(anIds)

#Example
## from SMESH_test1 import *

## smesh.Compute(mesh, box)
## BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )

## salome.sg.updateObjBrowser(1);

## Instruction:
Fix a bug - salome.py is not imported here and this causes run-time Python exception
## Code After:
from meshpy import *

def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
    aFilterMgr = smesh.CreateFilterManager()
    aFilter = aFilterMgr.CreateFilter()
   
    aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
    aLyingOnGeom.SetGeom(theShape)
    aLyingOnGeom.SetElementType(theElemType)
    
    aFilter.SetPredicate(aLyingOnGeom)
    anIds = aFilter.GetElementsId(theMesh)

    aGroup = theMesh.CreateGroup(theElemType, theName)
    aGroup.Add(anIds)

#Example
## from SMESH_test1 import *

## smesh.Compute(mesh, box)
## BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )

## salome.sg.updateObjBrowser(1);
