Personal tools
You are here: Home Forum How to use Salome? Error when using .Add function in salome

Error when using .Add function in salome

Up to How to use Salome?

Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 01. 2017

Hello,

 

I'm currently having a problem while using the Add function in salome mesh.

I am trying to create an empty group of volumes initially, called Group_1. I then go through an array (.mat file) to choose some values and add them in an append list (list_volumes). Then I would like to display the group of volumes by adding them to Group_1.

I have the following program in python:

 

import scipy.io
content = scipy.io.loadmat("ind_elements.mat");
content = content['B']

# Group
Group_1 = Mesh_1.CreateEmptyGroup( SMESH.VOLUME, 'Group_1' )
list_volumes = [ ]
for a in xrange(0, 21):
    b = content[a][0]
    list_volumes.append(b)   
       
nbAdd = Group_1.Add( list_volumes )

 

Everything works but the last line. It is very weird as I used the same line in another model and it worked just fine. The error it produces is:

p, li { white-space: pre-wrap; }

Traceback (most recent call last):

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

File "/home/bilquis/Documents/These/Simulations/temporel/new_models/MSDE/python models/actual_MSDE_TO_zones_discretised/display_airgap_elements.py", line 21, in <module>

nbAdd = Group_1.Add( list_volumes )

File "/opt/salome/appli_V7_4_0/lib/python2.7/site-packages/salome/SMESH_Group_idl.py", line 203, in Add

return _omnipy.invoke(self, "Add", _0_SMESH.SMESH_Group._d_Add, args)

omniORB.CORBA.BAD_PARAM: CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)

 

Also, when I add the volumes directly using the following line, it works fine as well. I cannot figure out the problem.

nbAdd = Group_1.Add( [3262, 3263, 3288, 3296, 3285, 3302, 3282, 3294, 3278, 3274, 3292, 3308, 3347, 3327, 3329, 3351, 3333, 3336, 3335, 3319, 3322] )

Can anyone help me out please?

Thank you in advance.

 

Bilquis

 

Re: Error when using .Add function in salome

Posted by Saint Michael at February 01. 2017

Hi Bilquis

It seems that list_volumes is not a list of integers. Print it to check what it is.

St.Michael

Re: Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 01. 2017

Hello,

Thank you for your reply.

The list_volumes is actually a list of integers as below:

p, li { white-space: pre-wrap; }

>>> list_volumes

[3262, 3263, 3288, 3296, 3285, 3302, 3282, 3294, 3278, 3274, 3292, 3308, 3347, 3327, 3329, 3351, 3333, 3336, 3335, 3319, 3322]

 

But it seems that the problem is with the function Add that doesn't work with this list of integers in this case for some reason.

 

Bilquis

Re: Error when using .Add function in salome

Posted by Saint Michael at February 01. 2017

Very strange. What >>> type( list_volumes ) returns?

St.Michael

Re: Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 01. 2017
p, li { white-space: pre-wrap; }

It returns this:

>>> type(list_volumes)

<type 'list'>

 

Exactly very strange. Because I use this same code as above with another model and it works fine! That's why I don't understand!

 

Bilquis

Re: Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 10. 2017

Hello again,

 

About the problem above described, does anyone have a solution? This is posing a big hindrance in my work and I can't find any solution.

I would be very grateful for any kind of help.

Thank you!

 

Bilquis

Re: Error when using .Add function in salome

Posted by Saint Michael at February 10. 2017

Last chance. What >>> type( list_volumes[ 0 ] ) returns?

St.Michael

Re: Error when using .Add function in salome

Posted by Saint Michael at February 10. 2017

Can you share ind_elements.mat to experiment with?

Re: Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 10. 2017

python script to display

Attachments

Re: Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 10. 2017

Hello,

 For the type, it returns:

 

p, li { white-space: pre-wrap; }

>>> type(list_volumes[0])

<type 'numpy.uint16'>

 

And I am attraching the .mat with the message. I have changed the name of the .mat which is now ind_ascend.mat.

I am also sending you the python script to display the elements.

Please tell me if you need any other files to get the error.

 

Thank you

 

Bilquis

 

Attachments

Re: Error when using .Add function in salome

Posted by Saint Michael at February 10. 2017

I think a solution is:

b = int( content[a][0] )

St.Michael

Re: Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 10. 2017

I tried but it did not work :(

It seems like the problem is with the line:

nbAdd = Group_1.Add( list_volumes )

Are there any other functions which do the same thing in salome?

Bilquis

Re: Error when using .Add function in salome

Posted by Saint Michael at February 10. 2017

I tried your script. W/o the correction - there is an exception, with the correction - OK.

You can create a group on filter with FT_RangeOfIds criterion.

Group_1 = Mesh_1.MakeGroup( "Group_1", SMESH.VOLUME, SMESH.FT_RangeOfIds,'=', str( list_volumes ))

St.Michael

Re: Error when using .Add function in salome

Posted by Bilquis Mohamodhosen at February 10. 2017

Ok, it works with this:

Group_1 = Mesh_1.MakeGroup( "Group_1", SMESH.VOLUME, SMESH.FT_RangeOfIds,'=', str(b))

and that only if I put it in the for loop, therefore it generates 21 Group_1. Otherwise, the Group_1 stays empty.

I guess the problem must be with the list_volumes, even after using b = int(content[a][0]), it still bugs.

I don't know, but it might probably be with the salome version as well? i am using salome7.4.

But thank you anyway. I have at least managed to display the contents.

Bilquis

Powered by Ploneboard
Document Actions