# Map from feature index to index of result. If index is zero (initial), no surrfix to entry is added.
aFeaturesIndices = {}
for aResId in range(aPartDoc.size(model.ModelAPI_ResultBody_group())):
- aResObject = aPartDoc.object(model.ModelAPI_ResultBody_group(), aResId)
+ aResObject = aPartDoc.object(model.ModelAPI_ResultBody_group(), aResId)
aRes = model.objectToResult(aResObject)
- continue
+ #do not export images
+ if aRes.hasTextureFile() is True:
++ continue
aResFeatureId = str(aPartDoc.feature(aRes).data().featureId())
if aResFeatureId in aFeaturesIndices:
aFeaturesIndices[aResFeatureId] += 1
if (aCurrentFeature)
thePart->setCurrentFeature(aCurrentFeature, THE_VISIBLE_FEATURE);
}
-
+
+ //-------------------------------------------------------------------------------------------------
+ //-------------------------------------------------------------------------------------------------
+
+ ExchangeAPI_Import_Image::ExchangeAPI_Import_Image(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature)
+ : ModelHighAPI_Interface(theFeature)
+ {
+ initialize();
+ }
+
+ ExchangeAPI_Import_Image::ExchangeAPI_Import_Image(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::string & theFilePath)
+ : ModelHighAPI_Interface(theFeature)
+ {
+ if (initialize())
+ setFilePath(theFilePath);
+ }
+
+ void ExchangeAPI_Import_Image::setFilePath(const std::string & theFilePath)
+ {
+ fillAttribute(theFilePath, myfilePath);
+ execute();
+ }
+
+ ImportImagePtr addImportImage(
+ const std::shared_ptr<ModelAPI_Document> & thePart,
+ const std::string & theFilePath)
+ {
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ExchangeAPI_Import_Image::ID());
+ return ImportImagePtr(new ExchangeAPI_Import_Image(aFeature, theFilePath));
+ }
+
+ void ExchangeAPI_Import_Image::dump(ModelHighAPI_Dumper& theDumper) const
+ {
+ FeaturePtr aBase = feature();
+ std::string aPartName = theDumper.name(aBase->document());
+
+ std::string aFilePath =
+ aBase->string(ExchangePlugin_Import_ImageFeature::FILE_PATH_ID())->value();
+
+ theDumper << aBase << " = model.addImportImage(" << aPartName << ", \""
+ << aFilePath << "\")" << std::endl;
+
+ // to make import have results
+ theDumper << "model.do()" << std::endl;
+ }
*
* The list of supported formats is defined in the configuration file.
*/
- class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature
+ class ExchangePlugin_ImportFeatureBase : public ModelAPI_CompositeFeature
{
- public:
- /// Feature kind
- inline static const std::string& ID()
- {
- static const std::string MY_IMPORT_ID("Import");
- return MY_IMPORT_ID;
- }
- /// Feature kind
- inline static const std::string& IMPORT_TYPE_ID()
- {
- static const std::string MY_IMPORT_TYPE_ID("ImportType");
- return MY_IMPORT_TYPE_ID;
- }
- public:
++public:
/// attribute name of file path
inline static const std::string& FILE_PATH_ID()
{
</groupbox>
</groupbox>
</case>
- </switch>
+ </switch>
+ </feature>
+ <feature id="ImportImageMacro" title="Import" tooltip="Import a file" icon="icons/Exchange/import.png"
+ helpfile="importFeature.html"
+ internal="1">
+ <file_selector id="file_path" title="Import image file" path="">
+ <validator id="ExchangePlugin_ImportFormat" parameters="GIF|TIFF|PNG|JPG|JPEG|BMP|PPM|JPE:Image" />
+ </file_selector>
+ <choice id="target_part"
+ string_list_attribute="target_parts_list"
+ label="Import to"
+ tooltip="Select the image to import the document" />
</feature>
<feature id="Import" title="Import" tooltip="Import a file" icon="icons/Exchange/import.png"
helpfile="importFeature.html" internal="1">
--- /dev/null
+# Copyright (C) 2021 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SET(TEST_NAMES
+ TestRectangle.py
++ TestRectangleCentered.py
+ TestcompoundVertices.py
+ TestimportParameters.py
+)
Part_1_doc = Part_1.document()
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(5.5, 8.5, 31.3, 78.9)
-# rectangle from center and end points
++# rectangle from center and end points
+ center = geom.Pnt2d(10, 5)
+ corner = geom.Pnt2d(25, 75)
+ rectangle_2 = sketch.addRectangleCentered(center, corner)
+
model.do()
model.end()