import FreeCADGui docName = FreeCADGui.activeDocument().Name print(docName)
import FreeCAD import FreeCADGui doc = FreeCAD.newDocument() FreeCADGui.activateDocument(doc.Name)
import FreeCAD import Part import FreeCADGui doc = FreeCAD.newDocument() box = doc.addObject("Part::Box", "MyBox") box.Length = 10.0 box.Width = 20.0 box.Height = 30.0 FreeCADGui.SendMsgToActiveView("ViewFit")In this example, a new document object is created, and a box object is added to it using the doc.addObject() method. The dimensions of the box object are then set, and the FreeCADGui.SendMsgToActiveView() method is used to fit the view to the box object. Package library: FreeCAD, Part, FreeCADGui