FreeCAD / FreeCAD-macros

A repository for FreeCAD macros
https://freecad.org/wiki/Macros_recipes
156 stars 139 forks source link
freecad freecad-macro

FreeCAD-macros

A repository of peer-reviewed FreeCAD macros.

This repository hosts FreeCAD macros that volunteers have vetted and added for use to the whole community in general available through the FreeCAD Addon Manager.

How to submit a macro

Guidelines for submitting a macro

Macro description

Please add a complete description how to use the macro near the top of your macro as normal Python comments. Ideally write a Wiki page explaining what your macro does and how to use it by following the instructions on the Wiki. It's a good habit to write a changelog, especially when bringing API breaking changes, from latest to oldest.

CamelCase macro name

Please follow the CamelCase.FCMacro convention for the macro name (other associated files except the macro icon don't need to follow this convention). Please don't start your macro name with Macro or FC or similar (we already know it's a macro for FreeCAD).

Macro name specifics

Also, if possible, start the macro name with the type of object it's working on, e.g. use ViewRotation instead of RotateView, so that all macros related to View will be together when sorting alphabetically.

Macro metadata

Please add the following metadata in your macro after the Macro description (mentioned above).

Macro metadata

    __Name__ = ''
    __Comment__ = ''
    __Author__ = ''
    __Date__ = ''
    __Version__ = ''
    __License__ = ''
    __Web__ = ''
    __Wiki__ = ''
    __Icon__ = ''
    __Xpm__ = ''
    __Help__ = ''
    __Status__ = ''
    __Requires__ = ''
    __Communication__ = ''
    __Files__ = ''

Explanation of metadata

NOTE: All metadata elements are simple strings, and may not contain code to evaluate. The FreeCAD Addon Manager parses these strings by searching for an equals sign followed by something inside quotes (single or double), all on a single line. Lines may not wrap. For example:

# Good, valid
__Comment__ = "When run, this macro reads your mind and creates the thing your are imagining."

# Bad, contains code:
__Author__ = ",".join(author_list)

# Bad, not a single string:
__Comment__ = "Some descriptive text" + " and more text"

# Bad, multiple lines:
__Files__ = "MyFirstFile.FCMacro \
MySecondFile.FCMacro"

# EXCEPTION: __Version__ may be set to __Date__ as long as __Date is defined first
__Date__ = 2022.05.19
__Version__ = __Date__

# EXCEPTION: XPM data must be a triple-quoted multi-line string
__Xpm__ = """
/* XPM */
static char * XFACE[] = {
"48 4 2 1",
"a c #ffffff",
"b c #000000",
"abaabaababaaabaabababaabaabaababaabaaababaabaaab",
"abaabaababaaabaabababaabaabaababaabaaababaabaaab",
"abaabaababaaabaabababaabaabaababaabaaababaabaaab",
"abaabaababaaabaabababaabaabaababaabaaababaabaaab"
};
"""