How to keep inner parts of letters?

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!
viktak
Posts: 24
Joined: Tue Oct 19, 2021 2:36 pm
Contact:

Re: How to keep inner parts of letters?

Post by viktak »

Now, that I replaced my original font with the "stencil" type one, I just saw that it messes up my arrangement as I used a non-proportional font to make sure that the macro I use for putting down the letters puts them down in a grid (that is what I need, that is not negotiable :D ).

So this begs the question: Is there a way to align the letters to their own center, or now I have to find a stencil type non-proportional font..?
viktak
Posts: 24
Joined: Tue Oct 19, 2021 2:36 pm
Contact:

Re: How to keep inner parts of letters?

Post by viktak »

If it helps this is my macro that does the generation of letters for the grid:

Code: Select all

DOC = FreeCAD.ActiveDocument
SHEET = DOC.Spreadsheet

for row in range(0,10):	#10
	for col in range(0,13):	# 13
		Gui.runCommand('Draft_ShapeString',0)
		ss=Draft.makeShapeString(String=myList[13*row+col],FontFile="/FreeCad/Fonts/BeonMedium-6d51.otf",Size=10.0,Tracking=0.0)
		ss.setExpression('Size', u'<<params>>.font_size')

		ss.setExpression('.Placement.Base.x', u'<<params>>.cell_width * ' + str(col) + u'-2.8')
		ss.setExpression('.Placement.Base.y', u'<<params>>.cell_length *' + str(-row) + u'- 3.2+' + u'(<<params>>.number_of_rows - 1) * <<params>>.cell_length')
		ss.setExpression('.Placement.Base.z', u'<<params>>.body_height - <<params>>.faceplate_thickness - <<params>>.backplate_thickness')
	
		ss.AttachmentOffset = App.Placement(App.Vector(0.0000000000, 0.0000000000, 0.0000000000),  App.Rotation(0.0000000000, 0.0000000000, 0.0000000000))
		ss.MapReversed = False
		#ss.Support = getattr(App.ActiveDocument, "DatumPlane")
		#ss.MapPathParameter = 0.000000
		#ss.MapMode = 'FlatFace'


		plm=FreeCAD.Placement()
		plm.Base=FreeCAD.Vector(0.0, 0.0, 0.0)
		plm.Rotation.Q=(0.0, 0.0, 1.5308084989341915e-17, 1.0)
		ss.Placement=plm
		Draft.autogroup(ss)

DOC.recompute()

User avatar
papyblaise
Veteran
Posts: 7864
Joined: Thu Jun 13, 2019 4:28 pm
Location: France

Re: How to keep inner parts of letters?

Post by papyblaise »

the font size is its total height, so a font of 10 you shift it by -5mm (minus 5)
viktak
Posts: 24
Joined: Tue Oct 19, 2021 2:36 pm
Contact:

Re: How to keep inner parts of letters?

Post by viktak »

papyblaise wrote: Mon Oct 25, 2021 3:27 pm the font size is its total height, so a font of 10 you shift it by -5 (minus 5)
Yes, I know that, but if each letter is different width/height, it is more difficult to do it programmatically. I would need to query FreeCAD for the letter's width/height, and I don't know how to do that.
User avatar
papyblaise
Veteran
Posts: 7864
Joined: Thu Jun 13, 2019 4:28 pm
Location: France

Re: How to keep inner parts of letters?

Post by papyblaise »

Why do the letters une to one :?: , but you can add booleen them aat the right place
please give us an exemple , because we suppute
viktak
Posts: 24
Joined: Tue Oct 19, 2021 2:36 pm
Contact:

Re: How to keep inner parts of letters?

Post by viktak »

As I explained earlier, since not all letters are of the same width, I need to adjust the formula for the different ones.

At the end, I came up with the following modification for the macro:

Code: Select all

		if myList[13*row+col] == "I":
			ss.setExpression('.Placement.Base.x', u'<<params>>.cell_width * ' + str(col) + u'-2')
		elif myList[13*row+col] == "W":
			ss.setExpression('.Placement.Base.x', u'<<params>>.cell_width * ' + str(col) + u'-5')
		else:
			ss.setExpression('.Placement.Base.x', u'<<params>>.cell_width * ' + str(col) + u'-4')
It turns out, that only the letters "I" and "W" need adjustment.

Now, all my letters are in the right location.

Thanks again to all helping!!!!
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: How to keep inner parts of letters?

Post by chrisb »

Perhaps I don't fully understand. If you want to print e.g. an O, then you need a common support below it. Even if you can print it without any connection of the inner thing to the outside, the inside would fall off as soon as you remove it from the printer.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: How to keep inner parts of letters?

Post by onekk »

You could use the boundingbox of the letter to obtain his center, with some work, but usually if you transform a letter in a solid, you should have a Center properties.

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/
viktak
Posts: 24
Joined: Tue Oct 19, 2021 2:36 pm
Contact:

Re: How to keep inner parts of letters?

Post by viktak »

onekk wrote: Tue Oct 26, 2021 7:49 am You could use the boundingbox of the letter to obtain his center, with some work, but usually if you transform a letter in a solid, you should have a Center properties.

Regards

Carlo D.
Cool tip, thank you!
Post Reply