Personal tools
You are here: Home Forum Use Exporting Mesh Face Stl with Python Script

Exporting Mesh Face Stl with Python Script

Up to Use

Exporting Mesh Face Stl with Python Script

Posted by Peter Dudley at July 19. 2018

Hi:

I have a meshed surface with a lot of faces (see attached photo). I want to export every surface as a separate stl file, thus i want to automate it with python.  When i dump the study after exporting one i see the flowing:

try:
  Mesh_1.ExportSTL( r'C:/Users/peter.dudley/Google Drive/Documents/Research/Project - Salmon/CFD/Geometry/Random5/Face_232.stl', 1, Face_232_1)
except:
  print 'ExportPartToSTL() failed. Invalid file name?'

I have a script like this so far:

obj1 = salome.myStudy.FindObject('Mesh_1')
obj2 = obj1.GetObject()

obj2.ExportSTL( r'C:/Users/peter.dudley/Google Drive/Documents/Research/Project - Salmon/CFD/Geometry/Random5/volume.stl', 1)

obj3 = salome.myStudy.FindObject('Face_1')
obj4 = obj3.GetObject()

obj2.ExportSTL( r'C:/Users/peter.dudley/Google Drive/Documents/Research/Project - Salmon/CFD/Geometry/Random5/Face_1.stl', 1, obj4)

but it always errors saying:

 File "C:\Users\peter.dudley\Google Drive\Documents\Research\Programs\CFDPrograms\SALOME-8.2.0-WIN64\MODULES\SMESH\RELEASE\SMESH_INSTALL\bin\salome\SMESH_Mesh_idl.py", line 920, in ExportSTL

 

return _omnipy.invoke(self, "ExportSTL", _0_SMESH.SMESH_Mesh._d_ExportSTL, args)

 

TypeError: Operation requires 2 arguments; 3 given

 

 

I'm not sure why it won't take the three arguments or what I'm doing wrong.

 

 

Greatly appreciate any help!

 

Best,

 

Peter

 

Peter

Attachments

Re: Exporting Mesh Face Stl with Python Script

Posted by Saint Michael at August 03. 2018
Hi
To  fix it, replace
obj2 = obj1.GetObject()
with
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
obj2 = smesh.Mesh(obj1.GetObject())
St.Michael
Powered by Ploneboard
Document Actions