Angle constraint issue in sketcher
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Angle constraint issue in sketcher
Attached is a file with a sketch I've been trying to develop for a parametric box culvert. It's a headwall corner, whose position is defined by an angle of skew along the centerline of the box culvert.
The problem is, if I try to change the skew angle by more than 5 - 15 degrees, it gives me an "Invalid constraint index" error. The constraint I'm adjusting (index 24) needs to be adjustable between -65 and 65 degrees. If I make the adjustments in small increments <= 15 degrees, I am generally successful.
The sketch is fully constrained, and I'm not certain where the solver is having issues when the increment gets larger (> 15 degrees).
Anyway, the file is attached, if anyone has the time and interest to play with it...
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13509 (Git)
Build type: Release
Branch: releases/FreeCAD-0-17
Hash: 0258808ccb6ba3bd5ea9312f79cd023f1a8671b7
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
The problem is, if I try to change the skew angle by more than 5 - 15 degrees, it gives me an "Invalid constraint index" error. The constraint I'm adjusting (index 24) needs to be adjustable between -65 and 65 degrees. If I make the adjustments in small increments <= 15 degrees, I am generally successful.
The sketch is fully constrained, and I'm not certain where the solver is having issues when the increment gets larger (> 15 degrees).
Anyway, the file is attached, if anyone has the time and interest to play with it...
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13509 (Git)
Build type: Release
Branch: releases/FreeCAD-0-17
Hash: 0258808ccb6ba3bd5ea9312f79cd023f1a8671b7
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Re: Angle constraint issue in sketcher
Hi,
I just took a quick look and there is two things disturbing me :
- why is there a vertical segment on the Y-axis ? (for me it is useless, but I don't know at all what you're drawing )
- The constraint numbered 21 looks odd : it's an equality between segments, but when you mesure the lengths, they are not equal (I did a try with a 30° angle). The vertical length on the y-axis is 0,3048 m, on your part it's 0,3519 m.
You might have some constraint issue (duplicate or something...)
I'll take a deeper look later if you didn't catch anything.
Regards,
I just took a quick look and there is two things disturbing me :
- why is there a vertical segment on the Y-axis ? (for me it is useless, but I don't know at all what you're drawing )
- The constraint numbered 21 looks odd : it's an equality between segments, but when you mesure the lengths, they are not equal (I did a try with a 30° angle). The vertical length on the y-axis is 0,3048 m, on your part it's 0,3519 m.
You might have some constraint issue (duplicate or something...)
I'll take a deeper look later if you didn't catch anything.
Regards,
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Angle constraint issue in sketcher
The vertical segment represents the culvert centerline (see picture in my previous post).schupin wrote: ↑Mon May 07, 2018 5:19 pm I just took a quick look and there is two things disturbing me :
- why is there a vertical segment on the Y-axis ? (for me it is useless, but I don't know at all what you're drawing )
- The constraint numbered 21 looks odd : it's an equality between segments, but when you mesure the lengths, they are not equal (I did a try with a 30° angle). The vertical length on the y-axis is 0,3048 m, on your part it's 0,3519 m.
In case you didn't know, a culvert allows water to flow under a road - think of it as a small bridge... Anyway, when they get placed, they are usually orthogonal to the centerline of the road. If, for some reason, the angle between the road's centerline and the culvert's centerline has to be at an angle other than 90 degrees, we say it's on a skew. That skew is simply the amount above or below 90 degrees. Usually skews tend to be small, up to 15 - 20 degrees, but they can go as high as 65 degrees.
In this case, the skew angle is represented by the constraint at the center of the sketch (labeled "local_skew").
Thus, the vertical line represents the centerline of the culvert. The end of the culvert itself (indicated by the two construction lines) are parallel to the road's centerline and are rotated about the centerpoint by the skew angle. so, to test the sketch, simply adjust the local_skew angle constraint.
So that explains your first question...
To your second question, that's not an equal-length constraint. It's a parallel constraint. You'll see it adjust when you change the local_skew angle constraint.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Re: Angle constraint issue in sketcher
I'm by no mean a specialist of the solvers, but my understanding (reading from some posts in the forum) is that they usually use some kind of gradient method to find the closest local solution that will satisfy the constraints. Think of it as trying to go always go downhill from your location and hope you will reach the sea level. It would work most of the time unless you get stuck in a craterJoel_graff wrote: ↑Mon May 07, 2018 4:52 pm The problem is, if I try to change the skew angle by more than 5 - 15 degrees, it gives me an "Invalid constraint index" error. The constraint I'm adjusting (index 24) needs to be adjustable between -65 and 65 degrees. If I make the adjustments in small increments <= 15 degrees, I am generally successful.
So I've also seen failed solved when the jumps are too large, maybe using a macro that would cahnge the parameter by small increment and then launch a recompute until you reach the target angle would be a good solution?
I've played with the crank simulation that was not too hard to follow (https://www.freecadweb.org/wiki/Macro_crank_simul) you should have all the elements there to make a small for loop to get do the successive updates. I'm not Python fluent so I can't wipe an quick example right there.
Cheers
Re: Angle constraint issue in sketcher
Ouch, indeed that was a good constraint. Hard to differentiate these two...Joel_graff wrote: ↑Mon May 07, 2018 6:12 pm To your second question, that's not an equal-length constraint. It's a parallel constraint. You'll see it adjust when you change the local_skew angle constraint.
Thanks a lot for your explanations about culverts. I've never heard about it before.
But for your problem... I can't find the solution... I tried different way of constraining your sketch but can't find anything.
I hope some other freecad user will have some ideas...
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Angle constraint issue in sketcher
I'm thinking dbecad might be right.
When I deleted the local_skew constraint and just dragged and moved everything, I had much better performance, I'm guessing because it was recomputing more frequently on smaller increments. So it looks like I'll have to figure out how to force more gradual increments when the user wants to adjust the skew more than, say five degrees...
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Re: Angle constraint issue in sketcher
I thought I had it, but no luck. I started with a theta angle of 15 degrees, but I also (sometimes) had to creep up the change of degrees a little at a time (instead of big jumps) to get to 65 degrees. I used some expressions without the Spreadsheet - two are in the Angle Constraints of the wing walls relative to the head wall, the 12.5 and 77.5 degrees in the image:
I also simply assigned a value to the wall thickness of the box culvert instead of X1, X2, 9", and X3. The file is attached in case it might be helpful:
OS: Ubuntu 16.04.4 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.17.13519 (Git)
Build type: None
Branch: releases/FreeCAD-0-17
Hash: 1a8b868018f45ea486c0023fdbfeb06febc1fb89
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
I also simply assigned a value to the wall thickness of the box culvert instead of X1, X2, 9", and X3. The file is attached in case it might be helpful:
OS: Ubuntu 16.04.4 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.17.13519 (Git)
Build type: None
Branch: releases/FreeCAD-0-17
Hash: 1a8b868018f45ea486c0023fdbfeb06febc1fb89
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
Re: Angle constraint issue in sketcher
I found something that works !
While in the sketcher, I went to : tools->Edit parameters.
I change "ExpandedSolverAdvancedWidget" to true and "ShowSolverAdvancedWidget" to true.
Then, you will see a lot of options for your solver in the combo view (just above the solver messages).
I don't know what all these options are doing, but if I tick "Sketch size multiplier" I can change your angle as I want !
(it seems to increase the max number of iteration regarding the size of your sketch)
While in the sketcher, I went to : tools->Edit parameters.
I change "ExpandedSolverAdvancedWidget" to true and "ShowSolverAdvancedWidget" to true.
Then, you will see a lot of options for your solver in the combo view (just above the solver messages).
I don't know what all these options are doing, but if I tick "Sketch size multiplier" I can change your angle as I want !
(it seems to increase the max number of iteration regarding the size of your sketch)
Re: Angle constraint issue in sketcher
Thanks schupin, that is much better! I can creep down to 15 degrees, but 11 degrees (or less ) with any of the 3 solvers gives me the "Invalid constraint index..." error message. I don't know what a "Sketch size multiplier" is though... The problem in my Sketch might have something to do with the horizontal or vertical Construction Lines that come off the wind walls but I haven't looked into it again.
"Show advanced solver controls..." is also accessible via Edit > Preferences > Sketcher (icon in left pane) > General (tab at top of right pane), toward the bottom of the window. I had mine ticked off, which I think is the default.
"Show advanced solver controls..." is also accessible via Edit > Preferences > Sketcher (icon in left pane) > General (tab at top of right pane), toward the bottom of the window. I had mine ticked off, which I think is the default.
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Angle constraint issue in sketcher
I'll definitely take a look at it. I discovered I can rotate it without fail in 5-degree increments, which is fine, I guess. The only other solution I was pondering was to animate it with a control to allow for faster angle adjustments.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers