#=========================================================================
# Modify the cylindrical hole base face by another groove in the history before the hole is created
#=========================================================================
-ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), -50, [model.selection("SOLID", "ExtrusionCut_1_1")])
+ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"))
SketchLine_9 = Sketch_4.addLine(-176.701443076057, -151.212050129331, -91.83965287802501, -151.212050129331)
SketchLine_10 = Sketch_4.addLine(-91.83965287802501, -151.212050129331, -91.83965287802501, -84.473709256573)
assert(ModelAPI.ModelAPI_Session.get().validators().validate(Sketch_4.feature()))
assert(ModelAPI.ModelAPI_Session.get().validators().validate(ExtrusionCut_2.feature()))
-assert(Sketch_3.feature().selection("External").namingName() == "(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_3_1/Modified_Face&Sketch_2/SketchLine_6)(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4)")
+assert(Sketch_3.feature().selection("External").namingName() == "(ExtrusionCut_3_1/Modified_Face&Sketch_2/SketchLine_6)(ExtrusionCut_3_1/Modified_Face&Sketch_1/SketchLine_4)(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face)")
assert(model.checkPythonDump())
void Selector_Algo::storeType(const Selector_Type theType)
{
+ myLab.ForgetAllAttributes(true);
TDataStd_Integer::Set(myLab, kSEL_TYPE, (int)(theType));
if (myGeometricalNaming)
TDataStd_UAttribute::Set(myLab, kGEOMETRICAL_NAMING);
return false;
}
-const std::list<Selector_Algo*>& Selector_AlgoWithSubs::list() const
+std::list<Selector_Algo*>& Selector_AlgoWithSubs::list()
{
return mySubSelList;
}
/// Appends a new algorithm to the list, erases list if it is null (failed)
bool append(Selector_Algo* theAlgo, const bool theEraseIfNull = true);
/// Returns the stored list of sub-algorithms.
- const std::list<Selector_Algo*>& list() const;
+ std::list<Selector_Algo*>& list();
};
#endif
TDataStd_IntegerArray::Set(label(), kLEVELS_ARRAY, 0, int(myNBLevel.size()) - 1);
std::list<int>::iterator aLevel = myNBLevel.begin();
for(int anIndex = 0; aLevel != myNBLevel.end(); aLevel++, anIndex++) {
- anArray->SetValue(anIndex, *aLevel);
+ anArray->SetValue(anIndex, Abs(*aLevel));
}
// store all sub-selectors
std::list<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
for(TDF_ChildIterator aSub(label(), false); aSub.More(); aSub.Next()) {
Selector_Algo* aSubSel = restoreByLab(aSub.Value(), baseDocument());
if (!append(aSubSel, false)) {
- break; // some empty label left in the end
+ if (!aSub.Value().HasAttribute())
+ break; // some empty label left in the end
+ // some selector fails, try to use rest selectors, myNBLevel becomes negative: unused
+ if (myNBLevel.size() > list().size()) {
+ std::list<int>::iterator aListIter = myNBLevel.begin();
+ for(int a = 0; a < list().size(); a++)
+ aListIter++;
+ *aListIter = -*aListIter;
+ list().push_back(NULL);
+ }
}
}
- return myNBLevel.size() == list().size();
+ return myNBLevel.size() == list().size() && !myNBLevel.empty();
}
TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName,
std::list<int>::iterator aLevel = myNBLevel.begin();
std::list<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
for(; aSubSel != list().cend(); aSubSel++, aLevel++) {
- if (!(*aSubSel)->solve(theContext)) {
- return false;
+ if (*aLevel < 0)
+ continue; // skip because sub-selector is not good
+ if ((*aSubSel)->solve(theContext)) {
+ aNBs.push_back(std::pair<TopoDS_Shape, int>((*aSubSel)->value(), *aLevel));
}
- aNBs.push_back(std::pair<TopoDS_Shape, int>((*aSubSel)->value(), *aLevel));
}
- aResult = findNeighbor(theContext, aNBs, geometricalNaming());
- if (!aResult.IsNull()) {
- Selector_Algo::store(aResult);
- return true;
+ if (!aNBs.empty()) {
+ aResult = findNeighbor(theContext, aNBs, geometricalNaming());
+ if (!aResult.IsNull()) {
+ Selector_Algo::store(aResult);
+ return true;
+ }
}
return false;
}
std::list<int>::iterator aLevel = myNBLevel.begin();
std::list<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
for(; aSubSel != list().cend(); aSubSel++, aLevel++) {
+ if (!*aSubSel)
+ continue;
aResult += "(" + (*aSubSel)->name(theNameGenerator) + ")";
if (*aLevel > 1) {
std::ostringstream aLevelStr;
SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_1.results()[1], "50/2")
model.do()
ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2f_wire")], model.selection(), 0, 13, [model.selection("SOLID", "Extrusion_1_1")])
-Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "_weak_name_6_ExtrusionCut_1_1"))
-SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9][_weak_name_6_ExtrusionCut_1_1]"), False)
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&ExtrusionCut_1_1/From_Face"))
+SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "ExtrusionCut_1_1/Generated_Vertex&ExtrusionCut_1_1/From_Face"), False)
SketchPoint_3 = SketchProjection_2.createdFeature()
-SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9][_weak_name_6_ExtrusionCut_1_1]"), False)
+SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_2"), False)
SketchLine_11 = SketchProjection_3.createdFeature()
SketchArc_3 = Sketch_3.addArc(-15, 35, -15, 46.0103340429751, -17.02045759563166, 24.17663606626138, True)
SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchPoint_3.result(), SketchArc_3.center())
SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_11.result(), SketchArc_3.startPoint())
-SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2][_weak_name_6_ExtrusionCut_1_1]"), False)
+SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_1"), False)
SketchArc_4 = SketchProjection_4.createdFeature()
SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchArc_3.endPoint(), SketchArc_4.results()[1])
SketchLine_12 = Sketch_3.addLine(-15, 46.0103340429751, -15, 35)