Personal tools
You are here: Home Forum Use Coordinates of Vertex

Coordinates of Vertex

Up to Use

Coordinates of Vertex

Posted by Francis Whiteley at March 19. 2017

Hi,

I am a newbie and am having problems.

I have created a set of vertices in the shape of a wing in a study called 'Study1'

Each vertex was named 'foil_90_1', 'foil_90_2' etc

I intended to follow this example

>>> import salome, geompy
>>> studyObject = salome.myStudy.FindObjectID('0:1:1:1')
>>> vertex = studyObject.GetObject()
>>> geompy.PointCoordinates( vertex )

However whenever I try to use FindObjectID it fails.

>>> studyObject = salome.myStudy.FindObjectID('foil_90_1')

>>> studyObject.GetName()

Traceback (most recent call last):

  File "<input>", line 1, in <module>

AttributeError: 'NoneType' object has no attribute 'GetName'

or 

>>> vertex = studyObject.GetObject()

Traceback (most recent call last):

  File "<input>", line 1, in <module>

AttributeError: 'NoneType' object has no attribute 'GetObject'

Thanking anyone in anticipation of a reply......

Re: Coordinates of Vertex

Posted by Saint Michael at March 20. 2017

Hi

An Object ID is not an object name. The Object ID is the entry which you can see in the Object Browser is you activate its Entry column.

To find an object by name, call

[ studyObject ] = salome.myStudy.FindObjectByName( 'foil_90_1', 'GEOM')

or

studyObject = salome.myStudy.FindObjectByPath("/Geometry/foil_90_1")

St.Michael

Re: Coordinates of Vertex

Posted by Francis Whiteley at March 20. 2017

Thanks for that.

I seem to call without a problem but the object returned seems to

either be null or I don't know how to use it

Re: Coordinates of Vertex

Posted by Francis Whiteley at March 20. 2017

I am using this code

                    sobj = salome.myStudy.FindObjectByName( 'foil_'+str(i) + '_' + str(j), 'GEOM')
                    stl_str += 'foil_'+str(i) + '_' + str(j)+  '_2: ' + '\n'
                    Descr = geompy.WhatIs(sobj)
                    stl_str += 'foil_'+str(i) + '_' + str(j)+  '_2a: ' + Descr + '\n'
                    v1 = geompy.PointCoordinates( sobj )
                    stl_str += 'foil_'+str(i) + '_' + str(j)+  '_2b: ' + '\n'

and I get to

foil_90_01_2:

not to ...2a,  ...2b

More help would be appreciated

Re: Coordinates of Vertex

Posted by Saint Michael at March 20. 2017

The code of your initial post is OK if you add my correction. Note that FindObjectByName() returns a list.

[ studyObject ] = salome.myStudy.FindObjectByName( 'foil_'+str(i) + '_' + str(j), 'GEOM')

vertex = studyObject.GetObject()

geompy.PointCoordinates( vertex )

St.Michael

Re: Coordinates of Vertex

Posted by Francis Whiteley at March 21. 2017

Thanks,

 but I couldn't get the []studyObject] = assignement to work, so I assigned to a variable and looped with a for.

Seems to work now

        objlist = salome.myStudy.FindObjectByName( 'foil_'+str(i) + '_' + str(j), 'GEOM')

        for sobj in objlist :

            vertex = sobj.GetObject() 

Once again thanks!

Powered by Ploneboard
Document Actions