当前位置: 首页>>代码示例>>Python>>正文


Python salome.salome_init函数代码示例

本文整理汇总了Python中salome.salome_init函数的典型用法代码示例。如果您正苦于以下问题:Python salome_init函数的具体用法?Python salome_init怎么用?Python salome_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了salome_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: the8vertices

def the8vertices(complaint="Shape1", pause=1):
    import salome

    salome.salome_init()
    import GEOM
    import time

    #
    delobjregex(".*phere.*$", "t")
    #
    # zoom
    obj_name1 = [complaint]  # zoom object
    obj_name2 = []  # environment object
    zoomobj(-1, -1, -1, -1, obj_name1, obj_name2, "OCCViewer")  # ok
    #
    Shape1 = salome.myStudy.FindObjectByName(complaint, "GEOM")[0].GetObject()  # .GetID()
    # def:
    VP = geompy.SubShapeAll(Shape1, geompy.ShapeType["VERTEX"])  # shape
    for i in range(0, len(VP)):
        sphere = geompy.MakeSpherePntR(VP[i], 20)
        sphere_id = geompy.addToStudy(sphere, "Sphere12" + str(i))
        salome.sg.updateObjBrowser(salome.myStudy._get_StudyId())
        gg.createAndDisplayGO(sphere_id)
        gg.setDisplayMode(sphere_id, 1)
        gg.setColor(sphere_id, 255 - 255 * i / len(VP), 165, 31)
        gg.setTransparency(sphere_id, 0.01)
        print "vertex" + str(i)
        time.sleep(pause)
开发者ID:teobo,项目名称:heatbridge,代码行数:28,代码来源:salome_breptovtu.py

示例2: TEST_CreateGeometry

def TEST_CreateGeometry():
    import salome
    salome.salome_init()
    import GEOM
    from salome.geom import geomBuilder
    geompy = geomBuilder.New(salome.myStudy)
    import SALOMEDS
    geompy.init_geom(salome.myStudy)
    Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
    edges = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["EDGE"])
    geompy.addToStudy(Box_1, "Box_1")
    for i in range(len(edges)):
        geompy.addToStudyInFather(Box_1, edges[i], "Edge_%d" % i)
    faces = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"])
    faces[3].SetColor(SALOMEDS.Color(1.0,0.5,0.0))
    faces[4].SetColor(SALOMEDS.Color(0.0,1.0,0.5))
    for i in range(len(faces)):
        geompy.addToStudyInFather(Box_1, faces[i], "Face_%d" % i)
    Cylinder_1 = geompy.MakeCylinderRH(50, 200)
    geompy.TranslateDXDYDZ(Cylinder_1, 300, 300, 0)
    cyl_faces = geompy.SubShapeAllSorted(Cylinder_1, geompy.ShapeType["FACE"])
    geompy.addToStudy(Cylinder_1, "Cylinder_1")
    for i in range(len(cyl_faces)):
        geompy.addToStudyInFather(Cylinder_1, cyl_faces[i], "CylFace_%d" % i)
    Cylinder_2 = geompy.MakeTranslation(Cylinder_1, 100, 100, 0)
    cyl_faces2 = geompy.SubShapeAllSorted(Cylinder_2,
                                          geompy.ShapeType["FACE"])
    geompy.addToStudy(Cylinder_2, "Cylinder_2")
    for i in range(len(cyl_faces2)):
        geompy.addToStudyInFather(Cylinder_2, cyl_faces2[i],
                                  "CylFace2_%d" % i)
开发者ID:FedoraScientific,项目名称:salome-geom,代码行数:31,代码来源:__init__.py

示例3: __init__

 def __init__(self, studyId = None):
     salome.salome_init()
     if studyId is None:
         studyId = getActiveStudyId()
     self.studyId = studyId
     self.study = salome.myStudyManager.GetStudyByID(studyId)
     if self.study is None:
         raise Exception("Can't create StudyEditor object: "
                         "Study %d doesn't exist" % studyId)
     self.builder = self.study.NewBuilder()
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:10,代码来源:studyedit.py

示例4: getActiveStudyId

def getActiveStudyId():
    """
    Return the ID of the active study. In GUI mode, this function is equivalent
    to ``salome.sg.getActiveStudyId()``. Outside GUI, it returns
    ``salome.myStudyId`` variable.
    """
    salome.salome_init()
    # Warning: we don't use salome.getActiveStudy() here because it doesn't
    # work properly when called from Salome modules (multi-study interpreter
    # issue)
    if salome.hasDesktop():
        return salome.sg.getActiveStudyId()
    else:
        return salome.myStudyId
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:14,代码来源:studyedit.py

示例5: importPlugins

    def importPlugins(self):
        """Execute the salome_plugins file that contains plugins definition """
        studyId=sg.getActiveStudyId()
        if studyId == 0:
          self.menu.clear()
          self.menu.menuAction().setVisible(False)
          return
        elif self.lasttime ==0 or salome.myStudy == None:
          salome.salome_init(embedded=1)

        lasttime=0

        plugins_files=[]
        plugins_file_name=self.name+MATCH_ENDING_PATTERN
        for directory in self.plugindirs:
          plugins_file = os.path.join(directory,plugins_file_name)
          if os.path.isfile(plugins_file):
            plugins_files.append((directory,plugins_file))
            lasttime=max(lasttime,os.path.getmtime(plugins_file))

        plugins_files.sort()

        if not plugins_files:
          self.registry.clear()
          self.handlers.clear()
          self.entries=[]
          self.lasttime=0
          self.menu.clear()
          self.menu.menuAction().setVisible(False)
          return

        if self.plugins_files != plugins_files or lasttime > self.lasttime:
          global current_plugins_manager
          current_plugins_manager=self
          self.registry.clear()
          self.handlers.clear()
          self.entries=[]
          self.lasttime=lasttime
          for directory,plugins_file in plugins_files:
            logger.debug("look for python path: %s"%directory)
            if directory not in sys.path:
              sys.path.insert(0,directory)
              logger.debug("The directory %s has been added to PYTHONPATH"%directory)
            try:
              execfile(plugins_file,globals(),{})
            except:
              logger.fatal("Error while loading plugins from file %s"%plugins_file)
              traceback.print_exc()

          self.updateMenu()
开发者ID:FedoraScientific,项目名称:salome-gui,代码行数:50,代码来源:salome_pluginsmanager.py

示例6: loadSpadderCatalog

def loadSpadderCatalog():
    import salome
    salome.salome_init()
    obj = salome.naming_service.Resolve('Kernel/ModulCatalog')
    import SALOME_ModuleCatalog
    catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
    if not catalog:
        raise RuntimeError, "Can't accesss module catalog"

    filename = getSpadderCatalogFilename()
    catalog.ImportXmlCatalogFile(filename)

    from salome.kernel import services
    print "The list of SALOME components is now:" 
    print services.getComponentList()
开发者ID:FedoraScientific,项目名称:salome-smesh,代码行数:15,代码来源:__init__.py

示例7: initNS

  def initNS( self, args ) :
    """
    Obtains a reference to the root naming context
    """
    try :
      # Try to connect to the existing SALOME session 
      obj = self.orb.resolve_initial_references( "NameService" )
      self.rootContext = obj._narrow( CosNaming.NamingContext )

      # Try to connect to already existing SALOME study
      from salome import salome_init
      salome_init( theStudyId = 1 )
    except :
      # Try to launch a new session of SALOME 

      # Obtain SALOME configuration parameters
      from setenv import get_config
      args, modules_list, modules_root_dir = get_config()

      from runSalome import kill_salome
      kill_salome( args )

      # To generate a new SALOME configuration
      from runSalome import searchFreePort
      searchFreePort( args, 0 )

      # Starting of SALOME application 
      from runSalome import startSalome
      startSalome( args, modules_list, modules_root_dir )

      # To call the carresponding method of base class
      orbmodule.client.initNS( self, args )

      # Try to create a new SALOME study
      from salome import salome_init
      salome_init( theStudyId = 0 )
      pass

    self.showNS() # Prints debug information (can be commented)

    # It is necessary to wait untill it will be possible 
    # to get access to some important SALOME services
    self.waitNS( "/Kernel/Session" )
    self.waitNS( "/Kernel/ModulCatalog" )
    self.waitNS( "/myStudyManager" )

    pass
开发者ID:asimurzin,项目名称:hybridFlu,代码行数:47,代码来源:pysalome.py

示例8: start_client

def start_client():
  try:
    clt = client()
  except Exception:
    import traceback
    traceback.print_exc()
    sys.exit(1)
  #

  session_server = clt.Resolve('/Kernel/Session')
  if session_server:
    session = clt.waitNS("/Kernel/Session")
  catalog = clt.waitNS("/Kernel/ModulCatalog")
  studyMgr = clt.waitNS("/myStudyManager")

  import salome
  salome.salome_init()
  from salome import lcc
  print "--> now connected to SALOME"
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:19,代码来源:runConsole.py

示例9: TEST_StructuralElement

def TEST_StructuralElement():
    salome.salome_init()
    TEST_CreateGeometry()
    liste_commandes = [('Orientation', {'MeshGroups': 'Edge_4',
                                        'VECT_Y': (1.0, 0.0, 1.0)}),
                       ('Orientation', {'MeshGroups': 'Edge_5',
                                        'ANGL_VRIL': 45.0}),
                       ('GeneralBeam', {'MeshGroups': ['Edge_1', 'Edge_7'],
                                        'A': 1, 'IY1': 20, 'IY2': 40,
                                        'IZ1': 60, 'IZ2': 30}),
                       ('VisuPoutreCercle', {'MeshGroups': ['Edge_6'],
                                             'R1': 30, 'R2': 20}),
                       ('CircularBeam', {'MeshGroups': ['Edge_2', 'Edge_3'],
                                         'R': 40, 'EP': 20}),
                       ('RectangularBeam', {'MeshGroups': ['Edge_4', 'Edge_5'],
                                            'HZ1': 60, 'HY1': 40,
                                            'EPZ1': 15, 'EPY1': 10,
                                            'HZ2': 40, 'HY2': 60,
                                            'EPZ2': 10, 'EPY2': 15}),
                       ('VisuCable', {'MeshGroups': 'Edge_7', 'R': 5}),
                       ('VisuCoque', {'MeshGroups': 'Face_4',
                                      'Epais': 10, 'Excentre': 5,
                                      'angleAlpha': 45, 'angleBeta': 60}),
                       ('VisuCoque', {'MeshGroups': 'CylFace_2', 'Epais': 5}),
                       ('VisuGrille', {'MeshGroups': 'Face_5', 'Excentre': 5,
                                       'angleAlpha': 45, 'angleBeta': 60}),
                       ('VisuGrille', {'MeshGroups': 'CylFace2_2',
                                       'Excentre': 5, 'origAxeX': 400,
                                       'origAxeY': 400, 'origAxeZ': 0,
                                       'axeX': 0, 'axeY': 0, 'axeZ': 100}),
                      ]

    structElemManager = StructuralElementManager()
    elem = structElemManager.createElement(liste_commandes)
    if salome.hasDesktop():
        elem.display()
        salome.sg.updateObjBrowser(True)
开发者ID:FedoraScientific,项目名称:salome-geom,代码行数:37,代码来源:__init__.py

示例10: CreateRdExtGlobalVar

def CreateRdExtGlobalVar(value,varName,scopeName):
    import salome
    salome.salome_init()
    dsm=salome.naming_service.Resolve("/DataServerManager")
    d2s,isCreated=dsm.giveADataScopeCalled(scopeName)
    return GetHandlerFromRef(d2s.createRdExtVar(varName,cPickle.dumps(value,cPickle.HIGHEST_PROTOCOL)),False)
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:6,代码来源:SalomeSDSClt.py

示例11: useSalome

def useSalome(args, modules_list, modules_root_dir):
    """
    Launch all SALOME servers requested by args,
    save list of process, give info to user,
    show registered objects in Naming Service.
    """
    global process_id

    clt=None
    try:
        clt = startSalome(args, modules_list, modules_root_dir)
    except:
        import traceback
        traceback.print_exc()
        print
        print
        print "--- Error during Salome launch ---"

    #print process_id

    from addToKillList import addToKillList
    from killSalomeWithPort import getPiDict

    filedict = getPiDict(args['port'])
    for pid, cmd in process_id.items():
        addToKillList(pid, cmd, args['port'])
        pass

    if verbose(): print """
    Saving of the dictionary of Salome processes in %s
    To kill SALOME processes from a console (kill all sessions from all ports):
      python killSalome.py
    To kill SALOME from the present interpreter, if it is not closed :
      killLocalPort()      --> kill this session
                               (use CORBA port from args of runSalome)
      givenPortKill(port)  --> kill a specific session with given CORBA port
      killAllPorts()       --> kill all sessions

    runSalome, with --killall option, starts with killing
    the processes resulting from the previous execution.
    """%filedict

    #
    #  Print Naming Service directory list
    #

    if clt != None:
        if verbose():
            print
            print " --- registered objects tree in Naming Service ---"
            clt.showNS()
            pass

        if not args['gui'] or not args['session_gui']:
            if args['shutdown_servers']:
                class __utils__(object):
                    def __init__(self, port):
                        self.port = port
                        import killSalomeWithPort
                        self.killSalomeWithPort = killSalomeWithPort
                        return
                    def __del__(self):
                        self.killSalomeWithPort.killMyPort(self.port)
                        return
                    pass
                def func(s):
                    del s
                import atexit
                atexit.register(func, __utils__(args['port']))
                pass
            pass

        # run python scripts, passed as command line arguments
        toimport = []
        if args.has_key('gui') and args.has_key('session_gui'):
            if not args['gui'] or not args['session_gui']:
                if args.has_key('study_hdf'):
                    toopen = args['study_hdf']
                    if toopen:
                        import salome
                        salome.salome_init(toopen)
                if args.has_key('pyscript'):
                    toimport = args['pyscript']
        from salomeContextUtils import formatScriptsAndArgs
        command = formatScriptsAndArgs(toimport)
        if command:
            proc = subprocess.Popen(command, shell=True)
            addToKillList(proc.pid, command, args['port'])
            res = proc.wait()
            if res: sys.exit(1) # if there's an error when executing script, we should explicitly exit

    return clt
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:92,代码来源:runSalome.py

示例12: setUp

 def setUp(self):
   salome.salome_init()
   pass
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:3,代码来源:TestSalomeSDS.py

示例13: getStudyFromStudyId

def getStudyFromStudyId(studyId):
    salome.salome_init()
    study = salome.myStudyManager.GetStudyByID(studyId)
    return study
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:4,代码来源:studyedit.py

示例14: createTunnel

def createTunnel(fileName, kwargs, doGUI=False,doMeshing=True,killSalomeAfter=True):
    '''
    @author: Vance Turnewitsch
    @date: Feb 20, 2014
    This code is to be run with salome-meca 2014.1 not an earlier version.
    '''
    try:
        import salome
        import math
    
        salome.salome_init()
        import GEOM
        from salome.geom import geomBuilder
        theStudy = salome.myStudy
        #from SMESH_mechanic import SMESH
    
        geompy = geomBuilder.New(salome.myStudy)
        if doGUI:
            gg = salome.ImportComponentGUI("GEOM")
    
        #import SMESH
        #from salome.smesh import smeshBuilder
    
        # Get the parameters
        diskX = kwargs['diskX']
        diskY = kwargs['diskY']
        diskZ = kwargs['diskZ']
    
        diskHeight = kwargs['diskHeight']
        diskRadius = kwargs['diskRadius']
        tunnelHeight = kwargs['tunnelHeight']
        tunnelRadius = kwargs['tunnelRadius']
        '''
        tunnelFineness=kwargs['tunnelFineness']
        diskFineness=kwargs['diskFineness']
    
        tunnelMaxTetraSize=kwargs['tunnelMaxTetraSize']
        tunnelMinTetraSize=kwargs['tunnelMinTetraSize']
        diskMaxTetraSize=kwargs['diskMaxTetraSize']
        diskMinTetraSize=kwargs['diskMinTetraSize']
        '''
        tunnelMaxSize = kwargs['tunnelMaxSize']
        
        # These are the raw coordinates for the shroud points
        shroudCoords = kwargs['shroudPoints']
        # This is the thickness of the shroud material
        shroudThickness = kwargs['shroudThickness']
    
        print "Creating tunnel with following properties:",kwargs
    
        #smesh = smeshBuilder.New(salome.myStudy)
    
        # Make the actuator disk
        startDiskBase = geompy.MakeVertex(diskX, diskY, diskZ)
        startDiskBaseID = geompy.addToStudy(startDiskBase, 'StartDiskBase')
        if doGUI:
            gg.createAndDisplayGO(startDiskBaseID)
    
        vx = geompy.MakeVectorDXDYDZ(100, 0, 0)
        vxID = geompy.addToStudy(vx, 'vx')
    
    
        if doGUI:
            gg.createAndDisplayGO(vxID)
    
        diskCyl = geompy.MakeCylinder(startDiskBase, vx, diskRadius, diskHeight)
        diskCylID = geompy.addToStudy(diskCyl, 'Disk')
        #geompy.addToStudy(diskCyl,'Disk')
        if doGUI:
            gg.createAndDisplayGO(diskCylID)
    
        # Make the cyliner
        origin = geompy.MakeVertex(0, 0, 0)
        tunnelCyl = geompy.MakeCylinder(origin, vx, tunnelRadius, tunnelHeight)
        
        # Make the shroud
        # The actual shroud vertices created from the raw data points
        shroudPoints = []
        # We better sort the points first
        shroudCoords.sort(key=lambda item: item[0])
        print "The shroud points to be meshed>",shroudCoords
        print "The sorted shroud coords:",shroudCoords
        for raw in shroudCoords:
            # The points are in x and z
            vertex = geompy.MakeVertex(raw[0],0,raw[1])
            shroudPoints.append(vertex)
            geompy.addToStudy(vertex,'Point:'+str(raw[0]))
            
        # Now make the line that we will extrude for the base that gets revolved
        ShroudLine = geompy.MakePolyline(shroudPoints)
        geompy.addToStudy(ShroudLine,'ShroudLine')
        # Now make a vector so that we can extrude this line
        vz = geompy.MakeVectorDXDYDZ(0,0,1)
        geompy.addToStudy(vz,'vz')
        # This is the extruded shroud line
        ShroudOutline = geompy.MakePrismVecH(ShroudLine,vz,0.25)
        geompy.addToStudy(ShroudOutline,'ShroudOutline')
        # Let's make the shroud!
        Shroud = geompy.MakeRevolution2Ways(ShroudOutline,vx,180*math.pi/180.0)
        geompy.addToStudy(Shroud,'Shroud')
#.........这里部分代码省略.........
开发者ID:Vance-Turner,项目名称:MCCapstone13-14,代码行数:101,代码来源:tunnelscript.py

示例15: GetHandlerFromName

def GetHandlerFromName(varName,scopeName):
    import salome
    salome.salome_init()
    dsm=salome.naming_service.Resolve("/DataServerManager")
    d2s=dsm.retriveDataScope(scopeName)
    return GetHandlerFromRef(d2s.retrieveVar(varName),False)
开发者ID:FedoraScientific,项目名称:salome-kernel,代码行数:6,代码来源:SalomeSDSClt.py


注:本文中的salome.salome_init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。