SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
model.do()
-Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 100, 0)
-Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1")])
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f_wire")], model.selection(), 100, 0)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]")])
model.do()
model.testHaveNamingSubshapes(Edge_1, model, Part_1_doc)
SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_13.result())
SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_8.result())
model.do()
-Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_10r-SketchLine_11r-SketchLine_12r")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_13"), 360, 0)
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_12r-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection("EDGE", "Sketch_1/SketchLine_13"), 360, 0)
model.do()
# check that naming of the revolution is correct
model.testHaveNamingSubshapes(Revolution_1, model, Part_1_doc)
Vertex_4 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_2")])
Cut_1 = model.addCut(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], [model.selection("VERTEX", "Vertex_2_1")])
Cut_2 = model.addCut(Part_1_doc, [model.selection("VERTEX", "Vertex_3_1")], [model.selection("VERTEX", "Vertex_4_1")])
-model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc)
model.testHaveNamingSubshapes(Cut_2, model, Part_1_doc)
model.do()
model.end()
const std::shared_ptr<ModelAPI_Result>& theResult)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theResult->data());
- if (aData.get()) {
+ if (aData.get() && aData->isValid()) {
TDF_Label aFeatureLab = aData->label().Father().Father().Father();
FeaturePtr aFeature = feature(aFeatureLab);
while(!aFeature.get() && aFeatureLab.Depth() > 1) { // this may be sub-result of result
while (!myResults.empty()) { // remove one by one with messages
std::shared_ptr<ModelAPI_Result> aRes = *(myResults.begin());
aRes->setDisabled(aRes, true); // to avoid activation of the Part result
- if (!myResults.empty()) // disabling result may erase the list (on undo of Part, issue 665)
+ if (!myResults.empty()) {// disabling result may erase the list (on undo of Part, issue 665)
myResults.erase(myResults.begin());
+ aRes->erase();
+ }
}
ModelAPI_Object::erase();
}
class ModelAPI_Data;
class ModelAPI_Document;
-// sometimes it is usefull for debug to see name of each object (bad for memory and performance)
+// sometimes it is useful for debug to see name of each object (bad for memory and performance)
//#define DEBUG_NAMES
/**\class ModelAPI_Object
MODELAPI_EXPORT virtual void erase();
friend class Model_Objects;
+ friend class ModelAPI_Feature;
friend class Model_Document;
};
SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
model.do()
-Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0)
-Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f"))
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0)
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"))
SketchLine_5 = Sketch_2.addLine(-3.660618520812283, -7.666051414039341, -9.927240775274454, -7.666051414039341)
SketchLine_6 = Sketch_2.addLine(-9.927240775274454, -7.666051414039341, -9.927240775274454, 7.885614342469023)
SketchLine_7 = Sketch_2.addLine(-9.927240775274454, 7.885614342469023, -3.660618520812283, 7.885614342469023)
SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result())
SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result())
model.do()
-Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")], model.selection(), 10, 0)
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r")], model.selection(), 10, 0)
Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")])
model.do()
model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc)
SketchConstraintDistance_9 = Sketch_2.setDistance(SketchLine_19.startPoint(), SketchLine_22.result(), "(TL/2-3)-20", True)
SketchConstraintDistance_10 = Sketch_2.setDistance(SketchLine_19.endPoint(), SketchLine_22.result(), "(TL/2-3)-20", True)
model.do()
-Wire_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_11"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_10"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_4_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_12"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_14"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_13"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_15"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_5_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_16"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_3_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]
+Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_11"), model.selection("EDGE", "Sketch_1/SketchLine_10"), model.selection("EDGE", "Sketch_1/SketchArc_4_2"), model.selection("EDGE", "Sketch_1/SketchLine_12"), model.selection("EDGE", "Sketch_1/SketchLine_14"), model.selection("EDGE", "Sketch_1/SketchLine_13"), model.selection("EDGE", "Sketch_1/SketchLine_15"), model.selection("EDGE", "Sketch_1/SketchArc_5_2"), model.selection("EDGE", "Sketch_1/SketchLine_16"), model.selection("EDGE", "Sketch_1/SketchLine_9"), model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchArc_3_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_1")]
Wire_1 = model.addWire(Part_1_doc, Wire_1_objects)
-Wire_2_objects = [model.selection("EDGE", "Sketch_2/Edge-SketchLine_17"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_20"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_19"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_18"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_6_2")]
+Wire_2_objects = [model.selection("EDGE", "Sketch_2/SketchLine_17"), model.selection("EDGE", "Sketch_2/SketchArc_7_2"), model.selection("EDGE", "Sketch_2/SketchLine_20"), model.selection("EDGE", "Sketch_2/SketchLine_19"), model.selection("EDGE", "Sketch_2/SketchLine_18"), model.selection("EDGE", "Sketch_2/SketchArc_6_2")]
Wire_2 = model.addWire(Part_1_doc, Wire_2_objects)
Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_1_1")])
Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_2_1")])
SketchConstraintVertical_10 = Sketch_1.setVertical(SketchLine_20.result())
model.do()
Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 100)
-Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], model.selection("EDGE", "Extrusion_1_1/Generated_Face_24&Extrusion_1_1/To_Face_2"), 200)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_20][Extrusion_1_1_2/To_Face]"), 200)
Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 50)
-Translation_2 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_2_1")], model.selection("EDGE", "Extrusion_2_1/Generated_Face_24&Extrusion_2_1/To_Face_2"), 150)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_2_1")], model.selection("EDGE", "[Extrusion_2_1_2/Generated_Face&Sketch_1/SketchLine_20][Extrusion_2_1_2/To_Face]"), 150)
Boolean_1 = model.addCut(Part_1_doc, [model.selection("COMPSOLID", "Translation_1_1")], [model.selection("COMPSOLID", "Translation_2_1")])
model.do()
model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc)
""" Tests if all vertices/edges/faces of result have a unique name
:param theFeature: feature to test.
"""
+ assert(len(theFeature.results()) > 0)
testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.VERTEX)
testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.EDGE)
testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.FACE)