import FreeCADGui def showMessage(): FreeCADGui.MessageBox("Hello World!") FreeCADGui.addCommand('myCommand', showMessage)
import FreeCAD, FreeCADGui def newDocument(): docName = "My New Document" doc = FreeCAD.newDocument(docName) FreeCADGui.activateWorkbench("DefaultWorkbench") FreeCADGui.addCommand('newDocument', newDocument)This example uses both the FreeCAD and FreeCADGui libraries. The newDocument function creates a new document with the specified name and activates the DefaultWorkbench interface. The addCommand method is used to register the newDocument function as a new command named 'newDocument'.