Hi!
EDIT: found the other existing issue!: https://github.com/FreeCAD/FreeCAD/issues/7489
POSSIBLY related - https://github.com/FreeCAD/FreeCAD/issues/7589, https://github.com/FreeCAD/FreeCAD/issues/7390
I had an issue where a constraint's value would not update after setting it to an expression. After investigating, the issue was in PropertyExpressionEngine::buildGraph.
The DiGraph uses a node count from 0 to revNodes.size()-1, and the edges are from 0 to nodes.size()-1
revNodes has sometimes fewer items than nodes because the dependencies are _not_ added in the revNodes dictionary by buildGraphStructures.
I have a change that fixes the issue, you can check this here - https://github.com/acpopescu/FreeCAD/co ... b1975fe2c1
I can clean it up and do a PR - let me know.
PropertyExpressionEngine - Issue in buildGraph
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
PropertyExpressionEngine - Issue in buildGraph
Last edited by acpopescu on Sun Jan 29, 2023 2:32 am, edited 2 times in total.
Re: PropertyExpressionEngine - Issue in buildGraph
It looks like the change has some side effects in my assembly...
EDIT: The side effect looks to be because of improved precision. Due to the way double precision works, I need to offset .001 mm. Also, we don't have a pure 6mm in the constraint below, but 5.999999999999993 for AxleMountThickness
Issue:
A pad on a sketch, with a placement constraint something like "-15mm - <<Ref_POVHatMountsTOP>>.Constraints.AxleMountThickness" will cause an invalid quad to show
If I do "-15.0001mm - <<Ref_POVHatMountsTOP>>.Constraints.AxleMountThickness " it will work: Any other formula referencing the local sketch ("-Placement.base.z + 14" ) will be fine.
Ref_POVHatMountsTOP is in another body, same part and document.
I suspect this is a side effect when dealing with precision issues. "<<Ref_POVHatMountsTOP>>.Constraints.AxleMountThickness" should be exactly on the tip of the curvature - see
EDIT: The side effect looks to be because of improved precision. Due to the way double precision works, I need to offset .001 mm. Also, we don't have a pure 6mm in the constraint below, but 5.999999999999993 for AxleMountThickness
Issue:
A pad on a sketch, with a placement constraint something like "-15mm - <<Ref_POVHatMountsTOP>>.Constraints.AxleMountThickness" will cause an invalid quad to show
If I do "-15.0001mm - <<Ref_POVHatMountsTOP>>.Constraints.AxleMountThickness " it will work: Any other formula referencing the local sketch ("-Placement.base.z + 14" ) will be fine.
Ref_POVHatMountsTOP is in another body, same part and document.
I suspect this is a side effect when dealing with precision issues. "<<Ref_POVHatMountsTOP>>.Constraints.AxleMountThickness" should be exactly on the tip of the curvature - see
Last edited by acpopescu on Sun Jan 29, 2023 3:04 am, edited 1 time in total.
Re: PropertyExpressionEngine - Issue in buildGraph
Trying with a smaller value yields the start of some artefacts, definitely a precision issue; probably stemming from how the property is being updated after the fix.
.0000001 : With -0.001 (14.999):
.0000001 : With -0.001 (14.999):
Re: PropertyExpressionEngine - Issue in buildGraph
Ok, so the actual property isn't exactly 21mm. Python console expands it to:
And the result for the Axle MountThickness is
In the end the behavior that I'm seeing looks correct, if not it's higher precision
Code: Select all
>>> App.ActiveDocument.Sketch081.Placement.Base.y
20.999999999999986
Code: Select all
>>> ActiveSketch.Constraints[19].Name
'AxleMountThickness'
>>> ActiveSketch.Constraints[19].Value
5.999999999999993
Re: PropertyExpressionEngine - Issue in buildGraph
It is normal "IEEE floating point approximation" for short a decimal number could not have a precise binary representation.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/