[SOLVED] Global coordinates of a Shape2DView?

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

[SOLVED] Global coordinates of a Shape2DView?

Post by Giulio Buccini »

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?
:?
Selection_7599.jpg
Selection_7599.jpg (68.55 KiB) Viewed 3325 times
Selection_7600.jpg
Selection_7600.jpg (38.4 KiB) Viewed 3325 times
Last edited by Giulio Buccini on Sun Oct 31, 2021 9:16 am, edited 1 time in total.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Global coordinates of a Shape2DView?

Post by Roy_043 »

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.
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: Global coordinates of a Shape2DView?

Post by Giulio Buccini »

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
Selection_7602.jpg
Selection_7602.jpg (40.9 KiB) Viewed 3156 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [SOLVED] Global coordinates of a Shape2DView?

Post by Roy_043 »

Select the object and then paste this line in the Python console will also work:

Code: Select all

Gui.Selection.getSelection()[0].Shape.BoundBox
I can't reproduce the accuracy issue you mention. See image.
Attachments
fcinfo-boundingbox.png
fcinfo-boundingbox.png (6.78 KiB) Viewed 3144 times
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] Global coordinates of a Shape2DView?

Post by Giulio Buccini »

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.
Selection_7603.jpg
Selection_7603.jpg (97.92 KiB) Viewed 3102 times
Attachments
boundingnox-test-deleteme.FCStd
(12.48 KiB) Downloaded 38 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [SOLVED] Global coordinates of a Shape2DView?

Post by Roy_043 »

Lower the Angular Deflection of the Body.
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] Global coordinates of a Shape2DView?

Post by Giulio Buccini »

No idea at all about what this "magic" parameter is... :roll:
But I will test it! :D
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] Global coordinates of a Shape2DView?

Post by Giulio Buccini »

As I understand, the angular deflection is a preference setting of the Part design workbench:
Selection_7604.jpg
Selection_7604.jpg (30.33 KiB) Viewed 3020 times
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%:
Selection_7605.jpg
Selection_7605.jpg (14.68 KiB) Viewed 3021 times
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.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [SOLVED] Global coordinates of a Shape2DView?

Post by Roy_043 »

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.
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: [SOLVED] Global coordinates of a Shape2DView?

Post by mario52 »

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
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.
Post Reply