ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::string & theFilePath,
const ModelHighAPI_Selection& theSelectedShape,
- double aDeflectionRelative,
- double aDeflectionAbsolute,
- const bool anIsRelative,
- const bool anIsASCII)
+ double theDeflectionRelative,
+ double theDeflectionAbsolute,
+ const bool theIsRelative,
+ const bool theIsASCII)
: ModelHighAPI_Interface(theFeature)
{
initialize();
fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID()));
fillAttribute(theFilePath, theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID()));
- if (anIsRelative) {
+ if (theIsRelative) {
fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(),
theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) );
- fillAttribute(aDeflectionRelative,
+ fillAttribute(theDeflectionRelative,
theFeature->real(ExchangePlugin_ExportFeature::STL_RELATIVE()) );
}
else {
fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(),
theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) );
- fillAttribute(aDeflectionAbsolute,
+ fillAttribute(theDeflectionAbsolute,
theFeature->real(ExchangePlugin_ExportFeature::STL_ABSOLUTE()) );
}
- if(anIsASCII){
+ if(theIsASCII){
fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_ASCII(),
theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE()));
}
*/
EXCHANGEAPI_EXPORT
ExportPtr exportToSTL(const std::shared_ptr<ModelAPI_Document> & thePart,
- const std::string & theFilePath,
- const ModelHighAPI_Selection& theSelectedShape,
- double aDeflectionRelative,
- double aDeflectionAbsolute,
- const bool anIsRelative,
- const bool anIsASCII);
+ const std::string & theFilePath,
+ const ModelHighAPI_Selection& theSelectedShape,
+ double theDeflectionRelative,
+ double theDeflectionAbsolute,
+ const bool theIsRelative,
+ const bool theIsASCII);
/**\ingroup CPPHighAPI
* \brief Exports to XAO file the selected result with groups parts related to it only.
:language: python
:download:`Download this script <examples/export.py>`
+
+ .. _tui_export_file_STL:
+
+Export STL File
+===============
+
+.. literalinclude:: examples/exportSTL.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/exportSTL.py>`
+
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Export_1 = model.exportToSTL(Part_1_doc, "/dn48/newgeom/vsv/test.stl",
+ [model.selection("SOLID", "Box_1_1")],0.0001,0.5,"True","False")
+model.do()
+model.end()
Export to CAD format
--------------------
-It is possible to export objects to files in the following CAD-neutral formats: BREP, STEP, IGES, XAO.
+It is possible to export objects to files in the following CAD-neutral formats: BREP, STEP, IGES, XAO, STL.
To export objects to a file select in the Main Menu *File -> Export -> To CAD formats...* item.
+
The following property panel will be opened:
.. figure:: images/Export_panel.png
**Export property panel**
-In this panel, it is necessary to select desirable format of export file. It can be **'BREP, STEP, IGES'** or **'XAO'**. In case of first choice the format of exported file will be defined according to file extension. The file name and path can be defined in **Export file** field by direct input or browsing with **'...'** button, which opens **Export file** dialog box:
+In this panel, it is necessary to select desirable format of export file. It can be **'BREP, STEP, IGES'** , **'XAO'** or **'STL'** .
+
+
+Export to BREP, STEP, IGES
+""""""""""""""""""""""""""
+
+In case of first choice the format of exported file will be defined according to file extension. The file name and path can be defined in **Export file** field by direct input or browsing with **'...'** button, which opens **Export file** dialog box:
.. figure:: images/ExportFileDlg.png
:align: center
- **Dialog box tp export in CAD-neutral format**
+ **Dialog box to export in CAD-neutral format**
Selection list in the property panel contains a list of exported objects which can be selected in a viewer or object browser.
+
**Apply** button exports the file.
**Cancel** button cancels the operation.
The Result of operation is an exported file.
**See Also** a sample TUI Script of :ref:`tui_export_file` operation.
+
+Result
+""""""
+
+The Result of operation is an exported file.
+
+**See Also** a sample TUI Script of :ref:`tui_export_file` operation.
+
+Export to STL
+"""""""""""""
+In this case, the following property panel will be opened:
+
+.. figure:: images/ExportSTL.png
+ :align: center
+
+ **Dialog box to export in STL format**
+
+
+The file name and path can be defined in **Export file** field by direct input or browsing with ‘…’ button, which opens Export file dialog box.
+
+**Object** field contains an exported object which can be selected in a viewer or object browser.
+
+**Deflection** (**Relative** or **Absolute**) has to be chosen and defined in the corresponding field as well as the **File type** which can defined as **Binary** or as **ASCII**.
+
+
+**Apply** button exports the file.
+
+**Cancel** button cancels the operation.
+
+**TUI Command**:
+
+.. py:function:: model.exportToSTL(Part_doc, FileNameString, selectedShape, relative, absolute, isRelative, isASCII)
+
+ :param part: The current part object
+ :param string: The file name
+ :param selectedShape: An exporting object
+ :param relative: value of the relative deflection
+ :param absolute: value of the absolute deflection
+ :param isRelative: indicate if use deflection relative
+ :param isASCII: indicate if the file is in ASCII type
+
+Result
+""""""
+
+The Result of operation is an exported STL file.
+
+**See Also** a sample TUI Script of :ref:`tui_export_file_STL` operation.
try
{
- double lDeflection = theDeflection;
+ double aDeflection = theDeflection;
StlAPI_Writer aWriter;
// copy source shape
BRepBuilderAPI_Copy aCopy( theShape->impl<TopoDS_Shape>(), Standard_False );
aWriter.ASCIIMode() = theIsASCII;
if ( theIsRelative ) {
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- Bnd_Box bndBox;
- BRepBndLib::Add( theShape->impl<TopoDS_Shape>(), bndBox );
- bndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
- lDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * theDeflection;
+ Bnd_Box aBndBox;
+ BRepBndLib::Add( theShape->impl<TopoDS_Shape>(), aBndBox );
+ aBndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+ aDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * theDeflection;
}
//Compute triangulation
- BRepMesh_IncrementalMesh aMesh( aCopyShape, lDeflection );
+ BRepTools::Clean( aCopyShape );
+ BRepMesh_IncrementalMesh aMesh( aCopyShape, aDeflection );
+
if (!aWriter.Write( aCopyShape, theFileName.c_str())) {
theError = "STL Export failed";
return false;