FeaturesAPI_Union.h
FeaturesAPI_FusionFaces.h
FeaturesAPI_Copy.h
+ FeaturesAPI_ImportResult.h
)
SET(PROJECT_SOURCES
FeaturesAPI_Union.cpp
FeaturesAPI_FusionFaces.cpp
FeaturesAPI_Copy.cpp
+ FeaturesAPI_ImportResult.cpp
)
SET(PROJECT_LIBRARIES
%shared_ptr(FeaturesAPI_FusionFaces)
%shared_ptr(FeaturesAPI_RemoveResults)
%shared_ptr(FeaturesAPI_Copy)
+%shared_ptr(FeaturesAPI_ImportResult)
%typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::list<ModelHighAPI_Selection>, bool>, const std::pair<std::list<ModelHighAPI_Selection>, bool> & {
%include "FeaturesAPI_FusionFaces.h"
%include "FeaturesAPI_RemoveResults.h"
%include "FeaturesAPI_Copy.h"
+%include "FeaturesAPI_ImportResult.h"
FEATURESAPI_EXPORT
explicit FeaturesAPI_Copy(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<ModelHighAPI_Selection>& theBaseObjects,
- const int theVersion = 0);
+ const int theNumber);
/// Destructor.
FEATURESAPI_EXPORT virtual ~FeaturesAPI_Copy();
--- /dev/null
+// Copyright (C) 2014-2019 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
+//
+
+#include "FeaturesAPI_ImportResult.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//================================================================================================
+FeaturesAPI_ImportResult::FeaturesAPI_ImportResult(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature) : ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//================================================================================================
+FeaturesAPI_ImportResult::FeaturesAPI_ImportResult(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theObjects) : ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setObjects(theObjects);
+ }
+}
+
+//=================================================================================================
+FeaturesAPI_ImportResult::~FeaturesAPI_ImportResult() {}
+
+//=================================================================================================
+void FeaturesAPI_ImportResult::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
+{
+ fillAttribute(theObjects, myobjects);
+ execute();
+}
+
+//=================================================================================================
+void FeaturesAPI_ImportResult::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+ AttributeSelectionListPtr anObjects =
+ aBase->selectionList(FeaturesPlugin_ImportResult::OBJECTS());
+
+ theDumper << aBase << " = model.addImportResult("
+ << aDocName << ", " << anObjects << ")" << std::endl;
+}
+
+//=================================================================================================
+ImportResultPtr addImportResult(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_ImportResult::ID());
+ return ImportResultPtr(new FeaturesAPI_ImportResult(aFeature, theObjects));
+}
--- /dev/null
+// Copyright (C) 2014-2019 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
+//
+
+#ifndef FeaturesAPI_ImportResult_H_
+#define FeaturesAPI_ImportResult_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_ImportResult.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_ImportResult
+/// \ingroup CPPHighAPI
+/// \brief Interface for ImportResult feature.
+class FeaturesAPI_ImportResult: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_ImportResult(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_ImportResult(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Destructor.
+ FEATURESAPI_EXPORT virtual ~FeaturesAPI_ImportResult();
+
+ INTERFACE_1(FeaturesPlugin_ImportResult::ID(),
+ objects, FeaturesPlugin_ImportResult::OBJECTS(),
+ ModelAPI_AttributeSelectionList, /** Source objects */)
+
+ /// Modify objects attribute of the feature.
+ FEATURESAPI_EXPORT void setObjects(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Dump wrapped feature
+ FEATURESAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on ImportResult object.
+typedef std::shared_ptr<FeaturesAPI_ImportResult> ImportResultPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create ImportResult feature.
+FEATURESAPI_EXPORT
+ImportResultPtr addImportResult(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theObjects);
+
+#endif // FeaturesAPI_ImportResult_H_
#include "FeaturesAPI_FusionFaces.h"
#include "FeaturesAPI_RemoveResults.h"
#include "FeaturesAPI_Copy.h"
+ #include "FeaturesAPI_ImportResult.h"
#endif // FeaturesAPI_swig_H_
FeaturesPlugin_RemoveResults.h
FeaturesPlugin_Chamfer.h
FeaturesPlugin_Copy.h
+ FeaturesPlugin_ImportResult.h
)
SET(PROJECT_SOURCES
FeaturesPlugin_RemoveResults.cpp
FeaturesPlugin_Chamfer.cpp
FeaturesPlugin_Copy.cpp
+ FeaturesPlugin_ImportResult.cpp
)
SET(XML_RESOURCES
fusion_faces_widget.xml
chamfer_widget.xml
copy_widget.xml
+ import_result_widget.xml
)
SET(TEXT_RESOURCES
TestCopyNames.py
TestCopySubShapes.py
TestCopyWholeFeature.py
+ TestImportResult.py
)
--- /dev/null
+// Copyright (C) 2017-2019 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
+//
+
+#include "FeaturesPlugin_ImportResult.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_ResultPart.h>
+#include <Events_InfoMessage.h>
+
+void FeaturesPlugin_ImportResult::initAttributes()
+{
+ data()->addAttribute(OBJECTS(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+void FeaturesPlugin_ImportResult::execute()
+{
+ AttributeSelectionListPtr aList = selectionList(OBJECTS());
+ int aResultIndex = 0;
+ for (int aSelIndex = 0; aSelIndex < aList->size(); aSelIndex++) {
+ AttributeSelectionPtr aSel = aList->value(aSelIndex);
+ ResultPtr aContext = aSel->context();
+ if (!aContext.get())
+ continue;
+ GeomShapePtr aShape = aContext->shape();
+ if (!aShape.get() || aShape->isNull())
+ continue;
+ std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
+ aResultBody->store(aShape);
+ aResultBody->loadFirstLevel(aShape, "ImportResult");
+ setResult(aResultBody, aResultIndex++);
+ }
+ removeResults(aResultIndex);
+}
+
+bool FeaturesPlugin_ValidatorImportResults::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>&, Events_InfoMessage& theError) const
+{
+ AttributeSelectionListPtr aList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if (aList->size() == 0) {
+ // LCOV_EXCL_START
+ theError = "Please select sources.";
+ return false;
+ // LCOV_EXCL_STOP
+ }
+ // store documents in the Part-fesatures in order to check
+ // the selection is located in the previous documents
+ std::map<DocumentPtr, int> aDocIndices;
+ DocumentPtr aRoot = ModelAPI_Session::get()->moduleDocument();
+ int aNum = aRoot->size(ModelAPI_Feature::group());
+ for (int a = 0; a < aNum; a++) {
+ FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(
+ aRoot->object(ModelAPI_Feature::group(), a));
+ if (aFeat.get() && aFeat->data() && aFeat->data()->isValid() && aFeat->getKind() == "Part" &&
+ aFeat->results().size()) {
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aFeat->firstResult());
+ if (aPart.get() && aPart->partDoc()) {
+ aDocIndices[aPart->partDoc()] = a;
+ }
+ }
+ }
+ int aThisIndex = aDocIndices[aList->owner()->document()];
+ for (int aSelIndex = 0; aSelIndex < aList->size(); aSelIndex++) {
+ AttributeSelectionPtr aSel = aList->value(aSelIndex);
+ ResultPtr aContext = aSel->context();
+ if (!aContext.get()) {
+ // LCOV_EXCL_START
+ theError = "Empty context.";
+ return false;
+ // LCOV_EXCL_STOP
+ }
+ GeomShapePtr aShape = aSel->value();
+ if (aShape.get() && !aShape->isNull() && !aShape->isSame(aContext->shape())) {
+ // LCOV_EXCL_START
+ theError = "Import results does not support selection of sub-shapes";
+ return false;
+ // LCOV_EXCL_STOP
+ }
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContext);
+ if (!aBody.get()) {
+ // LCOV_EXCL_START
+ theError = "Only results may be selected.";
+ return false;
+ // LCOV_EXCL_STOP
+ }
+ if (!aBody->shape()) {
+ // LCOV_EXCL_START
+ theError = "Result is empty.";
+ return false;
+ // LCOV_EXCL_STOP
+ }
+ int aBodyIndex = aDocIndices[aBody->document()];
+ if (aBodyIndex >= aThisIndex) {
+ theError = "The selected result must be located in earlier part.";
+ return false;
+ }
+ }
+ return true;
+}
--- /dev/null
+// Copyright (C) 2017-2019 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
+//
+
+#ifndef FeaturesPlugin_ImportResult_H_
+#define FeaturesPlugin_ImportResult_H_
+
+#include "FeaturesPlugin.h"
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_AttributeValidator.h>
+
+/// \class FeaturesPlugin_ImportResult
+/// \ingroup Plugins
+/// \brief The Import Result feature allows the user to import one or several results
+/// from another Part.
+
+class FeaturesPlugin_ImportResult : public ModelAPI_Feature
+{
+public:
+ /// Feature kind.
+ inline static const std::string& ID()
+ {
+ static const std::string MY_ID("ImportResult");
+ return MY_ID;
+ }
+
+ /// \return the kind of a feature.
+ FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = FeaturesPlugin_ImportResult::ID();
+ return MY_KIND;
+ }
+
+ /// Selection list attribute that contains all copied shapes selection.
+ inline static const std::string& OBJECTS()
+ {
+ static const std::string MY_OBJECTS("objects");
+ return MY_OBJECTS;
+ }
+
+ /// Performs the algorithm and stores results it in the data structure.
+ FEATURESPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes.
+ FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Use plugin manager for features creation.
+ FeaturesPlugin_ImportResult() {}
+};
+
+/// \class FeaturesPlugin_ValidatorImportResults
+/// \ingroup Validators
+/// \brief A validator for selection of objects that may be imported:
+/// from another part, result bodies.
+class FeaturesPlugin_ValidatorImportResults : public ModelAPI_AttributeValidator
+{
+public:
+ //! \return True if selection is valid.
+ //! \param[in] theAttribute the checked attribute.
+ //! \param[in] theArguments arguments of the attribute.
+ //! \param[out] theError error message.
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments, Events_InfoMessage& theError) const;
+};
+
+#endif
#include <FeaturesPlugin_FusionFaces.h>
#include <FeaturesPlugin_RemoveResults.h>
#include <FeaturesPlugin_Copy.h>
+#include <FeaturesPlugin_ImportResult.h>
#include <FeaturesPlugin_ValidatorTransform.h>
#include <FeaturesPlugin_Validators.h>
new FeaturesPlugin_ValidatorBooleanCommonSelection);
aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanCommonArguments",
new FeaturesPlugin_ValidatorBooleanCommonArguments);
+ aFactory->registerValidator("FeaturesPlugin_ValidatorImportResults",
+ new FeaturesPlugin_ValidatorImportResults);
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
return FeaturePtr(new FeaturesPlugin_Chamfer);
} else if (theFeatureID == FeaturesPlugin_Copy::ID()) {
return FeaturePtr(new FeaturesPlugin_Copy);
+ } else if (theFeatureID == FeaturesPlugin_ImportResult::ID()) {
+ return FeaturePtr(new FeaturesPlugin_ImportResult);
}
<source>Copy</source>
<translation>Copie</translation>
</message>
+ <message>
+ <source>Import Result</source>
+ <translation>Importer le résultat</translation>
+ </message>
<message>
<source>Remove Sub-Shapes</source>
<translation>Supprimer les sous-formes</translation>
</message>
</context>
+ <!-- Import result -->
+ <context>
+ <name>ImportResult</name>
+ <message>
+ <source>ImportResult</source>
+ <translation>Importer le résultat</translation>
+ </message>
+ <message>
+ <source>Copies results from other parts</source>
+ <translation>Copie les résultats d'autres pièces</translation>
+ </message>
+ </context>
+ <context>
+ <name>ImportResult:objects</name>
+ <message>
+ <source>Sources:</source>
+ <translation>Sources:</translation>
+ </message>
+ <message>
+ <source>Select copied results</source>
+ <translation>Sélectionnez les résultats copiés</translation>
+ </message>
+ </context>
+
<!-- Remove_SubShapes -->
<context>
<name>Remove_SubShapes</name>
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+from salome.shaper import model
+from ModelAPI import *
+from GeomAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(15, 13, 11)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
+model.do()
+
+Part_2 = model.addPart(partSet)
+Part_2_doc = Part_2.document()
+Sketch_2 = model.addSketch(Part_2_doc, model.defaultPlane("XOZ"))
+SketchCircle_2 = Sketch_2.addCircle(-13, -9, 5)
+model.do()
+Extrusion_2 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
+ImportResult_1 = model.addImportResult(Part_2_doc, [model.selection("SOLID", "Part_1/Extrusion_1_1")])
+model.do()
+
+Part_3 = model.addPart(partSet)
+Part_3_doc = Part_3.document()
+Extrusion_3 = model.addExtrusion(Part_3_doc, [], model.selection(), 1, 0)
+Sketch_3 = model.addSketch(Part_3_doc, model.defaultPlane("XOZ"))
+SketchCircle_3 = Sketch_3.addCircle(-4, 2, 5)
+Extrusion_3.setNestedSketch(Sketch_3)
+model.do()
+
+model.end()
+
+# check Part_2 is ok and contains 2 solids in result
+assert(Part_2.feature().results().size() == 1)
+aPartShape = Part_2.feature().firstResult().shape()
+assert(aPartShape.shapeTypeStr() == "COMPOUND")
+aShapeExplorer = GeomAPI_ShapeExplorer(aPartShape, GeomAPI_Shape.SOLID)
+assert(aShapeExplorer.more())
+aShapeExplorer.next()
+assert(aShapeExplorer.more())
+
+# check that selection of this part and the lower part is impossible (by validator)
+model.begin()
+aSel = ImportResult_1.feature().selectionList("objects").value(0)
+aSel.selectSubShape("SOLID", "Part_2/Extrusion_1_1")
+model.end()
+aFactory = ModelAPI_Session.get().validators()
+assert(not aFactory.validate(ImportResult_1.feature()))
+
+model.begin()
+aSel = ImportResult_1.feature().selectionList("objects").value(0)
+aSel.selectSubShape("SOLID", "Part_3/Extrusion_1_1")
+model.end()
+assert(not aFactory.validate(ImportResult_1.feature()))
+
+# back to correct value
+model.begin()
+aSel = ImportResult_1.feature().selectionList("objects").value(0)
+aSel.selectSubShape("SOLID", "Part_1/Extrusion_1_1")
+model.end()
+assert(aFactory.validate(ImportResult_1.feature()))
+
+# TODO: implement for GEOMOETRICAL also
+assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING))
filletFeature.rst
fuseFeature.rst
fuseFeatureFaces.rst
+ importResult.rst
intersectionFeature.rst
linearCopyFeature.rst
measurementFeature.rst
--- /dev/null
+
+ .. _tui_create_import_result:
+
+Create Import Result
+============
+
+.. literalinclude:: examples/import_result.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/import_result.py>`
+
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(21, 16, 6)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
+model.do()
+Part_2 = model.addPart(partSet)
+Part_2_doc = Part_2.document()
+ImportResult_1 = model.addImportResult(Part_2_doc, [model.selection("SOLID", "Part_1/Extrusion_1_1")])
+model.end()
--- /dev/null
+.. |import_result_btn.icon| image:: images/import_result_btn.png
+
+Import Result
+=====
+
+The Import Result feature allows the user to import one or several results from another Part. If the result of the source-part is
+changed, the part and part result that contains the copy-results will be updated. The feature keeps the
+copy-shape, so, even the document was opened and the source-part was not activated (loaded), the part with copy-feature works well
+with this result-shape.
+
+It may be necessary for the user to load the other parts before using this feature otherwise the content of the **Results** folders will be empty.
+
+To create a Copy in the active part:
+
+#. select in the Main Menu *Features - > Import Result* item or
+#. click |import_result_btn.icon| **Import Result** button in the toolbar
+
+
+The following property panel will be opened:
+
+.. image:: images/ImportResult.png
+ :align: center
+
+.. centered::
+ **Import result operation**
+
+Here it is necessary to select one or several objects. It is only possible to import results from Parts placed before the
+current Part where the import is done. Only results from the **Results** folder of previously created parts may be selected.
+
+
+**Apply** button creates a copy.
+
+**Cancel** button cancels the operation.
+
+**TUI Command**:
+
+.. py:function:: model.addImportResult(Part_doc, results)
+
+ :param part: The current part object.
+ :param results: A list of results from another part.
+ :return: Result feature Import Result.
+
+Result
+""""""
+
+The Result of the operation will be copy of one or several results selected in another part located in the same place:
+
+.. image:: images/CreatedImportResult.png
+ :align: center
+
+.. centered::
+ **Import result created**
+
+**See Also** a sample TUI Script of :ref:`tui_create_import_result` operation.
--- /dev/null
+<source>
+ <multi_selector id="objects"
+ label="Sources:"
+ tooltip="Select copied results"
+ shape_types="objects"
+ use_choice="false"
+ concealment="false"
+ allow_parts_content="true">
+ <validator id="FeaturesPlugin_ValidatorImportResults"/>
+ </multi_selector>
+</source>
helpfile="copyFeature.html">
<source path="copy_widget.xml"/>
</feature>
+ <feature id="ImportResult"
+ title="Import Result"
+ tooltip="Copies results from other parts"
+ icon="icons/Features/import_result.png"
+ helpfile="importResultFeature.html">
+ <source path="import_result_widget.xml"/>
+ </feature>
<feature id="RemoveResults" title="Remove results" tooltip="Internal feature for results removal" internal="1">
<multi_selector id="results" concealment="true"/>
</feature>
Handle(TDataStd_AsciiString) anEntry;
if (myRef->Label().FindAttribute(TDataStd_AsciiString::GetID(), anEntry)) {
std::shared_ptr<Model_Document> aDR = std::dynamic_pointer_cast<Model_Document>(aRefDoc);
- TDF_Label aRefLab;
- TDF_Tool::Label(aDR->objects()->featuresLabel().Data(),
- anEntry->Get().ToCString(), aRefLab);
- if (!aRefLab.IsNull()) {
- return aDR->objects()->object(aRefLab);
+ if (aDR.get() && aDR->objects()) {
+ TDF_Label aRefLab;
+ TDF_Tool::Label(aDR->objects()->featuresLabel().Data(),
+ anEntry->Get().ToCString(), aRefLab);
+ if (!aRefLab.IsNull()) {
+ return aDR->objects()->object(aRefLab);
+ }
}
}
}
if (aPartName == aRootDoc->kind()) {
aDoc = std::dynamic_pointer_cast<Model_Document>(aRootDoc);
aSubShapeName = aSubShapeName.substr(aPartEnd + 1);
- } else {
+ }
+ else {
ObjectPtr aFound =
owner()->document()->objectByName(ModelAPI_ResultPart::group(), aPartName);
if (aFound.get()) { // found such part, so asking it for the name
continue;
std::shared_ptr<GeomAPI_Edge> aSelectedEdge(new GeomAPI_Edge(aSelected));
setValueCenter(aPart, aSelectedEdge, aCenterType);
- } else
+ }
+ else
setValue(aPart, aSelected);
TDataStd_Integer::Set(selectionLabel(), anIndex);
return;
}
+ } else { // for the ImportResult feature Objects widget this may be a result in other part
+ // result may be hidden (like, tranlsatiomn of part) in PartSet, so iterate Part-features
+ int aNum = aRootDoc->size(ModelAPI_Feature::group());
+ for (int a = 0; a < aNum; a++) {
+ FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(
+ aRootDoc->object(ModelAPI_Feature::group(), a));
+ if (aFeat.get() && aFeat->data() && aFeat->data()->isValid() &&
+ aFeat->getKind() == "Part" && aFeat->results().size()) {
+ ResultPartPtr aPart =
+ std::dynamic_pointer_cast<ModelAPI_ResultPart>(aFeat->firstResult());
+ if (aPart.get() && aPart->partDoc().get() && aPart->data()->name() == aPartName) {
+ aDoc = std::dynamic_pointer_cast<Model_Document>(aPart->partDoc());
+ aSubShapeName = aSubShapeName.substr(aPartEnd + 1);
+ }
+ }
+ }
}
}
}
if (aObj) {
DocumentPtr aDoc = aObj->document();
SessionPtr aMgr = ModelAPI_Session::get();
+ // TODO: disable the next line for the ImportResult feature "objects" widget only
aValid = (aDoc == aMgr->activeDocument() || aDoc == aMgr->moduleDocument());
}
else {
from FeaturesAPI import addFusionFaces
from FeaturesAPI import measureLength, measureDistance, measureRadius, measureAngle
from FeaturesAPI import addRemoveResults
-from FeaturesAPI import addCopy
+from FeaturesAPI import addCopy, addImportResult