Centering ShapeString parametrically

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!
Post Reply
nefarious
Posts: 14
Joined: Fri Feb 03, 2023 5:58 pm

Centering ShapeString parametrically

Post by nefarious »

I am in the process of learning how to manipulate text in freecad and trying to center shapeString on a solid. I have all of my parameters for the solid in a spreadsheet and I notice that the shapestring has some parameters available. I can show the bounding box in the application but I can't figure out how to add it to an equation to center the text when the string changes. Is this possible?
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Centering ShapeString parametrically

Post by onekk »

nefarious wrote: Fri Feb 03, 2023 6:05 pm I am in the process of learning how to manipulate text in freecad and trying to center shapeString on a solid. I have all of my parameters for the solid in a spreadsheet and I notice that the shapestring has some parameters available. I can show the bounding box in the application but I can't figure out how to add it to an equation to center the text when the string changes. Is this possible?
usually you could retrieve the BoundBox, so probably:

<<Object>>.Shape.BoundBox. will go.

Take in account that BoundBox are unitless so you have to multiply them * 1mm if not it will not work.

In the file attached in Cube001 placement X you will see an example of expression.
test_expression.FCStd
(5.38 KiB) Downloaded 16 times

Code: Select all

help(FreeCAD.BoundBox)
will show you parameter other than XLength

Hope it helps

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/
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

Re: Centering ShapeString parametrically

Post by drmacro »

You are welcome to try this macro/Python script.

Select the face and an edge to indicate the direction, then run the script.
Attachments
CenterShapeStringOnFace-1.zip
(5.58 KiB) Downloaded 14 times
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply