From 3940e39be66c38444d3957d62bdec288c2c413f1 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 9 Sep 2015 12:05:42 +0300 Subject: [PATCH] Tests update --- src/FeaturesPlugin/Test/TestPartition.py | 16 +++++++-- src/FeaturesPlugin/Test/TestRevolution.py | 44 +++++++++++------------ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/FeaturesPlugin/Test/TestPartition.py b/src/FeaturesPlugin/Test/TestPartition.py index 84c70c49c..6b8c5da5c 100644 --- a/src/FeaturesPlugin/Test/TestPartition.py +++ b/src/FeaturesPlugin/Test/TestPartition.py @@ -75,15 +75,27 @@ assert (len(anExtrusionFt.results()) > 0) anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult()) assert (anExtrusionResult is not None) +#========================================================================= +# Create plane +#========================================================================= +aSession.startOperation() +aPlaneFeature = aPart.addFeature("Plane") +aPlaneFeature.string("CreationMethod").setValue("PlaneByGeneralEquation") +aPlaneFeature.real("A").setValue(0.) +aPlaneFeature.real("B").setValue(1.) +aPlaneFeature.real("C").setValue(0.) +aPlaneFeature.real("D").setValue(1.) +aSession.finishOperation() +aPlaneResult = aPlaneFeature.firstResult() + #========================================================================= # Create a partition #========================================================================= -aXOZPlane = modelAPI_Result(aDocument.objectByName("Construction", "XOZ")) aSession.startOperation() aPartitionFt = aPart.addFeature("Partition") assert (aPartitionFt.getKind() == "Partition") aPartitionFt.selectionList("main_objects").append(anExtrusionResult, anExtrusionResult.shape()) -aPartitionFt.selectionList("tool_objects").append(aXOZPlane, None) +aPartitionFt.selectionList("tool_objects").append(aPlaneResult, None) aPartitionFt.execute() aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestRevolution.py b/src/FeaturesPlugin/Test/TestRevolution.py index 1dd1ee277..9bb13f88f 100644 --- a/src/FeaturesPlugin/Test/TestRevolution.py +++ b/src/FeaturesPlugin/Test/TestRevolution.py @@ -128,33 +128,31 @@ aRevolResult = modelAPI_ResultBody(aRevolFt.firstResult()) assert (aRevolResult is not None) #========================================================================= -# Create a first plane +# Create bounding planes #========================================================================= -aXOYPlane = modelAPI_Result(aDocument.objectByName("Construction", "XOY")) +# Create from plane aSession.startOperation() -aPlaneFeature = aPart.addFeature("Plane") -aPlaneFeatureData = aPlaneFeature.data() -assert(aPlaneFeatureData is not None) -aPlaneFeatureData.string("CreationMethod").setValue("PlaneByFaceAndDistance") -aPlaneFeatureData.selection("planeFace").setValue(aXOYPlane, None) -aPlaneFeatureData.real("distance").setValue(50) -aPlaneFeature.execute() +aFromPlaneFeature = aPart.addFeature("Plane") +aFromPlaneFeature.string("CreationMethod").setValue("PlaneByGeneralEquation") +aFromPlaneFeature.real("A").setValue(0.) +aFromPlaneFeature.real("B").setValue(0.) +aFromPlaneFeature.real("C").setValue(1.) +aFromPlaneFeature.real("D").setValue(50.) aSession.finishOperation() -aPlane1Result = aPlaneFeature.firstResult(); +aFromResult = aFromPlaneFeature.firstResult() +aFromShape = modelAPI_ResultConstruction(aFromResult).shape() -#========================================================================= -# Create a second plane -#========================================================================= +# Create to plane aSession.startOperation() -aPlaneFeature = aPart.addFeature("Plane") -aPlaneFeatureData = aPlaneFeature.data() -assert(aPlaneFeatureData is not None) -aPlaneFeatureData.string("CreationMethod").setValue("PlaneByFaceAndDistance") -aPlaneFeatureData.selection("planeFace").setValue(aXOYPlane, None) -aPlaneFeatureData.real("distance").setValue(-50) -aPlaneFeature.execute() +aToPlaneFeature = aPart.addFeature("Plane") +aToPlaneFeature.string("CreationMethod").setValue("PlaneByGeneralEquation") +aToPlaneFeature.real("A").setValue(0.) +aToPlaneFeature.real("B").setValue(0.) +aToPlaneFeature.real("C").setValue(1.) +aToPlaneFeature.real("D").setValue(-50.) aSession.finishOperation() -aPlane2Result = aPlaneFeature.firstResult(); +aToResult = aToPlaneFeature.firstResult() +aToShape = modelAPI_ResultConstruction(aToResult).shape() #========================================================================= # Test revol between bounding planes @@ -169,9 +167,9 @@ aRevolFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge) aRevolFt.string("CreationMethod").setValue("ByPlanesAndOffsets") aRevolFt.real("from_angle").setValue(0) #TODO: remove aRevolFt.real("to_angle").setValue(0) #TODO: remove -aRevolFt.selection("to_object").setValue(aPlane1Result, None) +aRevolFt.selection("to_object").setValue(aToResult, None) aRevolFt.real("to_offset").setValue(0) -aRevolFt.selection("from_object").setValue(aPlane2Result, None) +aRevolFt.selection("from_object").setValue(aFromResult, None) aRevolFt.real("from_offset").setValue(0) aRevolFt.execute() aSession.finishOperation() -- 2.39.2