Sketch changes from hex to square when spreadsheet value is changed
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!
Sketch changes from hex to square when spreadsheet value is changed
I am new to FreeCAD.
I am building a parametric model that I want to use to create multiple 3D printed parts. I have created a spreadsheet cell that defines the number of holes (hex pockets) desired, and then calculates the length of the part and the position of the first pockets that will be used in a linear pattern. There is a sketch that defines the shape of the pockets that are in a linear pattern based on the length parameter.
However, when I change the "NumberOfBits" parameter, my sketch changes from a hexagon to a square. I cannot figure out what is causing the sketch to change.
If the value for NumberOfBits is increased rather than decreased, the model seems to work.
I have spent a lot of time trying to figure this out, and am about to give up and create a bunch of manual files...
Thanks for any help!
FreeCAD 0.20.2
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.2.29177 +426 (Git)
Build type: Release
Branch: (HEAD detached from 0.20.2)
Hash: 930dd9a76203a3260b1e6256c70c1c3cad8c5cb8
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods:
* A2plus 0.4.60h
I am building a parametric model that I want to use to create multiple 3D printed parts. I have created a spreadsheet cell that defines the number of holes (hex pockets) desired, and then calculates the length of the part and the position of the first pockets that will be used in a linear pattern. There is a sketch that defines the shape of the pockets that are in a linear pattern based on the length parameter.
However, when I change the "NumberOfBits" parameter, my sketch changes from a hexagon to a square. I cannot figure out what is causing the sketch to change.
If the value for NumberOfBits is increased rather than decreased, the model seems to work.
I have spent a lot of time trying to figure this out, and am about to give up and create a bunch of manual files...
Thanks for any help!
FreeCAD 0.20.2
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.2.29177 +426 (Git)
Build type: Release
Branch: (HEAD detached from 0.20.2)
Hash: 930dd9a76203a3260b1e6256c70c1c3cad8c5cb8
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods:
* A2plus 0.4.60h
- Attachments
-
- The model prior to making the change.
- OriginalState.jpg (309.23 KiB) Viewed 867 times
-
- Hex Small Bit Unlabeled Rail Block_V1 - Fails.FCStd
- (69.81 KiB) Downloaded 15 times
-
- The model after making the change.
- AfterChangingValue.jpg (308.91 KiB) Viewed 867 times
Last edited by db44022 on Sat Jan 28, 2023 6:47 pm, edited 1 time in total.
Re: Sketch changes from hex to square when spreadsheet value is changed
You probably have a flipping sketch. I can investigate it a bit later. You probably have some sort of degenerated hexagon, where you still have six sides inside of a circle and all have the same length.
It happens when a hexagon is moved too far from its origin, IIRC more than half of its diameter
There are various ways to avoid it, one of them using a triangle only and apply a multitransform with a polar and a linear pattern.
It happens when a hexagon is moved too far from its origin, IIRC more than half of its diameter
There are various ways to avoid it, one of them using a triangle only and apply a multitransform with a polar and a linear pattern.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Sketch changes from hex to square when spreadsheet value is changed
I had a look now, and I was right and wrong. I was right with the flipping sketch, and I was wrong with the distance to move. The sketch doesn't flip if the distance of the move is 20mm or less, and it flips if it is 21 or bigger.
In your case I wouldn't use the multipattern mentioned above, I would rather place the hexagon in the center of the sketch and move the whole sketch.
Something else: If you have only one sketch on the DatumPlane it is worth to consider to omit the latter and use the same Placement on the former.
In your case I wouldn't use the multipattern mentioned above, I would rather place the hexagon in the center of the sketch and move the whole sketch.
Something else: If you have only one sketch on the DatumPlane it is worth to consider to omit the latter and use the same Placement on the former.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Sketch changes from hex to square when spreadsheet value is changed
Here is the model where I just fixed the flipping, without reworking anything else. If you are interested in more comments how I would design it to make it more robust against changes (e.g. change BlockExtensionFromRail to 20 and see what happens), ask back.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Sketch changes from hex to square when spreadsheet value is changed
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/
Re: Sketch changes from hex to square when spreadsheet value is changed
Uups.
- Attachments
-
- Hex Small Bit Unlabeled Rail Block_cb.FCStd
- (62.23 KiB) Downloaded 8 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Sketch changes from hex to square when spreadsheet value is changed
The model I uploaded was simplified from what I wanted to achieve. I was using chamfers, and text that I were attached to the DatumPlane. I simplified the model to highlight the problem I encountered.
Re: Sketch changes from hex to square when spreadsheet value is changed
Is the "Flipping Sketch" a bug, or caused by some valid use case?
I am not familiar with how to "Move the whole sketch", but I will do research and give it a try. Is there any published information on when it is better to use a pattern, and when you should move the sketch? I thought I was doing it correctly!
Thanks for your help!!
Re: Sketch changes from hex to square when spreadsheet value is changed
It is a limitation of how the constraint solver works.
Every time you add a constraint it adds to the equation matrix that the solver solves. (Note: fully constrained does not mean the geometry won't change shape, it essentially means the user has added a constraint for each DOF (degree of freedom). And, it does not mean that proximity of two vertexes constitute coincident, they must marked as such. )
The solver knows nothing about geometry or the users intent or expectations. It finds the first valid solution to the matrix and considers it's job done.
If that happens to have moved things in a way that causes the geometry to be shaped differently from our expectations, it sometimes appears to "flip" things. If a positional constraint were available, then we would be able to constrain "this must be left of that", etc. We can't at this point.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Sketch changes from hex to square when spreadsheet value is changed
I looked at your change, and it seems pretty minor, but works much better. I do not understand why, but will do some research and try to learn more about the best way to define constraints and patterns.
Of course I would love any suggestions you have, or point me to somewhere that will help me learn.