Personal tools
You are here: Home Forum Use how to use Python within Salome?

how to use Python within Salome?

Up to Use
  • how to use Python within Salome?

    Posted by jo77 at July 20. 2007
    hello,
    I am sorry for a - may be - very simple question. I m new with Python and have learned that before using commands certain MODULEs must be imported which contain them. But unfortunality, I do not succeed to do anything. I try some lines as proposed in the Salome documentation:

    import geompy
    import salome
    gg = salome.ImportComponentGUI("GEOM";)
    p0 = geompy.MakeVertex(0., 0., 0.)
    p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.)
    px = geompy.MakeVertex(100., 0., 0.)
    py = geompy.MakeVertex(0., 100., 0.)
    pz = geompy.MakeVertex(0., 0., 100.)
    Arc = geompy.MakeArc(py, pz, px)
    p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25)

    Typing this, no errors are echoed by the python interpreter, so everything seems OK. But there are no geometric object created in the object browser and in the GUI.

    Can someone please shed some light on this for me? Thank You in advance

    Jo
    • Re: how to use Python within Salome?

      Posted by Bonaccorsi at July 20. 2007
      jo77 wrote:
      hello,
      I am sorry for a - may be - very simple question. I m new with Python and have learned that before using commands certain MODULEs must be imported which contain them. But unfortunality, I do not succeed to do anything. I try some lines as proposed in the Salome documentation:

      import geompy
      import salome
      gg = salome.ImportComponentGUI("GEOM";)
      p0 = geompy.MakeVertex(0., 0., 0.)
      p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.)
      px = geompy.MakeVertex(100., 0., 0.)
      py = geompy.MakeVertex(0., 100., 0.)
      pz = geompy.MakeVertex(0., 0., 100.)
      Arc = geompy.MakeArc(py, pz, px)
      p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25)

      Typing this, no errors are echoed by the python interpreter, so everything seems OK. But there are no geometric object created in the object browser and in the GUI.

      Can someone please shed some light on this for me? Thank You in advance

      Jo


      Hi,

      I think your script is good, but you only build GEOM object. Now, you have to display them with the good commands. If I consider you launch this script into the PYTHON interpretor of SALOME (within the SALOME IHM), you have to append those lines (for each of your GEOM objects) :

      id_p0 = geompy.addToStudy(p0 ,'p0')

      gg.createAndDisplayGO(id_p0)

      and so on...

      Good week-end,

      Thomas.

       

       

      • Re: how to use Python within Salome?

        Posted by Kwun Ho Ngan at July 26. 2007
        To add on this post, is there any manual or reference about using python on Salome. That will be interesting to me.

        Thanks
Powered by Ploneboard
Document Actions