Tutte le macro devono essere documentate correttamente, nello stesso modo in cui vengono documentati i comandi GUI.
Dovrebbero avere una pagina wiki individuale e dovrebbero essere elencate in una delle categorie nella Raccolta di macro.
La pagina della Raccolta di macro contiene una buona selezione di macro create da utenti esperti e molte di esse possono essere installate direttamente da Addon Manager.
Consultare modello GuiCommand e pagine macro come Macro Loft e Macro Site From Contours per informazioni su come documentare le macro. È necessario includere almeno due sezioni: una sezione Descrizione con informazioni generali sull'utilizzo e una sezione Script per contenere il codice macro vero e proprio. È possibile includere altre sezioni, se necessario, per spiegare in modo più dettagliato l'utilizzo della macro.
Se una macro fornisce una funzionalità ben definita ed è ben documentata, potrebbe essere inclusa in futuro come parte di un ambiente di lavoro nuovo o esistente.
La pagina originale deve essere scritta in inglese. Dopo che uno degli amministratori l'avrà contrassegnata per la traduzione, potrà essere tradotta in un'altra lingua.
Creare una nuova pagina per la macro iniziando con la parola Macro_ seguita dal nome della macro, ad esempio Macro_Excellent_Modification. Per creare un collegamento alla pagina, usare: [[Macro_Excellent_Modification|Macro Excellent Modification]].
Nella nuova pagina si dovrebbe usare Template:Macro in alto, con un minimo di informazioni:
{{Macro
|Name=Macro Excellent Modification
|Description=This macro does excellent things on existing shapes
|Author=your username
|Date=2018-11-30
}}
È possibile aggiungere un'icona personalizzata se non ha lo stesso nome della macro; è anche possibile aggiungere altri campi di informazioni.
{{Macro
|Name=Macro Excellent Modification
|Icon=Macro_custom_icon.svg
|Description=This macro does excellent things on existing shapes
|Author=your username
|Date=2018-11-30
|Version=3.14516
|SeeAlso=[[Macro_Regular_Modification|Macro Regular Modification]]
}}
Quando si traduce la pagina, usare un modello localizzato. Si deve specificare il nome con il codice della lingua a due lettere (/fr, /it, /de) e indicare esplicitamente l'icona.
{{Macro/fr
|Name=Macro Excellent Modification translated
|Icon=Macro_Excellent_Modification.svg
|Description=(Translated description)
|Author=your username
|Date=2018-11-30
}}
oppure usare il campo Translate
{{Macro/fr
|Name=Macro Excellent Modification
|Translate=Macro Excellent Modification translated
|Description=(Translated description)
|Author=your username
|Date=2018-11-30
}}
Icon=Text-x-python.svg Icon=Text_console_python.png Template:Macro will put the information on using and installing the macros in every page.
How to install macros and customize toolbars links in the infobox on each macro page
OS: Ubuntu 18.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15302 (Git)
Build type: Release
Branch: master
Hash: 2e03d2f298677b8212c22cbbc3cb20b7c80eabb5
Python version: 2.7.15rc1
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Consider adding this information in a comment block inside the code of the macro.
Inside the Script section, use Template:MacroCode to place the code of the macro in the page. This will create a block of text that uses monospace font, which will preserve the whitespace that is essential for Python.
If the block of code contains the characters {{ }} (double closing brace and opening brace) or | (vertical bar), the <nowiki> ... </nowiki> tags can be added explicitly to allow displaying these special symbols.
This Template:MacroCode essentially generates a block of HTML tags <pre> ... </pre>, so these can be used directly instead of using the template. The Addon Manager will search for the biggest such block and use it for the body of the macro.
{{MacroCode|code=
«Your code should be here»
}}
Or if it includes the vertical bar |.
{{MacroCode|code=
<nowiki>
«Your code should be here»
</nowiki>
}}
Or
<pre> «Your code should be here» </pre>
Add header information before your actual code.
__Title__="Title_Of_macro"
__Author__ = "User_Name"
__Version__ = "00.11"
__Date__ = "2015-07-25"
__Comment__ = "This is the comment of the macro"
__Web__ = "https://forum.freecad.org/viewtopic.php?f=3&t=7384"
__Wiki__ = "https://wiki.freecad.org/index.php?title=Macro_Title_Of_macro"
__Icon__ = "/usr/lib/freecad/Mod/plugins/icons/Title_Of_macro"
__IconW__ = "C:/Users/YourUserName/AppData/Roaming/FreeCAD"
__Help__ = "start the macro and follow the instructions"
__Status__ = "stable"
__Requires__ = "freecad 0.14.3706"
__Communication__ = "https://wiki.freecad.org/index.php?title=User:User_Name"
«Your code should be here»
Starting with FreeCAD 0.17, this information is used by the Addon Manager, which downloads the macro from the FreeCAD-macros repository.
If your macro is too big that it exceeds 64 KB, it won't be able to be hosted on the wiki. In this case, use Template:Codeextralink with a link to the raw web address of the code.
For example:
{{Codeextralink|https://gist.githubusercontent.com/mario52a/8d40ab6c018c2bde678f/raw/e16ad9ea7b38c0c47e42aa3019be01dd1267a620/FCInfo_en_Ver_1-20_Docked.FCMacro}}
It will be displayed as:
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/8d40ab6c018c2bde678f/raw/e16ad9ea7b38c0c47e42aa3019be01dd1267a620/FCInfo_en_Ver_1-20_Docked.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/8d40ab6c018c2bde678f/raw/e16ad9ea7b38c0c47e42aa3019be01dd1267a620/FCInfo_en_Ver_1-20_Docked.FCMacro")
This template must be placed at the beginning of the macro page, in the Description section. It must be the first block of code in the page so that the Addon Manager can automatically detect it and import it. See Macro CirclePlus for an example of the usage.
Use Template:MacroLink to include a line in the appropriate category in Macros recipes; create a new category if needed.
* {{MacroLink|Macro_Excellent_Modification|Macro Excellent Modification}}: the macro described in a short sentence.
You can also use the optional parameter Icon= to specify the image file that will be placed at the start of the line. The icon should be an SVG or a PNG file, and should have the same name as your macro. If this parameter is not given it will use the default icon for a Python script .
* {{MacroLink|Icon=Macro_Excellent_Modification.svg|Macro_Excellent_Modification|Macro Excellent Modification}}: the macro described in a short sentence.
To localize this template, use the appropriate language link in the first argument.
* {{MacroLink|Macro_Excellent_Modification/fr|Macro Excellent Modification}}: (translated description)
To make a macro installable from the Addon Manager it should be included in the central FreeCAD-macros repository.
In order to include the macro there, first it must be reviewed by the FreeCAD community in the Python scripting and macros subforum. Once this is done, the FreeCAD-macros repository should be forked, the new macro should be included in a branch, and then the branch should be pushed and merged into the upstream repository.