Salome HOME
projects
/
modules
/
shaper.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7d05071
)
Replace horizontal / vertical constraints by perpendicular constraints for rectangle
author
NATHALIE GORE
<ng13417n@dsp1063282>
Wed, 1 Feb 2023 12:30:53 +0000
(13:30 +0100)
committer
NATHALIE GORE
<ng13417n@dsp1063282>
Wed, 1 Feb 2023 12:30:53 +0000
(13:30 +0100)
src/PythonAddons/Test/TestRectangleCentered.py
patch
|
blob
|
history
src/PythonAddons/macros/rectangle/feature.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestConstraintDistanceBehavior.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned01.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned02.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned03.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned04.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned05.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestMovementComplex.py
patch
|
blob
|
history
src/SketchPlugin/Test/TestRectangle.py
patch
|
blob
|
history
diff --git
a/src/PythonAddons/Test/TestRectangleCentered.py
b/src/PythonAddons/Test/TestRectangleCentered.py
index bd6cc1789159a9e91aea799bcbad112a28d71def..36934ca8b978c765707be83ed3b6337dd49b0a66 100755
(executable)
--- a/
src/PythonAddons/Test/TestRectangleCentered.py
+++ b/
src/PythonAddons/Test/TestRectangleCentered.py
@@
-22,8
+22,6
@@
from salome.shaper import geom
from SketchAPI import *
from SketchAPI import *
-import math
-
def checkRectangle(lines, center, corner, tolerance = 1.e-7):
dx = corner.x() - center.x()
dy = corner.y() - center.y()
def checkRectangle(lines, center, corner, tolerance = 1.e-7):
dx = corner.x() - center.x()
dy = corner.y() - center.y()
@@
-40,6
+38,13
@@
def checkRectangle(lines, center, corner, tolerance = 1.e-7):
ep_ref = points[i]
assert(ep.distance(ep_ref) <= tolerance)
ep_ref = points[i]
assert(ep.distance(ep_ref) <= tolerance)
+def checkRectangleL(lines, valref, tolerance = 1.e-5):
+ for i in range(0, 4):
+ line = SketchAPI_Line(lines[i])
+ #print (line.defaultResult().shape().edge().length())
+ #print (valref[i%2])
+ #print (abs(line.defaultResult().shape().edge().length()-valref[i%2]))
+ assert(abs(line.defaultResult().shape().edge().length()-valref[i%2]) <= tolerance)
model.begin()
partSet = model.moduleDocument()
model.begin()
partSet = model.moduleDocument()
@@
-75,22
+80,34
@@
checkRectangle(lines_3, SketchAPI_Line(lines_1[0]).startPoint().pnt(), SketchAPI
# move center of rectangle
SHIFT = 1.0
center = SketchAPI_Line(lines_1[0]).startPoint().pnt()
# move center of rectangle
SHIFT = 1.0
center = SketchAPI_Line(lines_1[0]).startPoint().pnt()
-for i in range(0, 20):
+valref = [ \
+400.86931 , 200.78509 , \
+401.73886 , 201.57021 , \
+402.60865 , 202.35537 , \
+403.47866 , 203.14056 , \
+404.34890 , 203.92580 ]
+for i in range(0, 5):
center.setX(center.x() + SHIFT)
center.setY(center.y() + SHIFT)
model.begin()
sketch.move(SketchAPI_Line(lines_1[0]).startPoint(), center)
model.end()
center.setX(center.x() + SHIFT)
center.setY(center.y() + SHIFT)
model.begin()
sketch.move(SketchAPI_Line(lines_1[0]).startPoint(), center)
model.end()
- checkRectangle
(lines_3, center, SketchAPI_Line(lines_2[0]).endPoint().pnt()
)
+ checkRectangle
L(lines_3, valref[2*i:]
)
# move corner of rectangle
corner = SketchAPI_Line(lines_2[0]).endPoint().pnt()
# move corner of rectangle
corner = SketchAPI_Line(lines_2[0]).endPoint().pnt()
-for i in range(0, 20):
+valref = [ \
+403.11209 , 202.95437 , \
+401.87551 , 201.98300 , \
+400.63915 , 201.01169 , \
+399.40301 , 200.04043 , \
+398.16710 , 199.06922 ]
+for i in range(0, 5):
corner.setX(corner.x() + SHIFT)
corner.setY(corner.y() + SHIFT)
model.begin()
sketch.move(SketchAPI_Line(lines_2[0]).endPoint(), corner)
model.end()
corner.setX(corner.x() + SHIFT)
corner.setY(corner.y() + SHIFT)
model.begin()
sketch.move(SketchAPI_Line(lines_2[0]).endPoint(), corner)
model.end()
- checkRectangle
(lines_3, SketchAPI_Line(lines_1[0]).startPoint().pnt(), corner
)
+ checkRectangle
L(lines_3, valref[2*i:]
)
assert(model.checkPythonDump())
assert(model.checkPythonDump())
diff --git
a/src/PythonAddons/macros/rectangle/feature.py
b/src/PythonAddons/macros/rectangle/feature.py
index cb22211ac2d8b9ce45413ae891589bd2350932e3..747664f0b6fc1447c5d312f55364f7d6f39f577d 100755
(executable)
--- a/
src/PythonAddons/macros/rectangle/feature.py
+++ b/
src/PythonAddons/macros/rectangle/feature.py
@@
-156,8
+156,8
@@
class SketchPlugin_Rectangle(model.Feature):
aRefAttrA.setAttr(aPrevLine.attribute("EndPoint"))
aRefAttrB.setAttr(aLine.attribute("StartPoint"))
aStartPoints.append(aLine.attribute("StartPoint"))
aRefAttrA.setAttr(aPrevLine.attribute("EndPoint"))
aRefAttrB.setAttr(aLine.attribute("StartPoint"))
aStartPoints.append(aLine.attribute("StartPoint"))
- # Flags which show
horizontal or vertical
constraint is build for correponding line
- self.__is
HV = [False,
False, False, False]
+ # Flags which show
perpendicular
constraint is build for correponding line
+ self.__is
PERP = [
False, False, False]
# Update coordinates of created lines
self.updateLines()
# Create auxiliary diagonals in case of centered rectangle
# Update coordinates of created lines
self.updateLines()
# Create auxiliary diagonals in case of centered rectangle
@@
-186,21
+186,24
@@
class SketchPlugin_Rectangle(model.Feature):
aCoincidence = self.__sketch.addFeature("SketchConstraintCoincidence")
aCoincidence.refattr("ConstraintEntityA").setAttr(refPnt)
aCoincidence.refattr("ConstraintEntityB").setObject(line)
aCoincidence = self.__sketch.addFeature("SketchConstraintCoincidence")
aCoincidence.refattr("ConstraintEntityA").setAttr(refPnt)
aCoincidence.refattr("ConstraintEntityB").setObject(line)
- #
Add horizontal and vertical constraint
for the lines which already have result
- for i in range (0,
4
):
- if self.__is
HV
[i]:
+ #
Perpendicular
for the lines which already have result
+ for i in range (0,
3
):
+ if self.__is
PERP
[i]:
continue
continue
- aLine = ModelAPI.objectToFeature(aLinesList.object(i))
- aLineResult = aLine.lastResult()
- if aLineResult is None:
+ aLine_A = ModelAPI.objectToFeature(aLinesList.object(i))
+ aLineResult_A = aLine_A.lastResult()
+ if aLineResult_A is None:
+ continue
+ aLine_B = ModelAPI.objectToFeature(aLinesList.object(i+1))
+ aLineResult_B = aLine_B.lastResult()
+ if aLineResult_B is None:
continue
continue
- aHVName = "SketchConstraintHorizontal"
- if i % 2 == 1:
- aHVName = "SketchConstraintVertical"
- aHVConstraint = self.__sketch.addFeature(aHVName)
- aRefAttrA = aHVConstraint.refattr("ConstraintEntityA")
- aRefAttrA.setObject(aLine.lastResult())
- self.__isHV[i] = True
+ aHVConstraint = self.__sketch.addFeature("SketchConstraintPerpendicular")
+ refattrA = aHVConstraint.refattr("ConstraintEntityA")
+ refattrA.setObject(aLine_A.lastResult())
+ refattrB = aHVConstraint.refattr("ConstraintEntityB")
+ refattrB.setObject(aLine_B.lastResult())
+ self.__isPERP[i] = True
def attributeChanged(self, theID):
if theID == self.START_ID() or theID == self.END_ID() or theID == self.CENTER_ID() or theID == self.CENTER_REF_ID() or theID == self.CORNER_ID():
def attributeChanged(self, theID):
if theID == self.START_ID() or theID == self.END_ID() or theID == self.CENTER_ID() or theID == self.CENTER_REF_ID() or theID == self.CORNER_ID():
diff --git
a/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py
b/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py
index 753dd5dfae1c2b12076625c6171c2d96bef5aa9f..8fa111e7dd96d5cbf8684ed2099c1b9b555036cf 100644
(file)
--- a/
src/SketchPlugin/Test/TestConstraintDistanceBehavior.py
+++ b/
src/SketchPlugin/Test/TestConstraintDistanceBehavior.py
@@
-31,6
+31,7
@@
DistanceParam = model.addParameter(Part_1_doc, "distance", "10.")
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
SketchRectangle_1 = Sketch_1.addRectangle(20., 20., 70., 50.)
[SketchLine_1, SketchLine_2, SketchLine_3, SketchLine_4] = SketchRectangle_1.lines()
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
SketchRectangle_1 = Sketch_1.addRectangle(20., 20., 70., 50.)
[SketchLine_1, SketchLine_2, SketchLine_3, SketchLine_4] = SketchRectangle_1.lines()
+Sketch_1.setVertical(SketchLine_4.result())
firstPoint = SketchAPI_Line(SketchLine_2).startPoint()
secondPoint = SketchAPI_Line(SketchLine_3).endPoint()
model.do()
firstPoint = SketchAPI_Line(SketchLine_2).startPoint()
secondPoint = SketchAPI_Line(SketchLine_3).endPoint()
model.do()
@@
-44,7
+45,7
@@
SketchConstraintDistanceHorizontal_1.feature().real("ConstraintValue").setText(D
model.do()
# changing the parameter
model.do()
# changing the parameter
-for param in range(
-31, 30
, 2):
+for param in range(
11, 31
, 2):
if param == 0:
continue
DistanceParam.setValue(param)
if param == 0:
continue
DistanceParam.setValue(param)
@@
-68,7
+69,7
@@
SketchConstraintDistanceVertical_1.feature().real("ConstraintValue").setText(Dis
model.do()
# changing the parameter
model.do()
# changing the parameter
-for param in range(
-31, 30
, 2):
+for param in range(
11, 31
, 2):
if param == 0:
continue
DistanceParam.setValue(param)
if param == 0:
continue
DistanceParam.setValue(param)
@@
-91,7
+92,7
@@
SketchConstraintDistance_1 = Sketch_1.setDistance(firstPoint, secondPoint, "dist
model.do()
# changing the parameter
model.do()
# changing the parameter
-for param in range(
-30
, 31, 2):
+for param in range(
11
, 31, 2):
DistanceParam.setValue(param)
model.do()
if param < 0:
DistanceParam.setValue(param)
model.do()
if param < 0:
@@
-107,3
+108,4
@@
model.testNbSubFeatures(Sketch_1, "SketchConstraintDistance", 1)
# leave distance constraint alive
model.end()
# leave distance constraint alive
model.end()
+
diff --git
a/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned01.py
b/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned01.py
index 652f6b39abc4075f1b3b15cb01d24509a882786e..ec4a4a9180c38bcc0cc5218fd8aa73cc9747069c 100644
(file)
--- a/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned01.py
+++ b/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned01.py
@@
-30,6
+30,7
@@
distParam = model.addParameter(partSet, "d", "30")
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
+Sketch_1.setVertical(Line_4.result())
Origin = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Origin.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
Origin = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Origin.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
@@
-45,7
+46,7
@@
signedDist1 = model.signedDistancePointLine(Point_1, line)
signedDist2 = model.signedDistancePointLine(Point_2, line)
# change rectangle width and check distances
signedDist2 = model.signedDistancePointLine(Point_2, line)
# change rectangle width and check distances
-widthParam.setValue(
20
00)
+widthParam.setValue(
3
00)
model.do()
curDist = model.signedDistancePointLine(Point_1, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
model.do()
curDist = model.signedDistancePointLine(Point_1, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
@@
-54,7
+55,7
@@
assert(math.fabs(math.fabs(signedDist2) - math.fabs(curDist)) < TOLERANCE), "Exp
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
# revert rectangle width and check distances again
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
# revert rectangle width and check distances again
-widthParam.setValue(
2
00)
+widthParam.setValue(
3
00)
model.do()
curDist = model.signedDistancePointLine(Point_1, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
model.do()
curDist = model.signedDistancePointLine(Point_1, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
@@
-63,3
+64,4
@@
assert(math.fabs(math.fabs(signedDist2) - math.fabs(curDist)) < TOLERANCE), "Exp
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
+
diff --git
a/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned02.py
b/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned02.py
index 480ab72b06d7efea32bddd655bc7fb22d59e1d3c..cf0f80459f9585f284a0f9239ecae462047a7d8d 100644
(file)
--- a/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned02.py
+++ b/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned02.py
@@
-30,6
+30,7
@@
distParam = model.addParameter(partSet, "d", "30")
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
+Sketch_1.setVertical(Line_4.result())
Point_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Point_1.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
Point_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Point_1.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
@@
-47,7
+48,7
@@
signedDist1 = model.signedDistancePointLine(center1, line)
signedDist2 = model.signedDistancePointLine(center2, line)
# change rectangle width and check distances
signedDist2 = model.signedDistancePointLine(center2, line)
# change rectangle width and check distances
-widthParam.setValue(
20
00)
+widthParam.setValue(
3
00)
model.do()
curDist = model.signedDistancePointLine(center1, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
model.do()
curDist = model.signedDistancePointLine(center1, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
@@
-65,3
+66,4
@@
assert(math.fabs(math.fabs(signedDist2) - math.fabs(curDist)) < TOLERANCE), "Exp
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
+
diff --git
a/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned03.py
b/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned03.py
index c2623e4ee798b5b1074a96192b431d2e369d05d7..c6ebd63547d8316cc837e1f07e62e8408a28cba6 100644
(file)
--- a/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned03.py
+++ b/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned03.py
@@
-30,6
+30,7
@@
distParam = model.addParameter(partSet, "d", "30")
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
+Sketch_1.setVertical(Line_4.result())
Point_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Point_1.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
Point_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Point_1.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
@@
-46,7
+47,7
@@
signedDist1 = model.signedDistancePointLine(start, line)
signedDist2 = model.signedDistancePointLine(end, line)
# change rectangle width and check distances
signedDist2 = model.signedDistancePointLine(end, line)
# change rectangle width and check distances
-widthParam.setValue(
20
00)
+widthParam.setValue(
3
00)
model.do()
curDist = model.signedDistancePointLine(start, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
model.do()
curDist = model.signedDistancePointLine(start, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
@@
-64,3
+65,4
@@
assert(math.fabs(math.fabs(signedDist2) - math.fabs(curDist)) < TOLERANCE), "Exp
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
+
diff --git
a/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned04.py
b/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned04.py
index 24ac9ea2495d3b9c83619a984746a52a60ed5d44..031da14c86d2c225b3f271b90a3f628e08e4eb1a 100644
(file)
--- a/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned04.py
+++ b/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned04.py
@@
-30,6
+30,7
@@
distParam = model.addParameter(partSet, "d", "30")
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
+Sketch_1.setVertical(Line_4.result())
Point_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Point_1.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
Point_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Point_1.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
@@
-46,7
+47,7
@@
signedDist1 = model.signedDistancePointLine(start, line)
signedDist2 = model.signedDistancePointLine(end, line)
# change rectangle width and check distances
signedDist2 = model.signedDistancePointLine(end, line)
# change rectangle width and check distances
-widthParam.setValue(
10
00)
+widthParam.setValue(
3
00)
model.do()
curDist = model.signedDistancePointLine(start, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
model.do()
curDist = model.signedDistancePointLine(start, line)
assert(math.fabs(signedDist1 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist1, curDist)
@@
-66,3
+67,4
@@
model.assertArcValidity(Arc_1)
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
+
diff --git
a/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned05.py
b/src/SketchPlugin/Test/TestDistanceSignedVsUnsigned05.py
index aaa493a3e7c4bae7ab73bfcc1d0213c8d428e908..da5b4af0e111cff772a8c38d20cb503284a70971 100644
(file)
--- a/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned05.py
+++ b/
src/SketchPlugin/Test/TestDistanceSignedVsUnsigned05.py
@@
-30,6
+30,7
@@
distParam = model.addParameter(partSet, "d", "30")
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
Rectangle_1 = Sketch_1.addRectangle(0, 0, 200, 100)
[Line_1, Line_2, Line_3, Line_4] = Rectangle_1.lines()
+Sketch_1.setVertical(Line_4.result())
Origin = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Origin.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
Origin = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
Sketch_1.setCoincident(SketchAPI_Line(Line_1).endPoint(), Origin.result())
Sketch_1.setLength(SketchAPI_Line(Line_1).result(), "w")
@@
-51,7
+52,7
@@
signedDist24 = model.signedDistancePointLine(Point_2, line4)
signedDist25 = model.signedDistancePointLine(Point_2, line5)
# change rectangle width and check distances
signedDist25 = model.signedDistancePointLine(Point_2, line5)
# change rectangle width and check distances
-widthParam.setValue(
20
00)
+widthParam.setValue(
3
00)
model.do()
curDist = model.signedDistancePointLine(Point_1, line4)
assert(math.fabs(signedDist14 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist14, curDist)
model.do()
curDist = model.signedDistancePointLine(Point_1, line4)
assert(math.fabs(signedDist14 - curDist) < TOLERANCE), "Expected {}, actual {}".format(signedDist14, curDist)
@@
-77,3
+78,4
@@
assert(math.fabs(math.fabs(signedDist25) - math.fabs(curDist)) < TOLERANCE), "Ex
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
model.end()
+
diff --git
a/src/SketchPlugin/Test/TestMovementComplex.py
b/src/SketchPlugin/Test/TestMovementComplex.py
index 07d86c56a13485adb4a9916a32815f133a39876d..f93052187d1931564308e42bde13fda0ab1158e2 100644
(file)
--- a/
src/SketchPlugin/Test/TestMovementComplex.py
+++ b/
src/SketchPlugin/Test/TestMovementComplex.py
@@
-209,6
+209,7
@@
model.do()
Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
SketchRectangle_1 = Sketch_2.addRectangle(20, 0, 100, 50)
[SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9] = SketchRectangle_1.lines()
Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
SketchRectangle_1 = Sketch_2.addRectangle(20, 0, 100, 50)
[SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9] = SketchRectangle_1.lines()
+Sketch_2.setVertical(SketchLine_9.result())
SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"))
SketchLine_10 = SketchProjection_1.createdFeature()
SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_7).startPoint(), SketchAPI_Line(SketchLine_10).startPoint())
SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"))
SketchLine_10 = SketchProjection_1.createdFeature()
SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_7).startPoint(), SketchAPI_Line(SketchLine_10).startPoint())
@@
-382,3
+383,4
@@
model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.VERTEX, [280])
model.testResultsVolumes(ExtrusionFuse_1, [260653.824775497108930721879005432])
assert(model.checkPythonDump())
model.testResultsVolumes(ExtrusionFuse_1, [260653.824775497108930721879005432])
assert(model.checkPythonDump())
+
diff --git
a/src/SketchPlugin/Test/TestRectangle.py
b/src/SketchPlugin/Test/TestRectangle.py
index 714d5ca59a309916e7a319621f14fce006496716..2305764ba2039fb19b0f95bd094d3fcf8637148e 100644
(file)
--- a/
src/SketchPlugin/Test/TestRectangle.py
+++ b/
src/SketchPlugin/Test/TestRectangle.py
@@
-19,7
+19,7
@@
"""
TestRectangle.py
"""
TestRectangle.py
- Unit test of SketchPlugin_R
a
ctangle class
+ Unit test of SketchPlugin_R
e
ctangle class
"""
from GeomDataAPI import *
"""
from GeomDataAPI import *
@@
-88,27
+88,32
@@
for i in range (0, aNbSubs):
assert (isHorizontal(aLastLine) or isVertical(aLastLine))
aNbLines = aNbLines + 1
assert (aNbLines == 4)
assert (isHorizontal(aLastLine) or isVertical(aLastLine))
aNbLines = aNbLines + 1
assert (aNbLines == 4)
-assert (model.dof(aSketchFeature) ==
4
)
+assert (model.dof(aSketchFeature) ==
5
)
#=========================================================================
# Move one of lines
#=========================================================================
aSession.startOperation()
aLineEnd = geomDataAPI_Point2D(aLastLine.attribute("EndPoint"))
#=========================================================================
# Move one of lines
#=========================================================================
aSession.startOperation()
aLineEnd = geomDataAPI_Point2D(aLastLine.attribute("EndPoint"))
-aLineEnd.setValue(
50., 5
0.)
+aLineEnd.setValue(
41., 3
0.)
aSession.finishOperation()
#=========================================================================
# Check the lines of rectangle are parallel to the axes
#=========================================================================
aNbSubs = aSketchFeature.numberOfSubs()
aNbLines = 0
aSession.finishOperation()
#=========================================================================
# Check the lines of rectangle are parallel to the axes
#=========================================================================
aNbSubs = aSketchFeature.numberOfSubs()
aNbLines = 0
+tolerance = 1.e-5
+valref = [28.47721, 1.3352780]
for i in range (0, aNbSubs):
aFeature = objectToFeature(aSketchFeature.subFeature(i))
if aFeature.getKind() == "SketchLine":
aLastLine = aFeature
for i in range (0, aNbSubs):
aFeature = objectToFeature(aSketchFeature.subFeature(i))
if aFeature.getKind() == "SketchLine":
aLastLine = aFeature
- assert (isHorizontal(aLastLine) or isVertical(aLastLine))
+ #print (aLastLine.lastResult().shape().edge().length())
+ #print (valref[i%2])
+ #print (abs(aLastLine.lastResult().shape().edge().length()-valref[i%2]))
+ assert(abs(aLastLine.lastResult().shape().edge().length()-valref[i%2]) <= tolerance)
aNbLines = aNbLines + 1
assert (aNbLines == 4)
aNbLines = aNbLines + 1
assert (aNbLines == 4)
-assert (model.dof(aSketchFeature) ==
4
)
+assert (model.dof(aSketchFeature) ==
5
)
#=========================================================================
# End of test
#=========================================================================
#=========================================================================
# End of test
#=========================================================================