Personal tools
You are here: Home Forum Extension of the platform New component based on PYHELLO example

New component based on PYHELLO example

Up to Extension of the platform

New component based on PYHELLO example

Posted by Damien GODIN at April 13. 2011

Hello,

I try to write a new salome component written in python . I started with PYHELLO example and rename "Hello" with "MyComponent".

The salome gui is launching properly but i have this error when i try to call a method defined in the idl file.

Traceback (most recent call last):
  File "/home/godin/salome_5.1.5/MYCOMPONENT_5.1.5/bin/salome/MYCOMPONENTGUI.py", line 224, in OnGUIEvent
    dict_command[commandID]()
  File "/home/godin/salome_5.1.5/MYCOMPONENT_5.1.5/bin/salome/MYCOMPONENTGUI.py", line 262, in CallMeth
    getEngine().meth( _getStudy() )
  File "/home/godin/salome_5.1.5/MYCOMPONENT_5.1.5/lib/python2.4/site-packages/salome/MYCOMPONENT_Gen_idl.py", line 68, in meth
    return _omnipy.invoke(self, "meth", _0_MYCOMPONENT_ORB.MYCOMPONENT_Gen._d_meth, args)
UNKNOWN: CORBA.UNKNOWN(omniORB.UNKNOWN_PythonException, CORBA.COMPLETED_MAYBE)
th. 140573188360064 end of trace

 

Here is the definition in the idl file

module MYCOMPONENT_ORB
{
  interface MYCOMPONENT_Gen : Engines::Component, SALOMEDS::Driver
  {
      void meth(in SALOMEDS::Study theStudy)
          raises (SALOME::SALOME_Exception);
  };
};

 

The definition of the method.

class MYCOMPONENT(MYCOMPONENT_ORB__POA.MYCOMPONENT_Gen,
              SALOME_ComponentPy.SALOME_ComponentPy_i,
              SALOME_DriverPy.SALOME_DriverPy_i):

    def meth( self, study ):

        print(meth)
        pass

  

Thanks for your help.

Damien

 

Re: New component based on PYHELLO example

Posted by Damien GODIN at August 11. 2011

Hello all,

 

I have solve the preceding problems.

Now i have some difficulties to manage Objects through python/corba and GUI.

 

Again on the PYHELLO sample component, these functions have a strange behavior.

 

in the idl file

:

 

module PYHELLO_ORB
{
  interface PYHELLO_Gen : Engines::Component, SALOMEDS::Driver
  {
    GEOM::GEOM_Object test()
      raises (SALOME::SALOME_Exception);

    void test2(in GEOM::GEOM_Object obj)
      raises (SALOME::SALOME_Exception);
  };
};

An the implementation in PYHELLO.py

 

def test(self):
       return geompy.MakeVertex(0., 0., 0.)

def test2(self, object):
   geompy.addToStudy(object, "Object")

 

As you can see the first function (test) create a new vertex and the second (test2) add a object to study.

I built this code and launch salome to execute the following script

 

 from batchmode_salome import lcc
import PYHELLO_ORB
import geompy
pyhello = lcc.FindOrLoadComponent( 'FactoryServerPy', 'PYHELLO' )

vertex = pyhello.test()
pyhello.test2(vertex) # <----- doesn't work
geompy.addtoStudy(vertex, "Vertex") # <----- works !

The call to pyhello.test2(vertex) doesn't work, the object is not present in the study, but when i call directly geompy.addToStudy(..), it works perfectly ?

 

What's wrong with this ? I think i haven't understood all salome concepts !

 

Damien

 

 

 

 

 

 

 

 

Re: New component based on PYHELLO example

Posted by Thomas PEDOT at April 05. 2012

Hello,

I am new to salome and I want to develop new module to integrate in Salome.

I will need (I guess) to do it with C++ but I think I will try first with python to understand all the concept.

Did you suceed ?

 

Thanks for your feed back ! I know it's a long time but I try. :)

Thomas

 

Previously Damien GODIN wrote:

Hello all,

 

I have solve the preceding problems.

Now i have some difficulties to manage Objects through python/corba and GUI.

 

Again on the PYHELLO sample component, these functions have a strange behavior.

 

in the idl file

:

 

module PYHELLO_ORB
{
  interface PYHELLO_Gen : Engines::Component, SALOMEDS::Driver
  {
    GEOM::GEOM_Object test()
      raises (SALOME::SALOME_Exception);

    void test2(in GEOM::GEOM_Object obj)
      raises (SALOME::SALOME_Exception);
  };
};

An the implementation in PYHELLO.py

 

def test(self):
       return geompy.MakeVertex(0., 0., 0.)

def test2(self, object):
   geompy.addToStudy(object, "Object")

 

As you can see the first function (test) create a new vertex and the second (test2) add a object to study.

I built this code and launch salome to execute the following script

 

 from batchmode_salome import lcc
import PYHELLO_ORB
import geompy
pyhello = lcc.FindOrLoadComponent( 'FactoryServerPy', 'PYHELLO' )

vertex = pyhello.test()
pyhello.test2(vertex) # <----- doesn't work
geompy.addtoStudy(vertex, "Vertex") # <----- works !

The call to pyhello.test2(vertex) doesn't work, the object is not present in the study, but when i call directly geompy.addToStudy(..), it works perfectly ?

 

What's wrong with this ? I think i haven't understood all salome concepts !

 

Damien

 

 

 

 

 

 

 

 

 

Re: New component based on PYHELLO example

Posted by Pascal KREZEL at June 04. 2012

Hi Damien,

 

I am happy to see that someone has the same idea as me : developing a new component in Salome.

For me, up to now, it seems difficult to understand how it works, so I would be grateful if you could describe what you did with the Hello component to make it appeared in Salome

.

 

Sincerely.

 

Pascal

 

Re: New component based on PYHELLO example

Posted by Saint Michael at June 04. 2012

Hi Pascal

To make PYHELLO appear in SALOME, one of the ways is to explicitly specify PYHELLO as a module to run (be default it is not run) this way:
$ runSalome -mPYHELLO

After that, when you create a new study, PYHELLO module will be activated.

St.Michael

Powered by Ploneboard
Document Actions