[solved] Align ShapeString on a Circle

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

[solved] Align ShapeString on a Circle

Post by reox »

I want to create a circular scale, where each scale tick has a number above it. I sketched the principle in Inkscape:
Screenshot 2023-02-09 134938.png
Screenshot 2023-02-09 134938.png (16.31 KiB) Viewed 948 times
Each number should be centered above the tick mark and the lower part of the number should be a defined distance away from the tick mark.

The part should then be 3d-printed and I want to create pockets for the numbers.
My worflow so far was to create the part in PartDesign and then for each number:
* go to Draft Workbench
* Create a ShapeString with the number
* Move the shapestring into the body
* go to Part Design
* Use "Map sketch to face" and map the ShapeString to the Surface (or XY Plane) using FlatFace attachement
* Adjust the Placement of the ShapeString by rotating it and adjusting the x/y offset - calculated either by hand or in a sketch
* use the pocket function to create the pocket

However, there is a problem with this approach:
The Attachement of the ShapeString is such, that it attaches the lower left corner of the bounding box to 0/0. While in the y-direction, the bbox is exactly at the lower part of the font, there is a spacing in the x-direction.
And thus, it is very hard to really center the number above the line in a defined distance.
See the BBox issue here: I simply attached the ShapeString to the face and opened the Sketcher.
Screenshot 2023-02-09 135127.png
Screenshot 2023-02-09 135127.png (5.86 KiB) Viewed 948 times
Probably the easiest would be, if I could define the origin of the ShapeString somehow. Then, the placement is simple. However, is that possible?
The other possibility would probably be to write a macro that does the placement and takes the additional offset into account.

Attached is a quick example, showing it for a tick mark and text at 60°:
ShapeString_demo.FCStd
(18.11 KiB) Downloaded 41 times
btw, there seems to be a bug, that the "Map sketch to face" will not get active, until a sketch is added to the body. Thus, when there is only the ShapeString in the body, you can not use "map sketch to face". A workaround is to always create an (empty) sketch fist or not use that button at all and simply adjust it in the data tab.
Last edited by reox on Thu Feb 09, 2023 3:50 pm, edited 1 time in total.
User avatar
Shalmeneser
Veteran
Posts: 9475
Joined: Wed Dec 23, 2020 12:04 am
Location: Fr

Re: Algin ShapeString on a Circle

Post by Shalmeneser »

I would draw all the numbers in Inkscape then import this in FreeCAD.
drmacro
Veteran
Posts: 8873
Joined: Sun Mar 02, 2014 4:35 pm

Re: Algin ShapeString on a Circle

Post by drmacro »

Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
drmacro
Veteran
Posts: 8873
Joined: Sun Mar 02, 2014 4:35 pm

Re: Algin ShapeString on a Circle

Post by drmacro »

Similar discussion on Discord and results having used Lattice2 workbench:

Image

Link to Discord thread (probably need Discord login and join the FreeCAD Project Discord server):
https://discord.com/channels/8708774110 ... 7421432902
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Algin ShapeString on a Circle

Post by reox »

Thanks! Lattice2 can indeed do that. The trick is to use Orient Mode = Vortex.
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Align ShapeString on a Circle

Post by reox »

Uhm okay, but there is then still an offset. The arrow base is at the correct position, but not the arrow tip and thus the center of the text itself:
Screenshot 2023-02-09 150534.png
Screenshot 2023-02-09 150534.png (15.82 KiB) Viewed 858 times
Is there another thing I have to set?
Attachments
lattice_test.FCStd
(69.46 KiB) Downloaded 38 times
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Align ShapeString on a Circle

Post by onekk »

IWhen using characters there is no a concept of center, but about baseline with numbers you have no problems as they are all over the baseline.

You have to find eventually the width or maybe orient them accordingly and rotate them by 90 degrees as probably it is a dial.

If it is knob it depends on what you want and where is notch position.

There were around some example as clock faces, probably searching the forum for clock and face will give some results.

It is not avstrange thing so probably Lattice2 has already some option.

Try to see his Wiki page.

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/
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Align ShapeString on a Circle

Post by reox »

onekk wrote: Thu Feb 09, 2023 2:39 pm There were around some example as clock faces, probably searching the forum for clock and face will give some results.
Thanks! There seems to be also this macro: https://wiki.freecad.org/Macro_FCCircularText
I'll try that as well.

Lattice2 has the issue, that the text is still not aligned at the center, as written above
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Align ShapeString on a Circle

Post by onekk »

reox wrote: Thu Feb 09, 2023 2:55 pm ...
Lattice2 has the issue, that the text is still not aligned at the center, as written above
Each shape has a boundingbox and you could find the center one of the property of the BoundBox is Center.

Placement property and expressions could maybe help.

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/
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Align ShapeString on a Circle

Post by reox »

onekk wrote: Thu Feb 09, 2023 2:59 pm Each shape has a boundingbox and you could find the center one of the property of the BoundBox is Center.
It seems like the FCCircularText does exactly that
Post Reply