-# Copyright (C) 2017-2019 CEA/DEN, EDF R&D
+# Copyright (C) 2017-2023 CEA, EDF
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
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()
model.do()
# changing the parameter
-for param in range(-30, 31, 2):
+for param in range(11, 31, 2):
if param == 0:
continue
DistanceParam.setValue(param)
model.do()
# changing the parameter
-for param in range(-30, 31, 2):
+for param in range(11, 31, 2):
if param == 0:
continue
DistanceParam.setValue(param)
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:
+ if param < 0:
assert SketchConstraintDistance_1.feature().error() != '', "ERROR: Sketch should not be valid due to negative distance value"
+ elif param == 0: # constraint is valid, but lead to degenerated geometry
+ assert Sketch_1.feature().error() != '', "ERROR: Sketch should not be valid due to negative distance value"
else:
dist = model.distancePointPoint(firstPoint, secondPoint)
assert math.fabs(dist - math.fabs(param)) < TOLERANCE, "Incorrect distance {}, expected {}".format(dist, math.fabs(param))
# leave distance constraint alive
model.end()
+