Skip to content

Instantly share code, notes, and snippets.

@luzpaz
Last active December 29, 2020 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luzpaz/72b3310ecc2f6299073e57d1b7efd1c1 to your computer and use it in GitHub Desktop.
Save luzpaz/72b3310ecc2f6299073e57d1b7efd1c1 to your computer and use it in GitHub Desktop.
FreeCAD API notes

src/Gui/CommandT.h shows doxygen examples of for both cplusplus and python:
https://github.com/luzpaz/FreeCAD/blob/f2d17774e8c9154f80b98f797e3561ee2ad36061/src/Gui/CommandT.h#L59-L78

How to list parameters in the user.cfg (courtesy of openBrain)

#!/usr/bin/python

def printValues(group, level):
    for value in FreeCAD.ParamGet(group).GetContents():
        print("  "*(level+1)+" - Key / Name = "+value[1]+" / Type = "+value[0]+" / Value = "+str(value[2])) 

def printGroup(group, level):
    print("  "*level+" - Group / "+group)
    if FreeCAD.ParamGet(group).GetContents() != None and len(FreeCAD.ParamGet(group).GetContents()) > 0:
        printValues(group, level)
    if len(FreeCAD.ParamGet(group).GetGroups()) > 0:
        for subgroup in FreeCAD.ParamGet(group).GetGroups():
            printGroup(group+"/"+subgroup, level+1)

printGroup("User parameter:BaseApp",1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment