FreeCAD Programmierschnittstelle

From FreeCAD Documentation
Jump to navigation Jump to search
This page is a translated version of the page FreeCAD API and the translation is 80% complete.
Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎română • ‎日本語
(October 2019) Diese Seite nicht bearbeiten. Die Informationen sind unvollständig und veraltet. Die neueste API findest du in der autogenerated API documentation, oder du generierst die Dokumentation selbst, siehe Quelldokumentation.


Dies ist das Hauptmodul (root) von FreeCAD. Es kann auch mit "App" aus dem FreeCAD Interpreter aufgerufen werden. Es enthält alles, was zur Manipulation von Dokumenten und deren Inhalt (Objekte) benötigt wird.

Beispiel:

import FreeCAD
print FreeCAD.listDocuments()
mydoc = FreeCAD.activeDocument()
Method.png ConfigDump( )

Description: Prints a dictionary containing all the FreeCAD configuration environment.

Returns:

Method.png ConfigGet([string])

Description: Returns the value of the given key. If no key is given, the complete configuration is returned

Returns: A string.

Method.png ConfigSet(string, string)

Description: Set the given key (first string) to the given value (second string).

Returns:

Method.png Version( )

Description: Prints the FreeCAD version.

Returns:

Method.png activeDocument( )

Description: Return the active document or None if there is no active document.

Returns: A FreeCAD Document.

Method.png addExportType(string, string)

Description: Adds a new export file type to FreeCAD. The first string must be formatted like this example: "Word Document (*.doc)". The second string is the name of a python script/module containing an export() function.

Returns:

Method.png addImportType(string, string)

Description: Adds a new import file type to FreeCAD, works the same way as addExportType, the handling python module must contain an open() and/or an import() function.

Returns:

Method.png closeDocument(Document name)

Description: Closes the given document

Returns:

Method.png getDocument(Document name)

Description: Returns a document or raise an exception if there is no document with the given name.

Returns:

Method.png getExportType(string)

Description: Returns the name of the module that can export the specified filetype.

Returns: A string.

Method.png getImportType(string)

Description: Returns the name of the module that can import the specified filetype.

Returns: A string.

Method.png listDocuments( )

Description: Returns a dictionary of names and object pointers of all documents.

Returns: A dictionary of names and object pointers.

Method.png newDocument([string])

Description: Creates and returns a new document with a given name. The document name must be unique, which is checked automatically. If no name is supplied, the document will be named "Untitled".

Returns: The newly created document.

Method.png open(string)

Description: See openDocument

Returns:

Method.png openDocument(filepath)

Description: Creates and returns a document and load a project file into the document. The string argument must point to an existing file. If the file doesn't exist or the file cannot be loaded an I/O exception is thrown. In this case the created document is kept, but will be empty.

Returns: The opened FreeCAD Document.

Method.png setActiveDocument(Document name)

Description: Set the active document by its name.

Returns: