[SOLVED] Global coordinates of a Shape2DView?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 541
- Joined: Fri Aug 26, 2016 9:07 pm
- Location: Munich - Gemany
[SOLVED] Global coordinates of a Shape2DView?
Hello folks,
I need to know the bottom-left coordinates of the "bounding-box" containing a 3D-bracket rotated of some degrees around his origin.
My steps was:
1. I have selected my bracket
2. Draft -> Shape2D View
3. Sketcher -> draw a rectangle containing the shape
4. I have selected the sketch
5. Draft -> Shape2D View
Both the rectangle (my "Bounding-box") and the Shape2dView have 0,0,0 as X,Y,Z coords. Why?
I need to know the bottom-left coordinates of the "bounding-box" containing a 3D-bracket rotated of some degrees around his origin.
My steps was:
1. I have selected my bracket
2. Draft -> Shape2D View
3. Sketcher -> draw a rectangle containing the shape
4. I have selected the sketch
5. Draft -> Shape2D View
Both the rectangle (my "Bounding-box") and the Shape2dView have 0,0,0 as X,Y,Z coords. Why?
Last edited by Giulio Buccini on Sun Oct 31, 2021 9:16 am, edited 1 time in total.
Re: Global coordinates of a Shape2DView?
You are mistaken. The Placement point of the Shape2DView is not the bottom left point of the bounding box. Just move your object further from the origin to check this. Maybe try Macro_FCInfo.
-
- Posts: 541
- Joined: Fri Aug 26, 2016 9:07 pm
- Location: Munich - Gemany
Re: Global coordinates of a Shape2DView?
Yeah, seems you're right.
The "placement" info display just the location of the coordinate system used to draw the Shape2D object...
For example, if I move the Shape2D into a Body by using the object-tree on the left panel, then the [0,0,0] coords stays untouched but the object translates to the new origin on the screen.
I was trying to pickup the left-bottom corner to get the start coordinates for a milling operation by using the Path Workbench.
I have several irregular shapes to be milled out of an alu plate. So my problem is to dispose the shapes on an XY plane in order to minimize the waste of material
My idea was: if I know the left-bottom coords of every bounding-box, then I can simply "move" the machine Working Coordinate System (WCS) to the appropriate point for every shape before starting milling. This can be done by issuing a simply G52 instruction.
The Macro_FCInfo is a useful workaround, since it gives info about the size of the bounding-box and the center of it. The coords of the bottom-left corner can be achieved by using some simple math.
There just one thing annoying: even for regular shapes the values are approximated, so one have to round them manually:
Box width=15 mm
Box height = 22.5mm
The "placement" info display just the location of the coordinate system used to draw the Shape2D object...
For example, if I move the Shape2D into a Body by using the object-tree on the left panel, then the [0,0,0] coords stays untouched but the object translates to the new origin on the screen.
I was trying to pickup the left-bottom corner to get the start coordinates for a milling operation by using the Path Workbench.
I have several irregular shapes to be milled out of an alu plate. So my problem is to dispose the shapes on an XY plane in order to minimize the waste of material
My idea was: if I know the left-bottom coords of every bounding-box, then I can simply "move" the machine Working Coordinate System (WCS) to the appropriate point for every shape before starting milling. This can be done by issuing a simply G52 instruction.
The Macro_FCInfo is a useful workaround, since it gives info about the size of the bounding-box and the center of it. The coords of the bottom-left corner can be achieved by using some simple math.
There just one thing annoying: even for regular shapes the values are approximated, so one have to round them manually:
Box width=15 mm
Box height = 22.5mm
Re: [SOLVED] Global coordinates of a Shape2DView?
Select the object and then paste this line in the Python console will also work:
I can't reproduce the accuracy issue you mention. See image.
Code: Select all
Gui.Selection.getSelection()[0].Shape.BoundBox
- Attachments
-
- fcinfo-boundingbox.png (6.78 KiB) Viewed 3144 times
-
- Posts: 541
- Joined: Fri Aug 26, 2016 9:07 pm
- Location: Munich - Gemany
Re: [SOLVED] Global coordinates of a Shape2DView?
Unfortunately I didn't save the FCStd file on which I made the test.
I created a new drawing from the scratch: just select the cylindrical shape and run the FCInfo macro.
I created a new drawing from the scratch: just select the cylindrical shape and run the FCInfo macro.
- Attachments
-
- boundingnox-test-deleteme.FCStd
- (12.48 KiB) Downloaded 38 times
Re: [SOLVED] Global coordinates of a Shape2DView?
Lower the Angular Deflection of the Body.
-
- Posts: 541
- Joined: Fri Aug 26, 2016 9:07 pm
- Location: Munich - Gemany
Re: [SOLVED] Global coordinates of a Shape2DView?
No idea at all about what this "magic" parameter is...
But I will test it!
But I will test it!
-
- Posts: 541
- Joined: Fri Aug 26, 2016 9:07 pm
- Location: Munich - Gemany
Re: [SOLVED] Global coordinates of a Shape2DView?
As I understand, the angular deflection is a preference setting of the Part design workbench:
I lowered progressively the parameter value and reload the FCStd each time. The bounding box is correctly calculated when the max angular deflection is set to 6%:
Great!
Quite curiously, changing the parameter and restarting Freecad each time has no effect if you are not saving the FCStd file too.
In fact, if you click on the "Apply" button on the preference window, you will see an asterisk (*) beside the opened model indicating that the model must be saved.
So, this information is somehow embedded in the model itself and need to be saved with it.
I lowered progressively the parameter value and reload the FCStd each time. The bounding box is correctly calculated when the max angular deflection is set to 6%:
Great!
Quite curiously, changing the parameter and restarting Freecad each time has no effect if you are not saving the FCStd file too.
In fact, if you click on the "Apply" button on the preference window, you will see an asterisk (*) beside the opened model indicating that the model must be saved.
So, this information is somehow embedded in the model itself and need to be saved with it.
Re: [SOLVED] Global coordinates of a Shape2DView?
The behavior you are seeing is the result of a (IMO) bad design decision. There is no global deflection setting. Each object stores its own value. The preference should be used for new object only. But at some point somebody decided that any change to the preference should be propagated to all objects in the currently opened documents.
Re: [SOLVED] Global coordinates of a Shape2DView?
Hi
thanks Roy_043
i upgrade the macro FCInfo now : 1.23 (download by Addon Manager)
adding:
1: include icon in macro,
2: number decimal displayed ,
3: text height,
4: info lines in the Sketcher open (i used the code How to select edges inside of Sketcher?)
5: configure options in the Preference FC
(and little change)
not yet upgrade for the Body
mario
thanks Roy_043
i upgrade the macro FCInfo now : 1.23 (download by Addon Manager)
adding:
1: include icon in macro,
2: number decimal displayed ,
3: text height,
4: info lines in the Sketcher open (i used the code How to select edges inside of Sketcher?)
5: configure options in the Preference FC
(and little change)
not yet upgrade for the Body
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.