SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
-SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()[0])
-SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()[0])
-SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()[0])
-SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()[0])
+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())
model.do()
Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")])
Wire_1.addContour()
# Test an axis by line
aSession.startOperation()
-anAxis = model.addAxis(aPart, aSketchLine.result()[0])
+anAxis = model.addAxis(aPart, aSketchLine.result())
aSession.finishOperation()
-assert (len(anAxis.result()) > 0)
+assert (len(anAxis.results()) > 0)
# Create plane
aSession.startOperation()
# Test an axis by plane and point
aSession.startOperation()
-anAxis = model.addAxis(aPart, aPlane1.result()[0], aSketchPoint.result()[0])
+anAxis = model.addAxis(aPart, aPlane1.result(), aSketchPoint.result())
aSession.finishOperation()
-assert (len(anAxis.result()) > 0)
+assert (len(anAxis.results()) > 0)
# Create plane
aSession.startOperation()
# Test an axis by two planes
aSession.startOperation()
-anAxis = model.addAxis(aPart, aPlane1.result()[0], aPlane2.result()[0])
+anAxis = model.addAxis(aPart, aPlane1.result(), aPlane2.result())
aSession.finishOperation()
-assert (len(anAxis.result()) > 0)
+assert (len(anAxis.results()) > 0)
# Test an axis by two planes and offsets
aSession.startOperation()
-anAxis = model.addAxis(aPart, aPlane1.result()[0], 50, False, aPlane2.result()[0], 100, True)
+anAxis = model.addAxis(aPart, aPlane1.result(), 50, False, aPlane2.result(), 100, True)
aSession.finishOperation()
-assert (len(anAxis.result()) > 0)
+assert (len(anAxis.results()) > 0)
import model
assert(model.checkPythonDump())
aSession.startOperation()
aPlane = model.addPlane(aDocument, 1, 1, 1, 0)
aSession.finishOperation()
-assert (len(aPlane.result()) > 0)
+assert (len(aPlane.results()) > 0)
# Create a point 1
aSession.startOperation()
# Test a plane by three points
aSession.startOperation()
-aPlane = model.addPlane(aDocument, aPoint1.result()[0], aPoint2.result()[0], aPoint3.result()[0])
+aPlane = model.addPlane(aDocument, aPoint1.result(), aPoint2.result(), aPoint3.result())
aSession.finishOperation()
-assert (len(aPlane.result()) > 0)
+assert (len(aPlane.results()) > 0)
# Create an axis
aSession.startOperation()
# Test a plane by line and point
aSession.startOperation()
-aPlane = model.addPlane(aDocument, anAxis.result()[0], aPoint3.result()[0], True)
+aPlane = model.addPlane(aDocument, anAxis.result(), aPoint3.result(), True)
aSession.finishOperation()
-assert (len(aPlane.result()) > 0)
+assert (len(aPlane.results()) > 0)
# Test a plane by distance from other
aSession.startOperation()
-aPlane = model.addPlane(aDocument, aPlane.result()[0], 50, False)
+aPlane = model.addPlane(aDocument, aPlane.result(), 50, False)
aSession.finishOperation()
-assert (len(aPlane.result()) > 0)
+assert (len(aPlane.results()) > 0)
# Test a plane by coincidence to point
aSession.startOperation()
-aCoincidentPlane = model.addPlane(aDocument, aPlane.result()[0], aPoint2.result()[0])
+aCoincidentPlane = model.addPlane(aDocument, aPlane.result(), aPoint2.result())
aSession.finishOperation()
-assert (len(aCoincidentPlane.result()) > 0)
+assert (len(aCoincidentPlane.results()) > 0)
# Create an axis
aSession.startOperation()
# Test a plane by rotation
aSession.startOperation()
-aRotatedPlane = model.addPlane(aDocument, aCoincidentPlane.result()[0], anAxis.result()[0], 45)
+aRotatedPlane = model.addPlane(aDocument, aCoincidentPlane.result(), anAxis.result(), 45)
aSession.finishOperation()
-assert (len(aRotatedPlane.result()) > 0)
+assert (len(aRotatedPlane.results()) > 0)
# Test plane by two parallel planes
aSession.startOperation()
-aPlane = model.addPlane(aDocument, aCoincidentPlane.result()[0], aPlane.result()[0])
+aPlane = model.addPlane(aDocument, aCoincidentPlane.result(), aPlane.result())
aSession.finishOperation()
-assert (len(aPlane.result()) > 0)
+assert (len(aPlane.results()) > 0)
import model
assert(model.checkPythonDump())
aSession.startOperation()
aPoint = model.addPoint(aDocument, 50, 50, 50)
aSession.finishOperation()
-assert (len(aPoint.result()) > 0)
+assert (len(aPoint.results()) > 0)
# # Create a sketch with lines
# aSession.startOperation()
removeFile(theFile)
# Export a part
aSession.startOperation("Export part")
- model.exportToFile(aPart, theFile, anImport.result(), theFormat)
+ model.exportToFile(aPart, theFile, anImport.results(), theFormat)
# anExportFeature = aPart.addFeature("Export")
# anExportFeature.string("file_format").setValue(theFormat)
# anExportFeature.string("file_path").setValue(theFile)
# Create groups
aSession.startOperation()
- aGroup = model.addGroup(aPart, anImport.result())
+ aGroup = model.addGroup(aPart, anImport.results())
aGroup.defaultResult().data().setName("boite_1")
aGroup.groupList().setSelectionType("solid")
# aGroupFeature = aSession.activeDocument().addFeature("Group")
Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), 10, 0)
Boolean_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")])
model.end()
-assert(len(Boolean_1.result()) > 0)
+assert(len(Boolean_1.results()) > 0)
model.begin()
partSet = model.moduleDocument()
Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), 10, 0)
Boolean_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")])
model.end()
-assert(len(Boolean_1.result()) > 0)
+assert(len(Boolean_1.results()) > 0)
assert(model.checkPythonDump())
# Make extrusion on circle (cylinder) and triangle (prism)
aSession.startOperation()
-anExtrusion = model.addExtrusion(aDocument, aCircleSketch.result() + aTriangleSketch.result(), 100)
+anExtrusion = model.addExtrusion(aDocument, aCircleSketch.results() + aTriangleSketch.results(), 100)
aSession.finishOperation()
# Fill prism with cylinder
aSession.startOperation()
-aBoolean = model.addFill(aDocument, [anExtrusion.result()[0]], [anExtrusion.result()[1]])
-assert (len(aBoolean.result()) > 0)
+aBoolean = model.addFill(aDocument, [anExtrusion.results()[0]], [anExtrusion.results()[1]])
+assert (len(aBoolean.results()) > 0)
aSession.finishOperation()
assert(model.checkPythonDump())
model.do()
smallcyl = model.addExtrusion(mypart, sk2.selectFace(), 150)
-cut = model.addCut(mypart, bigcyl.result(), smallcyl.result())
+cut = model.addCut(mypart, bigcyl.results(), smallcyl.results())
model.do()
# check bodies number is 1: only Boolean result
assert(mypart.size("Bodies") == 1)
-model.addRecover(mypart, cut, smallcyl.result())
+model.addRecover(mypart, cut, smallcyl.results())
model.end()
# check persistent flag of recover: never concealed
model.begin()
-recover = model.addRecover(mypart, cut, smallcyl.result(), True)
+recover = model.addRecover(mypart, cut, smallcyl.results(), True)
assert(mypart.size("Bodies") == 2)
sk3 = model.addSketch(mypart, model.defaultPlane("XOY"))
c3 = sk3.addCircle(0, 0, 90)
model.do()
big2 = model.addExtrusion(mypart, sk3.selectFace(), 110)
-cut2 = model.addCut(mypart, big2.result(), smallcyl.result())
+cut2 = model.addCut(mypart, big2.results(), smallcyl.results())
model.end()
SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
-SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()[0])
-SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()[0])
-SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()[0])
-SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()[0])
+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())
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(), 300, 0)
SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
-SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_5.result()[0])
-SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result()[0])
-SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result()[0])
-SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result()[0])
+SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result())
+SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result())
ExtrusionCut_1.setNestedSketch(Sketch_2)
model.do()
SketchConstraintCoincidence_10 = Sketch_4.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
SketchConstraintCoincidence_11 = Sketch_4.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
SketchConstraintCoincidence_12 = Sketch_4.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
-SketchConstraintHorizontal_5 = Sketch_4.setHorizontal(SketchLine_9.result()[0])
-SketchConstraintVertical_5 = Sketch_4.setVertical(SketchLine_10.result()[0])
-SketchConstraintHorizontal_6 = Sketch_4.setHorizontal(SketchLine_11.result()[0])
-SketchConstraintVertical_6 = Sketch_4.setVertical(SketchLine_12.result()[0])
+SketchConstraintHorizontal_5 = Sketch_4.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_5 = Sketch_4.setVertical(SketchLine_10.result())
+SketchConstraintHorizontal_6 = Sketch_4.setHorizontal(SketchLine_11.result())
+SketchConstraintVertical_6 = Sketch_4.setVertical(SketchLine_12.result())
model.do()
ExtrusionCut_3.setNestedSketch(Sketch_4)
break;
}
}
- myDumpBuffer << name(aFeature) << ".result()[" << anIndex << "]";
+
+ myDumpBuffer << name(aFeature);
+ if(anIndex == 0) {
+ myDumpBuffer << ".result()";
+ } else {
+ myDumpBuffer << ".results()[" << anIndex << "]";
+ }
return *this;
}
feature()->data()->setName(theName);
}
-std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::result() const
+ModelHighAPI_Selection ModelHighAPI_Interface::result() const
+{
+ const_cast<ModelHighAPI_Interface*>(this)->execute();
+
+ return ModelHighAPI_Selection(feature()->firstResult());
+}
+
+std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::results() const
{
const_cast<ModelHighAPI_Interface*>(this)->execute();
MODELHIGHAPI_EXPORT
void setName(const std::string& theName);
+ /// Return firts object of the feature
+ MODELHIGHAPI_EXPORT
+ virtual ModelHighAPI_Selection result() const;
+
/// Return all objects of the feature
MODELHIGHAPI_EXPORT
- virtual std::list<ModelHighAPI_Selection> result() const;
+ virtual std::list<ModelHighAPI_Selection> results() const;
/// Return default result. Default implementation feature()->lastResult()
MODELHIGHAPI_EXPORT
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
SketchCircle_1 = Sketch_1.addCircle(-325.90051457976, -18.010291595197, 258.003584159371)
model.do()
-Sketch_1.result()[0].setDeflection(5e-006)
+Sketch_1.result().setDeflection(5e-006)
Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0)
-Extrusion_1.result()[0].setDeflection(0.5)
+Extrusion_1.result().setDeflection(0.5)
model.end()
assert(model.checkPythonDump())
def test_add_box_by_two_points(self):
point1 = model.addPoint(self.part,0,0,0).result()
point2 = model.addPoint(self.part,10,10,10).result()
- box = model.addBox(self.part, point1[0], point2[0])
+ box = model.addBox(self.part, point1, point2)
model.do()
self.assertEqual(box.creationMethod().value(),"BoxByTwoPoints")
self.assertEqual(box.firstPoint().context().shape().isVertex(),True)
# Subtracting the cylinder to the box
-model.addCut(mypart, mybox.result(), myboss.result())
+model.addCut(mypart, mybox.results(), myboss.results())
model.end()
# Subtracting the cylinder to the box
-model.addCut(mypart, mybox.result(), myboss.result())
+model.addCut(mypart, mybox.results(), myboss.results())
model.end()
b1 = vertical_body()
b2 = bottom_body()
-boolean = model.addFuse(part, b1.result() + b2.result())
+boolean = model.addFuse(part, b1.results() + b2.results())
model.do()
b3 = body_3()
-boolean = model.addFuse(part, boolean.result() + b3.result())
+boolean = model.addFuse(part, boolean.results() + b3.results())
model.do()
# START DEBUG PURPOSES
# END DEBUG PURPOSES
b4 = body_4()
-boolean = model.addFuse(part, boolean.result() + b4.result())
+boolean = model.addFuse(part, boolean.results() + b4.results())
model.end()
assert(model.checkPythonDump())
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
SketchLine_1 = Sketch_1.addLine(0, 50, 100, 50)
SketchPoint_1 = Sketch_1.addPoint(50, 50)
-SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result()[0])
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result())
Sketch_1.addSplit(SketchLine_1, SketchPoint_1.coordinates(), SketchLine_1.endPoint())
model.do()
SketchLine_2_1 = Sketch_2.addLine(0, 50, 100, 50)
SketchPoint_2_1 = Sketch_2.addPoint(25, 50)
SketchPoint_2_2 = Sketch_2.addPoint(75, 50)
-SketchConstraintCoincidence_2_1 = Sketch_2.setCoincident(SketchPoint_2_1.coordinates(), SketchLine_2_1.result()[0])
-SketchConstraintCoincidence_2_2 = Sketch_2.setCoincident(SketchPoint_2_2.coordinates(), SketchLine_2_1.result()[0])
+SketchConstraintCoincidence_2_1 = Sketch_2.setCoincident(SketchPoint_2_1.coordinates(), SketchLine_2_1.result())
+SketchConstraintCoincidence_2_2 = Sketch_2.setCoincident(SketchPoint_2_2.coordinates(), SketchLine_2_1.result())
Sketch_2.addSplit(SketchLine_2_1, SketchPoint_2_1.coordinates(), SketchPoint_2_2.coordinates())
model.do()
SketchCircle_3_1 = Sketch_3.addCircle(50, 50, 50)
SketchPoint_3_1 = Sketch_3.addPoint(50, 0)
SketchPoint_3_2 = Sketch_3.addPoint(50, 100)
-SketchConstraintCoincidence_3_1 = Sketch_3.setCoincident(SketchPoint_3_1.coordinates(), SketchCircle_3_1.result()[1])
-SketchConstraintCoincidence_3_2 = Sketch_3.setCoincident(SketchPoint_3_2.coordinates(), SketchCircle_3_1.result()[1])
+SketchConstraintCoincidence_3_1 = Sketch_3.setCoincident(SketchPoint_3_1.coordinates(), SketchCircle_3_1.results()[1])
+SketchConstraintCoincidence_3_2 = Sketch_3.setCoincident(SketchPoint_3_2.coordinates(), SketchCircle_3_1.results()[1])
Sketch_3.addSplit(SketchCircle_3_1, SketchPoint_3_1.coordinates(), SketchPoint_3_2.coordinates())
model.do()
Sketch_4.setFixed(SketchArc_4_1.endPoint())
Sketch_4.setRadius(SketchArc_4_1, 50)
SketchPoint_4_1 = Sketch_4.addPoint(50, 100)
-SketchConstraintCoincidence_4_1 = Sketch_4.setCoincident(SketchPoint_4_1.coordinates(), SketchArc_4_1.result()[1])
+SketchConstraintCoincidence_4_1 = Sketch_4.setCoincident(SketchPoint_4_1.coordinates(), SketchArc_4_1.results()[1])
Sketch_4.addSplit(SketchArc_4_1, SketchPoint_4_1.coordinates(), SketchArc_4_1.endPoint())
model.do()
Sketch_5.setFixed(SketchArc_5_1.endPoint())
Sketch_5.setRadius(SketchArc_5_1, 50)
SketchLine_5_1 = Sketch_5.addLine(25, 93.301270189222, 75, 93.301270189222)
-SketchConstraintCoincidence_5_1 = Sketch_5.setCoincident(SketchLine_5_1.startPoint(), SketchArc_5_1.result()[1])
-SketchConstraintCoincidence_5_2 = Sketch_5.setCoincident(SketchLine_5_1.endPoint(), SketchArc_5_1.result()[1])
-SketchConstraintHorizontal_5_1 = Sketch_5.setHorizontal(SketchLine_5_1.result()[0])
-SketchConstraintLength_5_1 = Sketch_5.setLength(SketchLine_5_1.result()[0], 50)
+SketchConstraintCoincidence_5_1 = Sketch_5.setCoincident(SketchLine_5_1.startPoint(), SketchArc_5_1.results()[1])
+SketchConstraintCoincidence_5_2 = Sketch_5.setCoincident(SketchLine_5_1.endPoint(), SketchArc_5_1.results()[1])
+SketchConstraintHorizontal_5_1 = Sketch_5.setHorizontal(SketchLine_5_1.result())
+SketchConstraintLength_5_1 = Sketch_5.setLength(SketchLine_5_1.result(), 50)
Sketch_5.addSplit(SketchArc_5_1, SketchLine_5_1.startPoint(), SketchLine_5_1.endPoint())
model.do()