Macro FCCircularText

Description
This macro makes use of the Draft ShapeString tool to create a text line placed in different circular orientations, including circumferential and helical in the fashion of a Trajan's Column. It can also be used to create a clock face with Arabic numerals 1, 2, 3, etc., or Roman numerals I, II, III, etc. This latter usage was inspired by the Forum thread Macro to Create Clock Face by FC community member, cblt2l.


 * FCCircularText 01.png

Usage
Launch the macro folder FcString for created characters and a file FcClock for created clocks.

All the characters are and remain independent. When creating extrusions nothing is deleted. If Compound is created with it is copied out of the folder.

The options are shaded by default and are active in all functions if they are checked :

Except for one Clock Service Placement box Z is activated and moves the text in the direction Z to place the text on the support surface.

Interface
Overview



First section



 * TextEdit window that lets you copy the text to display (click on the allows to know the number of the input string that is displayed in the window title)
 * The button reverses the text
 * checked, this option consider the text as word, the text is cut on space and write the text word by word (instead character by character in normal use)
 * The button displays the wiki page in the FreeCAD browser
 * LineEdit: display the path and name of file font
 * button for search the font in other directory in case all directory is not discovery automatically
 * ComboView to choose the font
 * return to origin system font path ex: "C:/Windows/Fonts/"
 * Default ARIAL.TTF

Options available
After the first use, you must modify the following parameters:

User parameter:BaseApp/Preferences/Macros/FCMmacros/FCCircularText

switchModeTextList
 * 0 = normal text mode (and black) cuts the switchFontComBox
 * 1 = allows switchFontComBox 1

switchFontComBox
 * 0 = (and switchModeTextList= 1) text mode (in color) in ComboBox list, faster
 * 1 = (and switchModeTextList= 1) fontFamily slower but more beautiful ComboBoxst!

setSystemFonts
 * 0 = matplotlib.font_manager.findSystemFonts("C:/", "ttf")
 * do all the fonts (in all folders and sub-folders of the DD) time !!
 * 1 = fontman.findSystemFonts(self.pathFont)
 * do all the fonts in the directory (and in all the sub-folders)

seTtextAlignement
 * 0 = AlignLeft (default)
 * 1 = AlignCenter
 * 2 = AlignRight

setFontByDefault
 * Font by Default

switchResetFALSE
 * 0 = reset (default)
 * 1 = no reset (not recommended) some switches can remain open or close unexpectedly!

Example


 * 1) switchModeTextList=
 * 2) switchFontComBox =
 * 3) setSystemFonts   =
 * 4) seTtextAlignement = 0


 * 1) switchModeTextList=
 * 2) switchFontComBox =
 * 3) setSystemFonts   =
 * 4) seTtextAlignement = 0


 * 1) switchModeTextList=
 * 2) switchFontComBox =
 * 3) setSystemFonts   =
 * 4) seTtextAlignement = 1 (0=Left, 1=Centered, 2=Right)


 * 1) switchModeTextList=
 * 2) switchFontComBox =
 * 3) setSystemFonts   =
 * 4) seTtextAlignement = 1

Second Section
Configuring characters in FCCircularText



First zone
Your choice :



Second area
This section allows you to configure the overall behavior of characters in all the choices available but with some variation. If the command is not used in the option chosen, it will be grayed out.


 * Radius of circle : Radius of the circle. (Default 10)
 * Size character : Character height. (Default 2)
 * Begin angle : Starting angle of the first character in the circle. (Default 0 °)
 * End angle : Angle end of the last character of the text. (Default 360)
 * Correction angle : Character correction angle to make it tangent to the circle. (Default 10 °)
 * Correction radius : Fixed the radius of the circle characters (optional). (Default 0.15)
 * : Checkbox extrusion characters. (Inactive Default)
 * : Text placement in the 3D view. (Inactive Default)
 * : Inclination of characters in three axes X, Y and Z (example to cover such a cone). (Inactive Default)
 * : Inclination of characters in three axes X, Y and Z (example to cover such a cone). (Inactive Default)

Outdoor
Default mode. The text is written on the outside of the circumference of the circle.

Indoor
The text is written on the inner side of the circumference of the circle

Helix
The text is entered on the outer circumference of a helix.


 * The helix area is hidden by default. The window is visible if the radio button is checked


 * All characters configuration options are available.
 * Step of helix which corresponds to the pitch of the helix turns and displays 2 (character height) by default.
 * Char. per turn activates and displays 10 by default, which corresponds to 10 characters per helical turn.


 * If Step of helix (helix pitch) is zero, Spinboxes Base Helix and End Helix are activated.
 * Base Helix provides the basis for starting the helix (even Placement Z). If  'Placement Z'  is different from zero, the starting point is added to Z Placement
 * End Helix End of the helix pitch of the helix will be calculated relative to the height and the number of characters per helical turn.

Clock
The figures are part of a circle with Arabic numerals or Romans.


 * By default, the section is hidden. The window is visible if the radio button is checked


 * When the selection is made, the following functions get dark and are usable:
 * Begin angle.
 * End angle.
 * Correction angle.
 * Correction radius.
 * The buttom or.
 * The area Clock is activated.


 * Radius of support : If a value is given, support will be created (default 0).
 * If Support number face is different from zero a support is created. (If Extrude support = zero then a face is created).
 * 1 = A circle is created (circle appears).
 * 2 = A rectangle is created (length = (Radius of media * 1.5) width = Radius of support) (Rectangle appears).
 * 3 = A triangle is created (circumscribed) (Triangle appears).
 * 4 = A square is created (Radius of support) (Square appears).
 * 5 = A polygon with the number of faces displayed (circumscribed) (Polygon appears).
 * Extrude support is activated and an extrusion dimension can be given.






 * If Support number face is equal to zero there is no support.
 * : The writing will be in Roman figures I II III IIII V VI VII VIII IX X XI XII
 * : The figures will be written axially.

Path section


The title section change and display the length of the wire selected.

If you select one wire, arc, circle, line and edge the section Path is coloured in and the unused command coloured in


 * 1) the character is Orthogonal to the view
 * 2) the character is Tangent to point path on wire


 * 1) the point base of the character is to point path on the wire
 * 2) the bounBox center of the character is to point path on the wire
 * 3) the top boundBox of the character is to point path on the wire

the last Radio Button used is saved in the parameter of FreeCAD

Command section



 * : Leaves the macro.
 * : Reset all values and displays the number of characters displayed in the window.
 * : Launches the macro and creates a Compount object of all characters.
 * : Launches the macro

Parameters available
Certain parameter are available in the parameters of FreeCAD see:


 * User parameter: BaseApp/Preferences/Macros/FCMmacros/FCCircularText


 * normal text mode (and black) turns off switchFontComBox
 * allow switchFontComBox 1 (default)
 * (and switchModeTextList = 1) text mode (in color) in Faster ComboBox list (default)
 * (and switchModeTextList = 1) font Family in ComboBox list slower but more beautiful!
 * matplotlib.font_manager.findSystemFonts ("C: /", "ttf") do all fonts (in all folders and subfolders of the HD) time !!
 * fontman.findSystemFonts (self.pathFont) make all the fonts in the directory (and in all the subfolders) (default)
 * : 0 = AlignLeft (default) 1 = AlignCenter 2 = AlignRight
 * : Font by Default (the last used)
 * : reset (default),  no reset (not recommended) some switches can stay open or close unexpectedly!
 * : FCCircularText version
 * : Font by Default (the last used)
 * : reset (default),  no reset (not recommended) some switches can stay open or close unexpectedly!
 * : FCCircularText version
 * : FCCircularText version
 * : FCCircularText version
 * : FCCircularText version
 * : FCCircularText version
 * : FCCircularText version
 * : FCCircularText version

Launch the macro folder FcString for created characters and a file FcClock for created clocks.

Script
The button icon:

- in .PNG

- in .SVG

(See Customize_Toolbars for more)

Script
Macro_Circular_Text.FCMacro

or download the script :

- on github Macro_FCCircularText.FCMacro ver 0.21 2022/05/31

- at the forum Extrude from curved surface of cylinder

Limitations
it is possible that an error may occur between versions. Please post the issue on the forum and wait for the updated fix or rollback to a previous version of the macro. Thank you)

It is possible that two characters may overlap. If this happens, here's a workaround is available using the Rotate-To-Point Macro.

(not fully developed)

Planned:

Writing on a path circular text of position object selected.

Change log
see Curved text on a flat surface?
 * ver 0.22c 2023/11/17 : adding restore selection after delete the last object, by TheMarkster , thanks


 * ver 0.22b 2023/11/15 : upgrade correction stylesheet and FreeCAD.activeDocument.recompute(None,True,True)


 * ver 0.22 2022/06/06 : adding QScrollArea cause : Unable to run FCCircularText [Problem with screen size ]


 * ver 0.21 2022/05/31 : adding button search other path fontmanuelly, and button return font origin of system


 * ver 0.20 2021/04/05 : adding icone in macro, Tab for diminish the heigth of the macro, remove all dimensions of widgets now fully compatible with the stylesheet, revisite the search version for compatibility and other little change.


 * ver 1.19 2021/03/15 : adding button the last object created and the code  for Undo/Redo system


 * Adding CheckBox for switched/activated (requested by users) the natural reset after all push button and . This use checkBox is, is you constade one malfunction pusch the  button or quit FCCircularText and restart.


 * ver 0.18 2021/01/19 : correction bug see FCCircularText Macro issues


 * ver 0.17b 2020/09/28 : correction little bug (pl instead plm in path section) and arrange the window (dimension) Clock, Helix, Path


 * ver 0.17 2020/09/26 : adding create circular text on wire (curve, arc, spline, line ...) selected, mode word

ver 16d 2020/09/15 : see the MasterCATZ commented Sep 14, 2020 message

delette the FC 0.18 test section:


 * ver 0.16c 2020/07/24 : modify text proposed by Kunda1 Please review FCVerticalText Macro


 * ver 0.16b 2020/07/24 : correct __title__ to __Title__ in 0.18 FC test (see Please review FCVerticalText Macro)


 * ver 0.16 2020/06/07 : little bug in Linux with the path, impost PolicePath = "/usr/share/fonts/" (stay on path /xx/xx/xx/xx/xx/xx/ on entry)


 * ver 0.15 2020/06/01 : For PySide2 Qt5 adding matplotlib fonts in comboView, config on parameter


 * ver 0.14-4 2020/04/25 : corrected for "DisplayMode = u"Flat Lines" :


 * ver 0.14-3 2020/04/25 : adapted for :


 * ver 0.14-2 2019/07/22 replace chr(176) (give error <FC 0.18) and replace with the wmayer code, see Fehler in Version 0.19 pre ??

carDegrees = b' \xc2\xb0'.decode("utf-8")   #thanks wmayer	https://forum.freecadweb.org/viewtopic.php?f=13&t=36380&p=308476#p308357 self.DS_InclinaisonX.setSuffix(carDegrees) self.DS_InclinaisonY.setSuffix(carDegrees) self.DS_InclinaisonZ.setSuffix(carDegrees)


 * ver 0.14-1 2019/06/11 replace "°" to chr(176)


 * ver 0.14 2019/04/27 compatible for Python 3.6.6 and Qt 5.6.2 (cause: unicode )


 * ver 0.13 30/01/2018 add feature Pivot for rotate the character on himself


 * ver 0.13 09/08/2016 replace the button "New font" to "fontComboBox" cause, with Windows 10 the window Font stay empty the files are hidden

replace the line
 * ver 0.12 03/07/2016 optimize the code for accept the decimal number in determination angle

to


 * ver 0.10 17/05/2015 adding lines 1365, 1366 only created more clock face ??


 * ver 0.9 11/05/2015 thank you NormandC for testing

replace

to


 * ver 0.8 10/05/2015 replace "String=texte[ii2]" to "String=unicode(texte[ii2])" line 1290. cause "TypeError: Property 'FontFile': type must be str or unicode, not QString"


 * ver 0.7 02/02/2015 suppression 2 str App.Console.PrintMessage(str(PolicePath)+"\n") to App.Console.PrintMessage((PolicePath)+"\n") that caused an error with the characters above 128 in the police path.
 * ver 0.6 23/11/2014 corrected "texte = unicode(self.textEdit.toPlainText)" now accept "'éèà@..."
 * ver 0.5 19/11/2014 Gui
 * ver 0.4 10/10/2014 add variable "rotation" in the loop (for i in range(0,rotation,(rotation/nombre)): # 360 a parametrer)
 * ver 0.4 27/08/2014 correction error of de radius (exterieur=0, debout=1)
 * ver 0.3 26/08/2014 add creation text of flat curve
 * ver 0.2 26/08/2014 add creation text of internal curve
 * ver 0.1

(2537)

Links
To comment on the Extrude from curved surface of cylinder