CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[cfMesh] Salome 9.3.0 cannot generate .fms file

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By Dinlink
  • 1 Post By Ship Designer

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2019, 18:03
Default Salome 9.3.0 cannot generate .fms file
  #1
Member
 
Join Date: Mar 2019
Posts: 86
Rep Power: 7
celestial is on a distinguished road
first to avoid syntax errors. I had to replace all occurrences of

print ---whatever----

with

print (---whatever----)


in scripts extractFeatureEdges.py and salomeTriSurf.py ( the opening and closing parentheses are essential) (These scripts are found under the installation of cfMesh software you can download cfMesh from their site or find it part of OpenFoam 18.0.6)

I load script salomeTriSurf.py in Salome 9.3.0 after highlighting my mesh in the Mesh module and pressing Ctrl-t)
Then, when I type
triSurf().writeFms('FileName.fms')
in the command window opened up by the loaded script, I get the following error on line 113:

AttributeError: 'collections.OrderedDict' object has no attribute 'iteritems'


I am beginning to wonder if those scripts were written to be understood by python 2.7 but not by python 3.6 which is the one used by Salome 9.3.0

Has anybody encountered this error ?
celestial is offline   Reply With Quote

Old   September 27, 2019, 10:57
Default
  #2
New Member
 
igor.leo93's Avatar
 
Igor Leonardo
Join Date: Jul 2016
Location: Brazil - SP - SJC
Posts: 20
Rep Power: 9
igor.leo93 is on a distinguished road
Quote:
Originally Posted by celestial View Post
I am beginning to wonder if those scripts were written to be understood by python 2.7 but not by python 3.6 which is the one used by Salome 9.3.0
You are correct,, check this:
General workflow to create a flawless mesh in cfMesh

Alternatively, you can download salime 8.5, and it should work there.

Best regards,
Igor Carvalho
igor.leo93 is offline   Reply With Quote

Old   October 18, 2019, 11:57
Default
  #3
Member
 
Join Date: Mar 2019
Posts: 86
Rep Power: 7
celestial is on a distinguished road
Thanks Igor. I will stick with version 7.4.0 since I had already downloaded it. Version 9.3.0 does not even work when you modify the scripts using the 2to3 python conversion program. (you get TypeError updateObjBrowser() takes 1 argument but 2 were given)
celestial is offline   Reply With Quote

Old   October 21, 2019, 05:53
Default
  #4
Senior Member
 
Carlo_P
Join Date: May 2019
Location: Italy
Posts: 176
Rep Power: 7
Carlo_P is on a distinguished road
Hey, anohter way can be to export a stl file a then convert it with surfaceToFMS.
Carlo_P is offline   Reply With Quote

Old   January 21, 2020, 10:06
Default
  #5
New Member
 
Abraham Vivas
Join Date: Sep 2016
Posts: 3
Rep Power: 9
Dinlink is on a distinguished road
Quote:
Originally Posted by celestial View Post
Thanks Igor. I will stick with version 7.4.0 since I had already downloaded it. Version 9.3.0 does not even work when you modify the scripts using the 2to3 python conversion program. (you get TypeError updateObjBrowser() takes 1 argument but 2 were given)

You were close, the problem is that it open the file to write in binary:


Code:
open(fileName, 'wb')
there are 3 lines like that... two options: or yo change every string to binary adding a "b" before the string or you open without the binary option:


Code:
open(fileName, 'w')
I just deleted the opening with the binary option and it worked. I attach my modified script which works with Salome 9.4


And for using it, after loading the script, I selected a surface mesh and then on the console i typed:


Code:
 
S = triSurf(allEdges=True)
S.writeFms("/path/to/fileName.fms")
Attached Files
File Type: gz salomeTriSurf.py.gz (2.9 KB, 101 views)
Dinlink is offline   Reply With Quote

Old   June 5, 2020, 22:15
Default
  #6
Senior Member
 
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 6
Ship Designer is on a distinguished road
Quote:
Originally Posted by celestial View Post
Thanks Igor. I will stick with version 7.4.0 since I had already downloaded it. Version 9.3.0 does not even work when you modify the scripts using the 2to3 python conversion program. (you get TypeError updateObjBrowser() takes 1 argument but 2 were given)
Hi celestial, I've encountered the same problems and I believe you're correct, that the cfMesh Python scripts are for older versions of Python. As a workaround I've used an online converter to convert the source code from Python version 2 to version 3. The updateObjBrowser() function fails, but as workaround, clicking on Refresh in the object tree context menu will update the tree and display the newly created object. Apparently, in Python the calling object is always an implied argument when a method is called, thus 2 arguments are counted, even if only one is visible in the source code. This might be an indication that the method is expected to be called without (visible) arguments (empty brackets only). I'll check the current Salome Python API and try that out. Apart from the changed Python version, some Salome APIs have had minor changes as well. Thus the cfMesh Python scripts are not compatible with the latest version of Salome.
joddy466 likes this.
Ship Designer is offline   Reply With Quote

Old   June 5, 2020, 22:18
Default
  #7
Senior Member
 
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 6
Ship Designer is on a distinguished road
Quote:
Originally Posted by celestial View Post
Thanks Igor. I will stick with version 7.4.0 since I had already downloaded it. Version 9.3.0 does not even work when you modify the scripts using the 2to3 python conversion program. (you get TypeError updateObjBrowser() takes 1 argument but 2 were given)
Hi celestial, I've encountered the same problems with Salome 9.4.0 and I believe you're correct, that the cfMesh Python scripts are for older versions of Python. As a workaround I've used an online converter to convert the source code from Python version 2 to version 3, as you did. The updateObjBrowser() function fails, but as workaround, clicking on Refresh in the object tree context menu will update the tree and display the newly created object. Apparently, in Python the calling object is always an implied argument when a method is called, thus 2 arguments are counted, even if only one is visible in the source code. This might be an indication that the method is expected to be called without (visible) arguments (empty brackets only). I'll check the current Salome Python API and try that out. Apart from the changed Python version, some Salome APIs have had minor changes as well. Thus the cfMesh Python scripts are not compatible with the latest version of Salome.
Ship Designer is offline   Reply With Quote

Old   August 12, 2020, 14:37
Default salomeTriSurf3.py
  #8
New Member
 
Elaxender david
Join Date: Nov 2017
Posts: 17
Rep Power: 8
Engin.shlxtn is on a distinguished road
Hello
I used salomeTriSurf3.py and many other script, But all failed. please help me to overcome that issues. I got that error. >>> exec(open("/home/smeralda/Cfmesh/cfMesh/python/Salome/salomeTriSurf3.py", "rb").read())
>>> triSurf().writeFms(‘FileName.fms’)
Traceback (most recent call last):
File "/opt/Salome/V2019.0.3_universal/prerequisites/Python-365/lib/python3.6/codeop.py", line 87, in _maybe_compile
code1 = compiler(source + "\n", filename, symbol)
File "/opt/Salome/V2019.0.3_universal/prerequisites/Python-365/lib/python3.6/codeop.py", line 102, in _compile
return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
File "<input>", line 1
triSurf().writeFms(‘FileName.fms’)
^
SyntaxError: invalid character in identifier
>>>
Engin.shlxtn is offline   Reply With Quote

Old   August 12, 2020, 14:46
Default
  #9
New Member
 
Elaxender david
Join Date: Nov 2017
Posts: 17
Rep Power: 8
Engin.shlxtn is on a distinguished road
Quote:
Originally Posted by Dinlink View Post
You were close, the problem is that it open the file to write in binary:


Code:
open(fileName, 'wb')
there are 3 lines like that... two options: or yo change every string to binary adding a "b" before the string or you open without the binary option:


Code:
open(fileName, 'w')
I just deleted the opening with the binary option and it worked. I attach my modified script which works with Salome 9.4


And for using it, after loading the script, I selected a surface mesh and then on the console i typed:


Code:
 
S = triSurf(allEdges=True)
S.writeFms("/path/to/fileName.fms")
salomeTriSurf3.py
Hello
I used salomeTriSurf3.py and many other script, But all failed. please help me to overcome that issues. I got that error. >>> exec(open("/home/smeralda/Cfmesh/cfMesh/python/Salome/salomeTriSurf3.py", "rb").read())
>>> triSurf().writeFms(‘FileName.fms’)
Traceback (most recent call last):
File "/opt/Salome/V2019.0.3_universal/prerequisites/Python-365/lib/python3.6/codeop.py", line 87, in _maybe_compile
code1 = compiler(source + "\n", filename, symbol)
File "/opt/Salome/V2019.0.3_universal/prerequisites/Python-365/lib/python3.6/codeop.py", line 102, in _compile
return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
File "<input>", line 1
triSurf().writeFms(‘FileName.fms’)
^
SyntaxError: invalid character in identifier
>>>
Engin.shlxtn is offline   Reply With Quote

Old   August 12, 2020, 15:23
Default
  #10
Senior Member
 
Claudio Boezio
Join Date: May 2020
Location: Europe
Posts: 137
Rep Power: 6
Ship Designer is on a distinguished road
Quote:
Originally Posted by Engin.shlxtn View Post
Hello
triSurf().writeFms(‘FileName.fms’)
^
SyntaxError: invalid character in identifier
>>>
Those single quotes look odd. Is this the error output? What are you trying to do? If you provide more information, getting help is more likely.
Ship Designer is offline   Reply With Quote

Old   August 13, 2020, 22:33
Default Succeed
  #11
New Member
 
Elaxender david
Join Date: Nov 2017
Posts: 17
Rep Power: 8
Engin.shlxtn is on a distinguished road
Quote:
Originally Posted by Dinlink View Post
You were close, the problem is that it open the file to write in binary:


Code:
open(fileName, 'wb')
there are 3 lines like that... two options: or yo change every string to binary adding a "b" before the string or you open without the binary option:


Code:
open(fileName, 'w')
I just deleted the opening with the binary option and it worked. I attach my modified script which works with Salome 9.4


And for using it, after loading the script, I selected a surface mesh and then on the console i typed:


Code:
 
S = triSurf(allEdges=True)
S.writeFms("/path/to/fileName.fms")
Hello

Finally succeeded thanks a lot
Engin.shlxtn is offline   Reply With Quote

Old   August 14, 2020, 22:42
Default Problem
  #12
New Member
 
Elaxender david
Join Date: Nov 2017
Posts: 17
Rep Power: 8
Engin.shlxtn is on a distinguished road
Quote:
Originally Posted by Dinlink View Post
You were close, the problem is that it open the file to write in binary:


Code:
open(fileName, 'wb')
there are 3 lines like that... two options: or yo change every string to binary adding a "b" before the string or you open without the binary option:


Code:
open(fileName, 'w')
I just deleted the opening with the binary option and it worked. I attach my modified script which works with Salome 9.4


And for using it, after loading the script, I selected a surface mesh and then on the console i typed:


Code:
 
S = triSurf(allEdges=True)
S.writeFms("/path/to/fileName.fms")

Hello
Thank you for your post. I did exactly what you wrote but failed at the begging of pressing Enter button. I don't know why?.
Thanks again.
Engin.shlxtn is offline   Reply With Quote

Old   August 16, 2020, 12:48
Default Thanks
  #13
New Member
 
Elaxender david
Join Date: Nov 2017
Posts: 17
Rep Power: 8
Engin.shlxtn is on a distinguished road
Quote:
Originally Posted by Ship Designer View Post
Those single quotes look odd. Is this the error output? What are you trying to do? If you provide more information, getting help is more likely.
Hello
Thank you very much. I fixed the problem of cfmesh with the blender.
Thanks again.
Engin.shlxtn is offline   Reply With Quote

Old   December 21, 2022, 22:19
Default
  #14
New Member
 
Joshua Oseh
Join Date: May 2016
Posts: 1
Rep Power: 0
joddy466 is on a distinguished road
If anyone stumbles on this post, what worked for me (Salome 9.9.0) was:


1) Update extractFeatureEdges.py to py2/3 using futurize. Skip to Step 1, 1b here if you already have python installed. This updates your file to work with Python 2 or 3.


2) Delete "x" in "xrange" in 3 places to use "range" which is what is used in Python3


3) Delete or comment out the last 2 lines (line 131,132). in extractFeatureEdges.py. cfmesh hasn't been updated in years so should be same for you. i.e



# if salome.sg.hasDesktop():
# salome.sg.updateObjBrowser(True)


4) Run script in Salome as usual


5) Refresh through object browser as "Ship Designer" mentioned


This worked for me!
Attached Files
File Type: zip extractFeatureEdges.zip (1.8 KB, 7 views)

Last edited by joddy466; December 21, 2022 at 23:24.
joddy466 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 18:13
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 19:43
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 03:23
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 18:38.