Builtin modules: Difference between revisions

From FreeCAD Documentation
No edit summary
 
No edit summary
Line 1: Line 1:
This page presents more in-depth information over the built-in FreeCAD modules, and what are the functions and properties availible to you. This page is not a complete list of all the contents of these modules, and, because of the fast evolution of FreeCAD, the information presented here might be slightly outdated, but it should give you a good overview of the possibilities. For complete list of the modules content, use the dir(module) function in the interpreter.
== The App module ==


== The FreeCAD module ==
The App module is also called the FreeCAD module. If you import it in an external script, you must call it by its FreeCAD name. The App name is only availible from the interpreter.


This is the principal (root) module of FreeCAD. It can also be called by "App" from the FreeCAD interpreter. It contains everything that is needed to manipulate documents and their contents (objects).
The functions in the FreeCAD module allow working with documents. The FreeCAD instance provides a list of references of documents which can be addressed by a string. Hence the document name must be unique. The document has the read-only attribute FileName which points to the file the document should be stored to.

The list below is an overview of the principal tools and functions availible to you. Be aware that FreeCAD evolves at a quite fast pace, and in new versions you might have much more functionality availible.
=== Main Functions ===
=== Main Functions ===

These are the functions and attributes availible to you directly from the FreeCAD module.
* ConfigDump() -- Dump the configuration to the output.
* ConfigGet([string]) -- Get the value for the given key. If no key is given the complete configuration is dumped to the output.
* '''ConfigDump()''' - Prints a dictionnnary containing all the FreeCAD configuration environment.
* ConfigSet(string, string) -- Set the given key to the given value.
* '''ConfigGet([string])''' - Returns the value of the given key. If no key is given, the complete configuration is returned
* Version() -- Print the version to the output.
* '''ConfigSet(string, string)''' - Set the given key (first string) to the given value (second string).
* activeDocument() -- Return the active document or None if there is no active document.
* '''Version()''' - Prints the FreeCAD version.
* addExportType("File type (*.ext)","script") -- Registers a filetype for export. The "script" string is the name of a python containing an export() function
* '''activeDocument()''' - Return the active document or None if there is no active document.
* addImportType("File type (*.ext)","script") -- Registers a filetype for import. The "script" string is the name of a python containing an import() or an open() function, or both.
* '''addExportType(string,string)''' - 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.
* closeDocument(string) -- Closes the given document
* '''addImportType(string,string)''' - Adds a new import file type to FreeCAD, works the same way as addExportType.
* getDocument(string) -- returns a document or raise an exception if there is no document with the given name.
* '''closeDocument(string)''' - Closes the given document
* getExportType("ext") -- Get the name of the module that can export the filetype
* '''getDocument(string)''' - Returns a document or raise an exception if there is no document with the given name.
* getImportType("ext) -- Get the name of the module that can import the filetype
* '''getExportType(string)''' - Returns the name of the module that can export the specified filetype.
* listDocuments() -- Return a list of names of all documents.
* '''getImportType(string)''' - Returns the name of the module that can import the specified filetype.
* newDocument([string]) -- Create 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". The created document object is returned.
* '''listDocuments()''' - Returns a list of names of all documents.
* open(string) -- See openDocument(string)
* '''newDocument([string])''' - 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".
* openDocument(string) -- Create a document and load the 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 document is kept alive. The created document object is returned.
* '''open(string)''' - See openDocument(string)
* setActiveDocement(string) -- Set the active document by its name.
* '''openDocument(string)''' - 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.
* '''setActiveDocement(string)''' - Set the active document by its name.


=== Base sub-module ===
=== Base sub-module ===

The Base module is contained inside the FreeCAD module and contains constructors for different types of objects heavily used in FreeCAD.

* '''BoundBox([Xmin,Ymin,Zmin,Xmax,Ymax,Zmax])''', or '''BoundBox(Tuple, Tuple)''', or '''BoundBox(Vector, Vector)''' - returns a bounding box. A bounding box is an orthographic cube which is a way to describe outer boundaries. You get a bounding box from a lot of 3D types. It is often used to check if a 3D entity lies in the range of another object. Checking for boundig interference first can save a lot of computing time!
* '''Matrix()''' - returns a 4x4 matrix, that can be used to apply transformations to objects
* '''Vector(x,y,z)''' - returns a FreeCAD 3D vector, representing a 3D point or a direction

=== Console sub-module ===
=== Console sub-module ===

* GetStatus(...) - Get the status for either Log, Msg, Wrn or Error for an observer
* PrintError(string) - Print an error message to the output
* PrintLog(string) - Print a log message to the output
* PrintMessage(string) - Print a message to the output
* PrintWarning(string) -- Print a warning to the output
* SetStatus(...) - Set the stats for either Log, Msg, Wrn or Error for an observer

== The FreeCADGui Module ==

=== Main functions ===

* activateWorkbench(string) - Activate the workbench by name
* activeDocument() - Return the active document or None if no one exists
* activeWorkbench() - Return the active workbench object
* addCommand(string, object) - Add a command
* addIcon(string, string or list) - Add an icon as file name or in XPM format to the system
* addIconPath(string) - Add a new path to the system where to find icon files
* addPreferencePage(string,string) - Add a UI form to the preferences dialog. The first argument specifies the file nameand the second specifies the group name
* addWorkbench(string, object) - Add a workbench under a defined name.
* createDialog(string) - Open a UI file
* getDocument(string) - Get a document by its name
* getWorkbench(string) - Get the workbench by its name
* insert(...) - Open a macro, Inventor or VRML file
* listWorkbenches() - Show a list of all workbenches
* open(...) - Open a macro, Inventor or VRML file
* removeWorkbench(string) - Remove the workbench with name
* runCommand(string) - Run command with name
* updateGui() - Update the main window and all its windows

=== Selection sub-module ===

* addSelection(object) - Add an object to the selection
* clearSelection([string]) - Clear the selection to the given document name. If no document is given the complete selection is cleared.
* getSelection([string]) - Return a list of selected objects for a given document name. If no document is given the complete selection is returned.
* isSelected(object) - Check if a given object is selected
* removeSelection(object) - Remove an object from the selection

== Objects ==

* Axis
* Content
* Label
* Location
* Name
* Placement
* Pos
* PropertiesList
* Shape
* State
* Type
* ViewObject
* getAllDerivedFrom
* getDocumentationOfProperty
* getGroupOfProperty
* getPropertyByName
* getTypeOfProperty
* isDerivedFrom
* touch

== View Objects ==

* Annotation
* BoundingBox
* Content
* ControlPoints
* DisplayMode
* LineColor
* LineMaterial
* LineWidth
* Objectt
* PointColor
* PointMaterial
* PointSize
* PropertiesList
* RootNode
* ShapeColor
* ShapeMaterial
* Transparency
* Type
* Visibility
* getAllDerivedFrom
* getDocumentationOfProperty
* getGroupOfProperty
* getPropertyByName
* getTypeOfProperty
* hide
* isDerivedFrom
* isVisible
* listDisplayModes
* show
* toString
* update

Revision as of 20:23, 3 November 2008

This page presents more in-depth information over the built-in FreeCAD modules, and what are the functions and properties availible to you. This page is not a complete list of all the contents of these modules, and, because of the fast evolution of FreeCAD, the information presented here might be slightly outdated, but it should give you a good overview of the possibilities. For complete list of the modules content, use the dir(module) function in the interpreter.

The FreeCAD module

This is the principal (root) module of FreeCAD. It can also be called by "App" from the FreeCAD interpreter. It contains everything that is needed to manipulate documents and their contents (objects).

Main Functions

These are the functions and attributes availible to you directly from the FreeCAD module.

  • ConfigDump() - Prints a dictionnnary containing all the FreeCAD configuration environment.
  • ConfigGet([string]) - Returns the value of the given key. If no key is given, the complete configuration is returned
  • ConfigSet(string, string) - Set the given key (first string) to the given value (second string).
  • Version() - Prints the FreeCAD version.
  • activeDocument() - Return the active document or None if there is no active document.
  • addExportType(string,string) - 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.
  • addImportType(string,string) - Adds a new import file type to FreeCAD, works the same way as addExportType.
  • closeDocument(string) - Closes the given document
  • getDocument(string) - Returns a document or raise an exception if there is no document with the given name.
  • getExportType(string) - Returns the name of the module that can export the specified filetype.
  • getImportType(string) - Returns the name of the module that can import the specified filetype.
  • listDocuments() - Returns a list of names of all documents.
  • newDocument([string]) - 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".
  • open(string) - See openDocument(string)
  • openDocument(string) - 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.
  • setActiveDocement(string) - Set the active document by its name.

Base sub-module

The Base module is contained inside the FreeCAD module and contains constructors for different types of objects heavily used in FreeCAD.

  • BoundBox([Xmin,Ymin,Zmin,Xmax,Ymax,Zmax]), or BoundBox(Tuple, Tuple), or BoundBox(Vector, Vector) - returns a bounding box. A bounding box is an orthographic cube which is a way to describe outer boundaries. You get a bounding box from a lot of 3D types. It is often used to check if a 3D entity lies in the range of another object. Checking for boundig interference first can save a lot of computing time!
  • Matrix() - returns a 4x4 matrix, that can be used to apply transformations to objects
  • Vector(x,y,z) - returns a FreeCAD 3D vector, representing a 3D point or a direction

Console sub-module

  • GetStatus(...) - Get the status for either Log, Msg, Wrn or Error for an observer
  • PrintError(string) - Print an error message to the output
  • PrintLog(string) - Print a log message to the output
  • PrintMessage(string) - Print a message to the output
  • PrintWarning(string) -- Print a warning to the output
  • SetStatus(...) - Set the stats for either Log, Msg, Wrn or Error for an observer

The FreeCADGui Module

Main functions

  • activateWorkbench(string) - Activate the workbench by name
  • activeDocument() - Return the active document or None if no one exists
  • activeWorkbench() - Return the active workbench object
  • addCommand(string, object) - Add a command
  • addIcon(string, string or list) - Add an icon as file name or in XPM format to the system
  • addIconPath(string) - Add a new path to the system where to find icon files
  • addPreferencePage(string,string) - Add a UI form to the preferences dialog. The first argument specifies the file nameand the second specifies the group name
  • addWorkbench(string, object) - Add a workbench under a defined name.
  • createDialog(string) - Open a UI file
  • getDocument(string) - Get a document by its name
  • getWorkbench(string) - Get the workbench by its name
  • insert(...) - Open a macro, Inventor or VRML file
  • listWorkbenches() - Show a list of all workbenches
  • open(...) - Open a macro, Inventor or VRML file
  • removeWorkbench(string) - Remove the workbench with name
  • runCommand(string) - Run command with name
  • updateGui() - Update the main window and all its windows

Selection sub-module

  • addSelection(object) - Add an object to the selection
  • clearSelection([string]) - Clear the selection to the given document name. If no document is given the complete selection is cleared.
  • getSelection([string]) - Return a list of selected objects for a given document name. If no document is given the complete selection is returned.
  • isSelected(object) - Check if a given object is selected
  • removeSelection(object) - Remove an object from the selection

Objects

  • Axis
  • Content
  • Label
  • Location
  • Name
  • Placement
  • Pos
  • PropertiesList
  • Shape
  • State
  • Type
  • ViewObject
  • getAllDerivedFrom
  • getDocumentationOfProperty
  • getGroupOfProperty
  • getPropertyByName
  • getTypeOfProperty
  • isDerivedFrom
  • touch

View Objects

  • Annotation
  • BoundingBox
  • Content
  • ControlPoints
  • DisplayMode
  • LineColor
  • LineMaterial
  • LineWidth
  • Objectt
  • PointColor
  • PointMaterial
  • PointSize
  • PropertiesList
  • RootNode
  • ShapeColor
  • ShapeMaterial
  • Transparency
  • Type
  • Visibility
  • getAllDerivedFrom
  • getDocumentationOfProperty
  • getGroupOfProperty
  • getPropertyByName
  • getTypeOfProperty
  • hide
  • isDerivedFrom
  • isVisible
  • listDisplayModes
  • show
  • toString
  • update