From d5297c3500d8f3ab40d554a6749ddeec0d4871e6 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 22 Dec 2016 14:17:43 +0300 Subject: [PATCH] A unit test for the issue #1799 --- src/CollectionPlugin/CMakeLists.txt | 1 + src/CollectionPlugin/Test/TestGroup1799.py | 118 ++++++++++ src/FeaturesPlugin/Test/TestGroup.py | 247 --------------------- src/Model/Model_SelectionNaming.cpp | 2 +- 4 files changed, 120 insertions(+), 248 deletions(-) create mode 100644 src/CollectionPlugin/Test/TestGroup1799.py delete mode 100644 src/FeaturesPlugin/Test/TestGroup.py diff --git a/src/CollectionPlugin/CMakeLists.txt b/src/CollectionPlugin/CMakeLists.txt index c1b22136e..bce080dc5 100644 --- a/src/CollectionPlugin/CMakeLists.txt +++ b/src/CollectionPlugin/CMakeLists.txt @@ -65,4 +65,5 @@ INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) ADD_UNIT_TESTS( TestGroup.py TestField.py + TestGroup1799.py ) diff --git a/src/CollectionPlugin/Test/TestGroup1799.py b/src/CollectionPlugin/Test/TestGroup1799.py new file mode 100644 index 000000000..70edca220 --- /dev/null +++ b/src/CollectionPlugin/Test/TestGroup1799.py @@ -0,0 +1,118 @@ +# This test is based on the issue 1799: after faces are splitted and group is moved +# down, the group-faces also must be splitted, the AttributeSelectionList should contain +# 4 times more faces. +# The biggest part of the code is python dump of the updated_for_1799.hdf file from this issue. + +import model +from ModelAPI 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")) +SketchLine_1 = Sketch_1.addLine(350, 250, 1.524660639134633e-014, 250) +SketchLine_2 = Sketch_1.addLine(-350, 1.720151798778602e-014, -350, -250) +SketchLine_3 = Sketch_1.addLine(-350, -250, 1.524660628546721e-014, -250) +SketchLine_4 = Sketch_1.addLine(350, -250, 350, 1.720151798778602e-014) +SketchLine_5 = Sketch_1.addLine(350, 1.720151798778602e-014, 350, 250) +SketchLine_5.setName("SketchLine_7") +SketchLine_5.result().setName("SketchLine_7") +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_1.startPoint()) +SketchLine_6 = Sketch_1.addLine(1.524660639134633e-014, 250, -350, 250) +SketchLine_6.setName("SketchLine_5") +SketchLine_6.result().setName("SketchLine_5") +SketchLine_7 = Sketch_1.addLine(-350, 250, -350, 1.720151798778602e-014) +SketchLine_7.setName("SketchLine_6") +SketchLine_7.result().setName("SketchLine_6") +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_8 = Sketch_1.addLine(1.524660628546721e-014, -250, 350, -250) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 101.5814068355669) +SketchPoint_1 = Sketch_1.addPoint(1.524660639134633e-014, 250) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.endPoint()) +SketchPoint_2 = Sketch_1.addPoint(-350, 1.720151798778602e-014) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_2.startPoint()) +SketchPoint_3 = Sketch_1.addPoint(1.524660628546721e-014, -250) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_3.endPoint()) +SketchPoint_4 = Sketch_1.addPoint(101.5814068355669, 1.720151798778602e-014) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchCircle_1.results()[1]) +SketchPoint_5 = Sketch_1.addPoint(-101.5814068355669, 1.720151798778602e-014) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_5.coordinates(), SketchCircle_1.results()[1]) +SketchPoint_6 = Sketch_1.addPoint(1.524660639134633e-014, 101.5814068355669) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchPoint_6.coordinates(), SketchCircle_1.results()[1]) +SketchPoint_7 = Sketch_1.addPoint(1.524660628546721e-014, -101.5814068355669) +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchPoint_7.coordinates(), SketchCircle_1.results()[1]) +SketchPoint_8 = Sketch_1.addPoint(350, 1.720151798778602e-014) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchPoint_8.coordinates(), SketchLine_4.endPoint()) +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_6.startPoint()) +SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_6.result()) +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_2.startPoint()) +SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_7.result()) +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintParallel_3 = Sketch_1.setParallel(SketchLine_4.result(), SketchLine_5.result()) +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_8.startPoint()) +SketchConstraintParallel_4 = Sketch_1.setParallel(SketchLine_3.result(), SketchLine_8.result()) +SketchLine_9 = Sketch_1.addLine(1.524660639134633e-014, 250, 1.524660639134633e-014, 101.5814068355669) +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchPoint_6.coordinates(), SketchLine_9.endPoint()) +SketchLine_10 = Sketch_1.addLine(-101.5814068355669, 1.720151798778602e-014, -350, 1.720151798778602e-014) +SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchPoint_5.coordinates(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_10.endPoint()) +SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_10.endPoint()) +SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_10.endPoint()) +SketchLine_11 = Sketch_1.addLine(1.524660628546721e-014, -250, 1.524660628546721e-014, -101.5814068355669) +SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchPoint_7.coordinates(), SketchLine_11.endPoint()) +SketchLine_12 = Sketch_1.addLine(350, 1.720151798778602e-014, 101.5814068355669, 1.720151798778602e-014) +SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchPoint_8.coordinates(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_12.startPoint()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_9.result()) +SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_11.result()) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_10.result()) +SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_12.result()) +SketchConstraintCoincidence_32 = Sketch_1.setCoincident(SketchLine_9.result(), SketchLine_11.endPoint()) +SketchConstraintCoincidence_33 = Sketch_1.setCoincident(SketchLine_10.result(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_34 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_12.endPoint()) +SketchPoint_9 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin")) +SketchConstraintCoincidence_35 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchPoint_9.coordinates()) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_6.result()) +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_8.result()) +SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_10.result(), SketchLine_12.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_6.result(), 350) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_7.result(), 250) +SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_9.result(), SketchLine_11.result()) +SketchConstraintEqual_5 = Sketch_1.setEqual(SketchLine_7.result(), SketchLine_2.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_5f-SketchLine_6f-SketchLine_9r-SketchLine_10r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchCircle_1_2r-SketchLine_7f-SketchLine_9f-SketchLine_12r"), model.selection("FACE", "Sketch_1/Face-SketchLine_4f-SketchCircle_1_2r-SketchLine_8f-SketchLine_11r-SketchLine_12f"), model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_3f-SketchCircle_1_2r-SketchLine_10f-SketchLine_11f")], model.selection(), 150, 0) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/To_Face_4"), model.selection("FACE", "Extrusion_1_1/To_Face_3"), model.selection("FACE", "Extrusion_1_1/To_Face_2")]) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_12"), 150, True) +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_7"), 150, True) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_1"), model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("FACE", "Plane_2")]) +Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1/Modified_Face_1_2_1"), 110, True) +Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1/Modified_Face_1_9_1"), 380, True) +Partition_2 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_3"), model.selection("COMPSOLID", "Partition_1_1"), model.selection("FACE", "Plane_4")]) +model.do() + +# check that group contains only 4 faces +selectionList = Group_1.feature().selectionList("group_list") +assert(selectionList.size() == 4) +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Group_1.feature())) +# move group to the end: it must be recomputed, faces are splitted +Part_1_doc.moveFeature(Group_1.feature(), Partition_2.feature()) +model.end() + +# check that number of faces becomes 4*4=16 and Group is valid +assert(selectionList.size() == 16) +assert(aFactory.validate(Group_1.feature())) diff --git a/src/FeaturesPlugin/Test/TestGroup.py b/src/FeaturesPlugin/Test/TestGroup.py deleted file mode 100644 index 139d41208..000000000 --- a/src/FeaturesPlugin/Test/TestGroup.py +++ /dev/null @@ -1,247 +0,0 @@ -""" - TestBoolean.py - Unit test of FeaturesPlugin_Group class - - class FeaturesPlugin_Group - static const std::string MY_GROUP_ID("Group"); - static const std::string MY_GROUP_LIST_ID("group_list"); - - data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); -""" -#========================================================================= -# Initialization of the test -#========================================================================= -from ModelAPI import * -from GeomDataAPI import * -from GeomAlgoAPI import * -from GeomAPI import * - -__updated__ = "2014-12-16" - -aSession = ModelAPI_Session.get() -# Create a part for extrusions & boolean -aSession.startOperation() -aPartFeature = aSession.moduleDocument().addFeature("Part") -aSession.finishOperation() -aPart = aSession.activeDocument() -#========================================================================= -# Create a sketch with triangle and extrude it -#========================================================================= -aSession.startOperation() -aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) -origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")) -origin.setValue(0, 0, 0) -dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")) -dirx.setValue(1, 0, 0) -norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")) -norm.setValue(0, 0, 1) -aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine") -aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine") -aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine") -aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint")) -aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint")) -aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint")) -aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint")) -aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint")) -aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint")) -aLineAStartPoint.setValue(-100., 0.) -aLineAEndPoint.setValue(100., 0.) -aLineBStartPoint.setValue(100., 0.) -aLineBEndPoint.setValue(0., 173.2) -aLineCStartPoint.setValue(0., 173.2) -aLineCEndPoint.setValue(-100., 0.) -aSession.finishOperation() -# Build sketch faces -aSession.startOperation() -aSketchResult = aTriangleSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces) -# Create extrusion on them -anExtrusionFt = aPart.addFeature("Extrusion") -anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0]) -anExtrusionFt.string("CreationMethod").setValue("BySizes") -anExtrusionFt.real("to_size").setValue(50) -anExtrusionFt.real("from_size").setValue(50) -anExtrusionFt.real("to_offset").setValue(0) #TODO: remove -anExtrusionFt.real("from_offset").setValue(0) #TODO: remove -anExtrusionFt.execute() -aSession.finishOperation() -anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult()) -#========================================================================= -# Create group of vertex -#========================================================================= -aSession.startOperation() -aGroupFeature = aSession.activeDocument().addFeature("Group") -aSelectionListAttr = aGroupFeature.selectionList("group_list") -aSelectionListAttr.setSelectionType("vertex") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1") -aSession.finishOperation() -#========================================================================= -# Check results -#========================================================================= -assert(aSelectionListAttr.size() == 6) -aGroupResult = aGroupFeature.firstResult() -assert(aGroupResult) -#========================================================================= -# Create group of edges -#========================================================================= -aSession.startOperation() -aGroupFeature = aSession.activeDocument().addFeature("Group") -aSelectionListAttr = aGroupFeature.selectionList("group_list") -aSelectionListAttr.setSelectionType("edge") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1_1") -aSession.finishOperation() -#========================================================================= -# Check results -#========================================================================= -assert(aSelectionListAttr.size() == 9) -aGroupResult = aGroupFeature.firstResult() -assert(aGroupResult) -#========================================================================= -# Create group of faces -#========================================================================= -aSession.startOperation() -aGroupFeature = aSession.activeDocument().addFeature("Group") -aSelectionListAttr = aGroupFeature.selectionList("group_list") -aSelectionListAttr.setSelectionType("face") -aShapeExplorer = GeomAPI_ShapeExplorer(anExtrusionBody.shape(), GeomAPI_Shape.FACE) -while aShapeExplorer.more(): - aSelectionListAttr.append(anExtrusionBody, aShapeExplorer.current()) - aShapeExplorer.next(); -aSession.finishOperation() -#========================================================================= -# Check results -#========================================================================= -assert(aSelectionListAttr.size() == 5) -aGroupResult = aGroupFeature.firstResult() -assert(aGroupResult) -#========================================================================= -# Create group of solids -#========================================================================= -aSession.startOperation() -aGroupFeature = aSession.activeDocument().addFeature("Group") -aSelectionListAttr = aGroupFeature.selectionList("group_list") -aSelectionListAttr.setSelectionType("face") -aSelectionListAttr.append(anExtrusionBody, None) -aSession.finishOperation() -#========================================================================= -# Check results -#========================================================================= -assert(aSelectionListAttr.size() == 1) -aGroupResult = aGroupFeature.firstResult() -assert(aGroupResult) - -#========================================================================= -# Create group of face -#========================================================================= -aSession.startOperation() -aGroupFeature = aSession.activeDocument().addFeature("Group") -aSelectionListAttr = aGroupFeature.selectionList("group_list") -aSelectionListAttr.setSelectionType("face") -aSelectionListAttr.append("Extrusion_1_1/To_Face_1_1") -aSession.finishOperation() -#========================================================================= -# Check results -#========================================================================= -assert(aSelectionListAttr.size() == 1) -aGroupResult = aGroupFeature.firstResult() -assert(aGroupResult) - -#========================================================================= -# Create a sketch circle to extrude -#========================================================================= -aSession.startOperation() -aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")) -origin.setValue(0, 0, 0) -dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")) -dirx.setValue(1, 0, 0) -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")) -norm.setValue(0, 0, 1) -# Create circle -aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle") -anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter")) -aCircleRadius = aSketchCircle.real("CircleRadius") -anCircleCentr.setValue(0., 57.74) -aCircleRadius.setValue(50.) -aSession.finishOperation() -#========================================================================= -# Make extrusion on circle -#========================================================================= -# Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert(len(aCircleSketchFaces) > 0) -assert(aCircleSketchFaces[0] is not None) -# Create extrusion -aSession.startOperation() -anExtrusionFt = aPart.addFeature("Extrusion") -assert (anExtrusionFt.getKind() == "Extrusion") -# selection type FACE=4 -anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchFaces[0]) -anExtrusionFt.string("CreationMethod").setValue("BySizes") -anExtrusionFt.real("to_size").setValue(50) -anExtrusionFt.real("from_size").setValue(50) -anExtrusionFt.real("to_offset").setValue(0) #TODO: remove -anExtrusionFt.real("from_offset").setValue(0) #TODO: remove -anExtrusionFt.execute() -aSession.finishOperation() -aCylinderBody = modelAPI_ResultBody(anExtrusionFt.firstResult()) - -#========================================================================= -# Create a cut -#========================================================================= -aSession.startOperation() -aBooleanFt = aPart.addFeature("Boolean") -aBooleanFt.selectionList("main_objects").append(anExtrusionBody, None) -aBooleanFt.selectionList("tool_objects").append(aCylinderBody, None) -aBooleanTypeCut = 0 -aBooleanFt.integer("bool_type").setValue(aBooleanTypeCut) -aBooleanFt.execute() -aSession.finishOperation() - -#========================================================================= -# Move group feature -#========================================================================= -aSession.startOperation() -aPart.moveFeature(aGroupFeature, aBooleanFt) -aSession.finishOperation() - -#========================================================================= -# Check results -#========================================================================= -aFactory = ModelAPI_Session.get().validators() -assert(aFactory.validate(aGroupFeature)) -assert(aSelectionListAttr.size() == 1) -assert(len(aGroupFeature.results()) > 0) -aGroupResult = aGroupFeature.firstResult() -assert(aGroupResult) -assert(aGroupResult.shape()) -#========================================================================= -# End of test -#========================================================================= - -import model -assert(model.checkPythonDump()) diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp index abaad4b2f..2a1fc259f 100644 --- a/src/Model/Model_SelectionNaming.cpp +++ b/src/Model/Model_SelectionNaming.cpp @@ -381,7 +381,7 @@ const TopoDS_Shape getShapeFromNS( // if we have here the same name as theSubShapeName, there is no index in compound, it is whole Handle(TDataStd_Name) aName; if (!theNS->Label().FindAttribute(TDataStd_Name::GetID(), aName) || - aName->Get() != theSubShapeName.c_str()) { + aName->Get() != aSubString.c_str()) { aSubString = aSubString.substr(n+1); indx = atoi(aSubString.c_str()); } -- 2.39.2