Macro FCCircularText/en: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
<languages/>
<languages/>

{{Macro
{{Macro
|Name=Macro Circular Text
|Name=Macro FCCircularText
|Icon=FCCircularTextButtom.png
|Icon=FCCircularTextButtom.png
|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 manner of Trajan 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.
|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 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.
|Author=Mario52
|Author=Mario52
|Version=0.14-2
|Version=0.22c
|Date=2019/07/22
|Date=2023/11/17
|FCVersion=All
|FCVersion=0.19 and more
|Download=[https://www.freecadweb.org/wiki/images/c/c1/FCCircularTextButtom.png ToolBar Icon]
|Download=[https://www.freecadweb.org/wiki/images/c/c1/FCCircularTextButtom.png ToolBar Icon]
}}
}}
Line 13: Line 14:
==Description==
==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 manner of [http://en.wikipedia.org/wiki/Trajan%27s_Column 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 [http://forum.freecadweb.org/viewtopic.php?f=22&t=5013&hilit=Clock Macro to Create Clock Face] by cblt2l.
This macro makes use of the [[Image:Draft_ShapeString.svg|24px|link=Draft ShapeString]] [[Draft ShapeString|Draft ShapeString]] tool to create a text line placed in different circular orientations, including circumferential and helical in the fashion of a [http://en.wikipedia.org/wiki/Trajan%27s_Column 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 [http://forum.freecadweb.org/viewtopic.php?f=22&t=5013&hilit=Clock Macro to Create Clock Face] by FC community member, cblt2l.


{{Codeextralink|https://gist.githubusercontent.com/mario52a/a25e802498bae6959335/raw/ef4312f8f63f65e298e9ae22e9d2e9a5550cf707/Macro_FCCircularText.FCMacro}}
{{Codeextralink|https://gist.githubusercontent.com/mario52a/a25e802498bae6959335/raw/7ab8a1e9dd7f924a62ecef83ec1d2ad8723e37d6/Macro_FCCircularText.FCMacro}}


[[File:FCCircularText 01.png|400px|texte 360 degrees]]
:[[File:FCCircularText 01.png|400px|360 degree orientation]]
{{Caption|Example of the macro displaying text in a 360 degree orientation}}


==Utilisation==
==Usage==

Principle: The options that are not useful for the selected function are dimmed so inaccessible.

A function can gray out options if they are not for him.


Launch the macro folder '''FcString''' for created characters and a file '''FcClock''' for created clocks.
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 {{KEY|Run Comp}} is copied out of the folder.
All the characters are and remain independent. When creating extrusions nothing is deleted. If Compound is created with {{Button|Run Comp}} it is copied out of the folder.


The options are shaded by default and are active in all functions if they are checked :
The options are shaded by default and are active in all functions if they are checked {{CheckBox|TRUE|}}:
* '''Extrude Char.'''
* {{CheckBox|Extrude Char.}}
* '''Placement.'''
* {{CheckBox|Placement.}}
* '''SP. inclination.'''
* {{CheckBox|SP. inclination.}}


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.
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.


==Notes==
=== Presentation ===

* This macro will gray-out (deactivate) options that are not relevant for a selected function.

== Interface ==

Overview
Overview


Line 42: Line 45:
{{clear}}
{{clear}}


==First section==
===First section===


[[File:FCCircularText 07.png|center]]
[[File:FCCircularText 07.png|center]]
{{clear}}
{{clear}}


* TextEdit window that lets you copy the text to display (click on the {{KEY|Reset}} allows to know the number of the input string that is displayed in the window title)
* TextEdit window that lets you copy the text to display (click on the {{Button|Reset}} allows to know the number of the input string that is displayed in the window title)
* The {{KEY|Reverse}} to reverse the text
* The {{Button|Reverse}} button reverses the text
* {{CheckBox|Word}} 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 {{KEY|New Font}} to select a new font to use
* The {{Button|Help}} button displays the wiki page in the FreeCAD browser
* LineEdit: display the path and name of file font
* {{Button|Other}} button for search the font in other directory in case all directory is not discovery automatically
* ComboView to choose the font
* {{Button|Origin}} return to origin system font path ex: "C:/Windows/Fonts/"
** Default ARIAL.TTF
** Default ARIAL.TTF


====Options available====
== Second Section ==

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'''

[[File:FCCirculatText Config 0000A0.png]]
#switchModeTextList= {{FALSE}}
#switchFontComBox = {{FALSE}}
#setSystemFonts = {{FALSE}}
#seTtextAlignement = 0
{{clear}}

[[File:FCCirculatText Config 1000A0.png]]
#switchModeTextList= {{TRUE}}
#switchFontComBox = {{FALSE}}
#setSystemFonts = {{FALSE}}
#seTtextAlignement = 0
{{clear}}

[[File:FCCirculatText Config 1001A0.png]]
#switchModeTextList= {{TRUE}}
#switchFontComBox = {{FALSE}}
#setSystemFonts = {{FALSE}}
#seTtextAlignement = 1 ''(0=Left, 1=Centered, 2=Right)''
{{clear}}

[[File:FCCirculatText Config 1101A0.png]]
#switchModeTextList= {{TRUE}}
#switchFontComBox = {{TRUE}}
#setSystemFonts = {{FALSE}}
#seTtextAlignement = 1
{{clear}}

=== Second Section ===

Configuring characters in FCCircularText
Configuring characters in FCCircularText


Line 58: Line 129:
{{clear}}
{{clear}}


===First zone===
====First zone====

Your choice :
Your choice:


[[File:FCCircularText 09.png|left]]
[[File:FCCircularText 09.png|left]]
Line 73: Line 145:


[[File:FCCircularText 24.png|left]]
[[File:FCCircularText 24.png|left]]
* {{KEY|Mode Stand}} or {{KEY|Mode Flat}} : The text will be placed standing or flat (same as clock) options '''Outdoor''' and '''Indoor''' are reversed.
* {{Button|Mode Stand}} or {{Button|Mode Flat}} : The text will be placed standing or flat (same as clock) options '''Outdoor''' and '''Indoor''' are reversed.
{{clear}}
{{clear}}


Line 90: Line 162:
</center>
</center>


=== Second area ===
==== Second area ====

This section allows you to configure the overall behavior of characters in all the choices available but with some variation.
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.
If the command is not used in the option chosen, it will be grayed out.


[[File:FCCircularText 10.png| left]]
[[File:FCCircularText 10.png| left]]
* '''Radius of circle''' : Radius of the circle. (Default 10)
* {{SpinBox|10.0 mm}} '''Radius of circle''' : Radius of the circle. (Default 10)
* '''Size character''' : Character height. (Default 2)
* {{SpinBox|2.0 mm}} '''Size character''' : Character height. (Default 2)
* '''Begin angle''' : Starting angle of the first character in the circle. (Default 0 °)
* {{SpinBox|0 deg}} '''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)
* {{SpinBox|360 deg}} '''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 °)
* {{SpinBox|10.0 deg}} '''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)
* {{SpinBox|0.15 mm}} '''Correction radius''' : Fixed the radius of the circle characters (optional). (Default 0.15)
*
*
* '''Pivot Character ''': Pivot the character on himself. (Inactive Default)
* {{CheckBox|'''Extrude Char'''}} : Checkbox extrusion characters. (Inactive Default)
* '''Extrude Char''' : Checkbox extrusion characters. (Inactive Default)
* {{CheckBox|'''Placement'''}} : Text placement in the 3D view. (Inactive Default)
* '''Placement''' : Text placement in the 3D view. (Inactive Default)
* {{CheckBox|'''Sp. inclination'''}} : Inclination of characters in three axes X, Y and Z (example to cover such a cone). (Inactive Default)
* '''Sp. inclination''' : Inclination of characters in three axes X, Y and Z (example to cover such a cone). (Inactive Default)
{{clear}}
{{clear}}


===Outdoor===
=====Outdoor=====

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


Line 119: Line 192:
</center>
</center>


===Indoor===
=====Indoor=====

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


Line 130: Line 204:
</center>
</center>


===Helix===
=====Helix=====

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


Line 141: Line 216:
</center>
</center>


* The helix area is hidden by default. The window is visible if the radio button {{RadioButton|TRUE|Helix}} is checked
[[File:FCCircularText 11.png|left]]
* The helix area is grayed out by default.
{{clear}}
{{clear}}
[[File:FCCircularText 14.png|left]]
[[File:FCCircularText 14.png|left]]
Line 154: Line 228:
* '''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.
* '''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=====


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


Line 166: Line 240:
</center>
</center>


* By default, the section is hidden. The window is visible if the radio button {{RadioButton|TRUE|Clock}} is checked
[[File:FCCircularText 12.png|left]]
* By default, the section is grayed.
{{clear}}
{{clear}}
[[File:FCCircularText 16.png|left]]
[[File:FCCircularText 16.png|left]]
Line 175: Line 248:
*# Correction angle.
*# Correction angle.
*# Correction radius.
*# Correction radius.
*# The buttom {{KEY|Mode Stand}} or {{KEY|Mode Flat}}.
*# The buttom {{Button|Mode Stand}} or {{Button|Mode Flat}}.
* The area '''Clock''' is activated.
* The area '''Clock''' is activated.
{{clear}}
{{clear}}
Line 190: Line 263:
{{clear}}
{{clear}}


[[File:FCCircularText 17.png|left]][[File:FCCircularText_38.png|200px]]
[[File:FCCircularText 18.png|left]][[File:FCCircularText_38.png|200px]]
{{clear}}
{{clear}}
[[File:FCCircularText 18.png|left]][[File:FCCircularText_37.png|200px]]
[[File:FCCircularText 17.png|left]][[File:FCCircularText_37.png|200px]]
{{clear}}
{{clear}}


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


===Commands===
===Path section===

[[File:FCCircularText_06_Path.png]]
{{clear}}

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 {{ColoredText|#E0F8E0|green}} and the unused command coloured in {{ColoredText|#F8E0E0|red}}

#{{RadioButton|Orthogonal}} the character is Orthogonal to the view
#{{RadioButton|Tangent}} the character is Tangent to point path on wire

#{{RadioButton|BB Base}} the point base of the character is to point path on the wire
#{{RadioButton|BB Center}} the bounBox center of the character is to point path on the wire
#{{RadioButton|BB Top}} 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===


[[File:FCCircularText 13.png]]
[[File:FCCircularText 13.png]]
{{clear}}
{{clear}}


* {{KEY|Exit}} : Leaves the macro.
* {{Button|Exit}} : Leaves the macro.
* {{KEY|Reset}} : Reset all values and displays the number of characters displayed in the window.
* {{Button|Reset}} : Reset all values and displays the number of characters displayed in the window.
* {{KEY|Run Comp}} : Launches the macro and creates a Compount object of all characters.
* {{Button|Run Comp}} : Launches the macro and creates a Compount object of all characters.
* {{KEY|Run}} : Launches the macro
* {{Button|Run}} : Launches the macro


===Parameters available===
Launch the macro folder '''FcString''' for created characters and a file '''FcClock''' for created clocks.


Certain parameter are available in the parameters of FreeCAD see: {{MenuCommand|Menu → Tools → Edit parameters...}}
==Script==
Download the script :


*User parameter: BaseApp/Preferences/Macros/FCMmacros/FCCircularText
- on github [https://gist.github.com/mario52a/a25e802498bae6959335 Macro_FCCircularText.FCMacro] ver 0.14-1 11/06/2019


**{{incode|switchModeTextList}} :
- at the forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=7384&p=87642#p87642 Extrude from curved surface of cylinder]
***{{FALSE}} normal text mode (and black) turns off switchFontComBox
***{{TRUE}} allow switchFontComBox 1 (default)
**{{incode|switchFontComBox}} :
***{{FALSE}} (and switchModeTextList = 1) text mode (in color) in Faster ComboBox list (default)
***{{TRUE}} (and switchModeTextList = 1) font Family in ComboBox list slower but more beautiful!
**{{incode|setSystemFonts}} :
***{{FALSE}} matplotlib.font_manager.findSystemFonts ("C: /", "ttf") do all fonts (in all folders and subfolders of the HD) time !!
***{{TRUE}} fontman.findSystemFonts (self.pathFont)</br>make all the fonts in the directory (and in all the subfolders) (default)
**{{incode|seTtextAlignement}} : 0 = AlignLeft (default) 1 = AlignCenter 2 = AlignRight
**{{incode|setFontByDefault}} : Font by Default (the last used)
**{{incode|switchResetFALSE}} : {{FALSE}} reset (default), {{TRUE}} no reset (not recommended) some switches can stay open or close unexpectedly!
**{{incode|setPathOrthogonal}} : {{TRUE}} {{FALSE}}
**{{incode|setPathTangent}} : {{TRUE}} {{FALSE}}
**{{incode|setPositionBase}} : {{TRUE}} {{FALSE}}
**{{incode|setPositionCenter}} : {{TRUE}} {{FALSE}}
**{{incode|setPositionTop}} : {{TRUE}} {{FALSE}}
**{{incode|switchVersionSearch}} : {{TRUE}} {{FALSE}}
**{{incode|Version}} : FCCircularText version

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

==Script==


The button icon:
The button icon:
Line 225: Line 337:


(See [[Customize_Toolbars| Customize_Toolbars]] for more)
(See [[Customize_Toolbars| Customize_Toolbars]] for more)

===Script===

'''Macro_Circular_Text.FCMacro'''

or download the script :

- on github [https://gist.github.com/mario52a/a25e802498bae6959335 Macro_FCCircularText.FCMacro] ver 0.21 2022/05/31

- at the forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=7384&p=87642#p87642 Extrude from curved surface of cylinder]


==Example==
==Example==
Line 239: Line 361:
Image:FCCircularText 04.png|Text circular on internal and external curve.
Image:FCCircularText 04.png|Text circular on internal and external curve.
Image:FCCircularText 05.png|Circular text on a flat onbjet.
Image:FCCircularText 05.png|Circular text on a flat onbjet.
</gallery>
</center>
<br />
<center>
<gallery widths="300" heights="200">
Image:FCCircularText IndoorFlat 01.png|Configuration Superior.(click to elarge)
Image:FCCircularText IndoorFlat 02.png|Configuration Inferior.(click to elarge)
</gallery>
</gallery>
</center>
</center>
Line 275: Line 404:
Image:FCCircularText 42.png|Ring Internal curve with subtraction.
Image:FCCircularText 42.png|Ring Internal curve with subtraction.
Image:FCCircularText 61.png|Pivot character 0°, 90°, ....
Image:FCCircularText 61.png|Pivot character 0°, 90°, ....
</gallery>
</center>
<br />
<center>
<gallery widths="300" heights="200">
Image:FCCircularText_Path_00_002_000.png| {{CheckBox|TRUE|Word}} The text is cutting on space character
</gallery>
</gallery>
</center>
</center>
Line 302: Line 437:
<center>
<center>
<gallery widths="300" heights="200">
<gallery widths="300" heights="200">
Image:FCCircularText 49.png|Create the text with {{KEY|Run Comp}}.
Image:FCCircularText 49.png|Create the text with {{Button|Run Comp}}.
Image:FCCircularText 50.png|Select Ellipse Extrude, Shape and press the {{KEY|[[Image:Part Cut.png|16px]] '''Part Cut'''}} button.
Image:FCCircularText 50.png|Select Ellipse Extrude, Shape and press the {{Button|[[Image:Part_Cut.svg|16px]] '''Part Cut'''}} button.
</gallery>
</gallery>
</center>
</center>
Line 317: Line 452:
<center>
<center>
<gallery widths="300" heights="200">
<gallery widths="300" heights="200">
Image:FCCircularText 53.png|Create an ellipse. [[File:Draft_Ellipse.png]]
Image:FCCircularText 53.png|Create an ellipse. [[File:Draft_Ellipse.svg]]
Image:FCCircularText 54.png|Create a rectangle include all object. [[File:Draft_Rectangle.png]]
Image:FCCircularText 54.png|Create a rectangle include all object. [[File:Draft_Rectangle.svg]]
</gallery>
</gallery>
</center>
</center>
Line 342: Line 477:
</center>
</center>
<br />
<br />
==Little bug==


==Example section path==
It is possible that two characters overlap, here a small remedy with [https://www.freecadweb.org/wiki/Macro_Rotate_To_Point Macro_Rotate_To_Point]

<center>
<gallery widths="300" heights="200">
Image:FCCircularText_Path_00_Orth_Base_000.png|Text on BoundBox Base (normal)
Image:FCCircularText_Path_00_Orth_Center_000.png|Text on BoundBox Center character
</gallery>
</center>
<br />

<center>
<gallery widths="300" heights="200">
Image:FCCircularText_Path_00_Orth_Top_000.png|Text on BoundBox Top character
Image:FCCircularText_Path_00_001_000_000.png|Text on selected line:<br />1: Orthogonal<br />2: Tangent
</gallery>
</center>
<br />
<center>
<gallery widths="797" heights="624">
File:YamahaDrumBadge00.gif|Exemple use ([https://forum.freecad.org/viewtopic.php?t=82577 Curved text on a flat surface?])
</gallery>
</center>
<br />

==Limitations==

{{Emphasis|Note}} 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 [https://www.freecadweb.org/wiki/Macro_Rotate_To_Point Rotate-To-Point Macro].
<br />
<br />
<center>
<center>
<gallery widths="630" heights="400">
<gallery widths="630" heights="400">
Image:FCCircularText Correction.gif|Little "bug" and remedy example.
Image:FCCircularText Correction.gif|Character overlap issue and the workaround
</gallery>
</gallery>
</center>
</center>
Line 355: Line 517:
(not fully developed)
(not fully developed)


Planned :
Planned:


Writing on a path circular text of position object selected.
Writing on a path circular text of position object selected.


==Change log==
'''(PS : it is possible that an error is made between version 2 Please wait for the next or return to the previous version thank you)'''


*ver 0.22c 2023/11/17 : adding restore selection after delete the last object , by TheMarkster , thanks
==Currently:==
see [https://forum.freecad.org/viewtopic.php?p=719353#p719353 Curved text on a flat surface?]
{{Code|code=
sel = Gui.Selection.getCompleteSelection()
#delete objects
#restore previous selection
Gui.Selection.clearSelection()
for s in sel:
Gui.Selection.addSelection(s.Object,s.SubElementNames)
}}
*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 : [https://forum.freecadweb.org/viewtopic.php?f=3&t=69206 Unable to run FCCircularText [Problem with screen size<nowiki>]</nowiki>]

*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 {{Button|Delette}} the last object created and the code {{incode|FreeCAD.ActiveDocument.openTransaction("FCCTc")}} for Undo/Redo system

**Adding CheckBox {{CheckBox|FALSE|Reset}} for switched/activated (''requested by users'') the natural reset after all push button {{Button|Run}}and {{Button|Run comp}}. This use checkBox is {{ColoredText|not advised}}, is you constade one malfunction pusch the {{Button|Reset}} button or quit FCCircularText and restart.

*ver 0.18 2021/01/19 : correction bug see [https://forum.freecadweb.org/viewtopic.php?f=22&t=54524&p=468687#p468687 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 [https://gist.github.com/mario52a/a25e802498bae6959335 MasterCATZ commented Sep 14, 2020 message]

delette the FC 0.18 test section:

{{Code|code=
#### Test FreeCAD.Version simple ############################################################################################################
if int(FreeCAD.Version()[1]) < 18: # Version de FreeCAD
FreeCAD.Console.PrintMessage("This version " + __Title__ + " rmu work with the FreeCAD 0.18 or higher." + "\n\n")
FreeCAD.Console.PrintMessage("For the precedent version see the page " + "\n\n")
FreeCAD.Console.PrintMessage("https://gist.githubusercontent.com/mario52a/a25e802498bae6959335/raw/db47f78f2b20a35137ac213b8d1a62d30f525dcb/Macro_FCCircularText.FCMacro" + "\n\n")
#### Test FreeCAD.Version simple ############################################################################################################
}}

*ver 0.16c 2020/07/24 : modify text proposed by Kunda1 [https://forum.freecadweb.org/viewtopic.php?f=22&t=48902#p418776 Please review FCVerticalText Macro]

*ver 0.16b 2020/07/24 : correct '''__title__''' to '''__Title__''' in 0.18 FC test (see [https://forum.freecadweb.org/viewtopic.php?f=22&t=48902 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 :

{{Code|code=
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20655 (Git)
Build type: Release
Branch: master
Hash: e8e67e8c5ebbc9f9ed9ea67aba5b891969595ece
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
}}


*ver 0.14-2 2019/07/22 replace chr(176) (give error <FC 0.18) and replace with the wmayer code, see [https://forum.freecadweb.org/viewtopic.php?f=13&t=36380&p=308476#p308357 Fehler in Version 0.19 pre ??]
*ver 0.14-2 2019/07/22 replace chr(176) (give error <FC 0.18) and replace with the wmayer code, see [https://forum.freecadweb.org/viewtopic.php?f=13&t=36380&p=308476#p308357 Fehler in Version 0.19 pre ??]
Line 467: Line 694:
To comment on the [http://forum.freecadweb.org/viewtopic.php?f=3&t=7384 Extrude from curved surface of cylinder]
To comment on the [http://forum.freecadweb.org/viewtopic.php?f=3&t=7384 Extrude from curved surface of cylinder]


{{Draft Tools navi{{#translation:}}}}
{{clear}}
{{Userdocnavi{{#translation:}}}}
{{Draft Tools navi}}
{{Userdocnavi}}

Latest revision as of 14:21, 18 November 2023

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 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.

Macro version: 0.22c
Last modified: 2023/11/17
FreeCAD version: 0.19 and more
Download: ToolBar Icon
Author: Mario52
Author
Mario52
Download
ToolBar Icon
Links
Macro Version
0.22c
Date last modified
2023/11/17
FreeCAD Version(s)
0.19 and more
Default shortcut
None
See also
None

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.

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "https://gist.githubusercontent.com/mario52a/a25e802498bae6959335/raw/7ab8a1e9dd7f924a62ecef83ec1d2ad8723e37d6/Macro_FCCircularText.FCMacro" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("https://gist.githubusercontent.com/mario52a/a25e802498bae6959335/raw/7ab8a1e9dd7f924a62ecef83ec1d2ad8723e37d6/Macro_FCCircularText.FCMacro")


360 degree orientation

Example of the macro displaying text in a 360 degree orientation

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 Run Comp it is copied out of the folder.

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

  • Extrude Char.
  • Placement.
  • SP. inclination.

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.

Notes

  • This macro will gray-out (deactivate) options that are not relevant for a selected function.

Interface

Overview

GUI

First section

  • TextEdit window that lets you copy the text to display (click on the Reset allows to know the number of the input string that is displayed in the window title)
  • The Reverse button reverses the text
  • Word 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 Help button displays the wiki page in the FreeCAD browser
  • LineEdit: display the path and name of file font
  • Other button for search the font in other directory in case all directory is not discovery automatically
  • ComboView to choose the font
  • Origin 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= false
  2. switchFontComBox = false
  3. setSystemFonts = false
  4. seTtextAlignement = 0

  1. switchModeTextList= true
  2. switchFontComBox = false
  3. setSystemFonts = false
  4. seTtextAlignement = 0

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

  1. switchModeTextList= true
  2. switchFontComBox = true
  3. setSystemFonts = false
  4. seTtextAlignement = 1

Second Section

Configuring characters in FCCircularText

First zone

Your choice:

  • Mode Stand or Mode Flat : The text will be placed standing or flat (same as clock) options Outdoor and Indoor are reversed.

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.

  • 10.0 mm Radius of circle : Radius of the circle. (Default 10)
  • 2.0 mm Size character : Character height. (Default 2)
  • 0 deg Begin angle : Starting angle of the first character in the circle. (Default 0 °)
  • 360 deg End angle : Angle end of the last character of the text. (Default 360)
  • 10.0 deg Correction angle : Character correction angle to make it tangent to the circle. (Default 10 °)
  • 0.15 mm Correction radius : Fixed the radius of the circle characters (optional). (Default 0.15)
  • Extrude Char : Checkbox extrusion characters. (Inactive Default)
  • Placement : Text placement in the 3D view. (Inactive Default)
  • Sp. inclination : 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 Helix 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 Clock is checked
  • When the selection is made, the following functions get dark and are usable:
    1. Begin angle.
    2. End angle.
    3. Correction angle.
    4. Correction radius.
    5. The buttom Mode Stand or Mode Flat.
  • 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.
  • Mode Roman : The writing will be in Roman figures I II III IIII V VI VII VIII IX X XI XII
  • Axial  : 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 green and the unused command coloured in red

  1. Orthogonal the character is Orthogonal to the view
  2. Tangent the character is Tangent to point path on wire
  1. BB Base the point base of the character is to point path on the wire
  2. BB Center the bounBox center of the character is to point path on the wire
  3. BB Top 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

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

Parameters available

Certain parameter are available in the parameters of FreeCAD see: Menu → Tools → Edit parameters...

  • User parameter: BaseApp/Preferences/Macros/FCMmacros/FCCircularText
    • switchModeTextList :
      • false normal text mode (and black) turns off switchFontComBox
      • true allow switchFontComBox 1 (default)
    • switchFontComBox :
      • false (and switchModeTextList = 1) text mode (in color) in Faster ComboBox list (default)
      • true (and switchModeTextList = 1) font Family in ComboBox list slower but more beautiful!
    • setSystemFonts :
      • false matplotlib.font_manager.findSystemFonts ("C: /", "ttf") do all fonts (in all folders and subfolders of the HD) time !!
      • true fontman.findSystemFonts (self.pathFont)
        make all the fonts in the directory (and in all the subfolders) (default)
    • seTtextAlignement : 0 = AlignLeft (default) 1 = AlignCenter 2 = AlignRight
    • setFontByDefault : Font by Default (the last used)
    • switchResetFALSE : false reset (default), true no reset (not recommended) some switches can stay open or close unexpectedly!
    • setPathOrthogonal : true false
    • setPathTangent : true false
    • setPositionBase : true false
    • setPositionCenter : true false
    • setPositionTop : true false
    • switchVersionSearch : true false
    • 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

Example













Example onto Ellipse






Mode relief:





Example section path




Limitations

Note 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

  • ver 0.22c 2023/11/17 : adding restore selection after delete the last object , by TheMarkster , thanks

see Curved text on a flat surface?

sel = Gui.Selection.getCompleteSelection()
#delete objects
#restore previous selection
Gui.Selection.clearSelection()
for s in sel:
    Gui.Selection.addSelection(s.Object,s.SubElementNames)
  • ver 0.22b 2023/11/15 : upgrade correction stylesheet and FreeCAD.activeDocument().recompute(None,True,True)
  • 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 Delette the last object created and the code FreeCAD.ActiveDocument.openTransaction("FCCTc") for Undo/Redo system
    • Adding CheckBox Reset for switched/activated (requested by users) the natural reset after all push button Runand Run comp. This use checkBox is not advised, is you constade one malfunction pusch the Reset button or quit FCCircularText and restart.
  • 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:

#### Test FreeCAD.Version simple ############################################################################################################
if int(FreeCAD.Version()[1]) < 18:      # Version de FreeCAD
    FreeCAD.Console.PrintMessage("This version " + __Title__ + " rmu  work with the FreeCAD 0.18 or higher." + "\n\n")
    FreeCAD.Console.PrintMessage("For the precedent version see the page " + "\n\n")
    FreeCAD.Console.PrintMessage("https://gist.githubusercontent.com/mario52a/a25e802498bae6959335/raw/db47f78f2b20a35137ac213b8d1a62d30f525dcb/Macro_FCCircularText.FCMacro" + "\n\n")
#### Test FreeCAD.Version simple ############################################################################################################
  • 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 :
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20655 (Git)
Build type: Release
Branch: master
Hash: e8e67e8c5ebbc9f9ed9ea67aba5b891969595ece
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
       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() )
latest testing:

#OS: Windows 10
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.19.16523 (Git)
#Build type: Release
#Branch: master
#Hash: 9b3ec233c8b21e0df66fada487cd10f471d60cac
#Python version: 3.6.6
#Qt version: 5.6.2
#Coin version: 4.0.0a
#OCC version: 7.3.0
  • 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
  • ver 0.12 03/07/2016 optimize the code for accept the decimal number in determination angle

replace the line

for angleTr in range(debut,rotation,((rotation-debut)/nombre)):

to

for angleTrFloat in range((debut*10000),(rotation*10000),int((round(((float(rotation)-float(debut))/float(nombre)),4)*10000)) ):    # pour 4 decimales
                angleTr = (float(angleTrFloat)/10000)
  • ver 0.10 17/05/2015 adding lines 1365, 1366 only created more clock face ?? ()
supp.MakeFace = True
            App.activeDocument().recompute()
  • ver 0.9 11/05/2015 thank you NormandC for testing

replace

self.DS_InclinaisonX.setSuffix(" X°")
        self.DS_InclinaisonY.setSuffix(" Y°")
        self.DS_InclinaisonZ.setSuffix(" Z°")

to

self.DS_InclinaisonX.setSuffix(unicode(" X°"))
        self.DS_InclinaisonY.setSuffix(unicode(" Y°"))
        self.DS_InclinaisonZ.setSuffix(unicode(" Z°"))
  • 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.8 10/05/2015 /_ # testing with OS :
##################################################################################################
# OS: Ubuntu 14.04.1 LTS                          # OS: Ubuntu 14.04.2 LTS
# Platform: 32-bit                                # Word size of OS: 32-bit
# Version: 0.14.2935 (Git)                        # Word size of FreeCAD: 32-bit
# Branch: master                                  # Version: 0.16.4928 (Git)
# Hash: eab159b6ee675012bf79de838c206a311e911d85  # Branch: master
# Python version: 2.7.6                           # Hash: d8f63bcfd10301f3d1e141cced4370f0782238d0
# Qt version: 4.8.6                               # Python version: 2.7.6
# Coin version: 4.0.0a                            # Qt version: 4.8.6
# SoQt version: 1.6.0a                            # Coin version: 4.0.0a
# OCC version: 6.7.0                              # OCC version: 6.8.0.oce-0.17
##################################################################################################
# OS: Windows Vista                               # OS: Windows Vista
# Word size of OS: 32-bit                         # Word size of OS: 32-bit
# Word size of FreeCAD: 32-bit                    # Word size of FreeCAD: 32-bit
# Version: 0.15.4527 (Git)                        # Version: 0.15.4671 (Git)
# Branch: master                                  # Branch: releases/FreeCAD-0-15
# Hash: 0da2e4c45a9a259c26abd54c2a35393e1c15696f  # Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
# Python version: 2.7.8                           # Python version: 2.7.8
# Qt version: 4.8.6                               # Qt version: 4.8.6
# Coin version: 4.0.0a                            # Coin version: 4.0.0a
# OCC version: 6.7.1                              # OCC version: 6.8.0.oce-0.17
##################################################################################################
  • 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