From 3ca27a27415fd4b21ee7409dd8194eb6aa13284e Mon Sep 17 00:00:00 2001 From: rraphael Date: Wed, 27 Jan 2021 17:33:41 +0100 Subject: [PATCH] import image: remove from ShaperResult (SHAPERSTUDY) --- src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py | 3 +++ .../ConnectorPlugin_PublishToStudyFeature.py | 5 ++++- src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp | 11 ++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py b/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py index 141155028..4fa7741fa 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py @@ -68,6 +68,9 @@ class ExportFeature(ModelAPI.ModelAPI_Feature): for aResIndex in range(self.Part.size(aResultType)): anObject = self.Part.object(aResultType, aResIndex) aResult = model.objectToResult(anObject) + # do nt export picture + if aResult.hasTextureFile() is True: + continue if not aResult is None: if (not aResult.shape() or aResult.shape().isNull()) and isPart: aPart = model.modelAPI_ResultPart(aResult) diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index a2e401aae..a5d8ed26e 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -90,8 +90,11 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): # 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) + #do not export images + if aRes.hasTextureFile() is True: + continue aResFeatureId = str(aPartDoc.feature(aRes).data().featureId()) if aResFeatureId in aFeaturesIndices: aFeaturesIndices[aResFeatureId] += 1 diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index eb6343737..49f71586d 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -412,6 +412,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) std::list aDocuments; /// documents of Parts selected and used in export std::map aDocTrsf; /// translation of the part + bool anExCludedIsImage = false; AttributeSelectionListPtr aSelection = selectionList(XAO_SELECTION_LIST_ID()); bool aIsSelection = aSelection->isInitialized() && aSelection->size() > 0; if (aIsSelection) { // a mode for export to geom result by result @@ -419,9 +420,12 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) AttributeSelectionPtr anAttr = aSelection->value(a); ResultPtr aBodyContext = std::dynamic_pointer_cast(anAttr->context()); - if (aBodyContext.get() && !aBodyContext->isDisabled() && aBodyContext->shape().get() + if (aBodyContext.get() && !aBodyContext->isDisabled() && aBodyContext->shape().get()) { /// do not export pictures - && !aBodyContext->hasTextureFile()) { + if(aBodyContext->hasTextureFile()){ + anExCludedIsImage = true; + continue; + } aResults.push_back(aBodyContext); GeomShapePtr aShape = anAttr->value(); if (!aShape.get()) @@ -454,7 +458,8 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) } } if (aShapes.empty()) { - setError("No shapes to export"); + if(!anExCludedIsImage) + setError("No shapes to export"); return; } -- 2.39.2