How to keep inner parts of letters?
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: How to keep inner parts of letters?
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 ).
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..?
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..?
Re: How to keep inner parts of letters?
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()
- papyblaise
- Veteran
- Posts: 7864
- Joined: Thu Jun 13, 2019 4:28 pm
- Location: France
Re: How to keep inner parts of letters?
the font size is its total height, so a font of 10 you shift it by -5mm (minus 5)
Re: How to keep inner parts of letters?
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.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)
- papyblaise
- Veteran
- Posts: 7864
- Joined: Thu Jun 13, 2019 4:28 pm
- Location: France
Re: How to keep inner parts of letters?
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
please give us an exemple , because we suppute
Re: How to keep inner parts of letters?
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:
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!!!!
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')
Now, all my letters are in the right location.
Thanks again to all helping!!!!
Re: How to keep inner parts of letters?
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.
Re: How to keep inner parts of letters?
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.
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: How to keep inner parts of letters?
Cool tip, thank you!