App DocumentObject

From FreeCAD Documentation
Revision as of 22:55, 17 January 2020 by Maker (talk | contribs) (Created page with "{{Caption|Vereinfachtes Diagramm der Beziehungen zwischen den Kernobjekten im Programm. Die Klasse {{incode|App::DocumentObject}} ist die Basisklasse von im Wesentlichen allen...")

Einleitung

Ein Objekt Anwendung DokumentObjekt oder formal ein App::DocumentObject ist die Basisklasse aller im Dokument behandelten Objektklassen.

Im Allgemeinen ist ein "Dokumentobjekt" jedes "Ding", das in der Baumansicht erscheinen kann und das beim Öffnen eines Dokuments gespeichert und wiederhergestellt wird.

Baumansicht mit verschiedenen Objekten im Dokument. Jedes von ihnen wird letztlich abgeleitet aus der App::DocumentObject Klasse.

Vereinfachtes Diagramm der Beziehungen zwischen den Kernobjekten im Programm. Die Klasse App::DocumentObject ist die Basisklasse von im Wesentlichen allen Objekten in der Software.

How to use

The App DocumentObject is an internal class, so it cannot be created from the graphical interface, nor is it meant to be used by itself. It just defines the basic behavior and properties of objects in the software.

Some of the most important DocumentObjects are the following:

  • The App FeaturePython class, an empty object that can be used for different purposes, depending on the added properties.
  • The App GeoFeature class, the base object of all geometrical objects, that is, of objects that have a Placement property that defines their position in the 3D view.
  • The Part Feature class, derived from App GeoFeature, and the parent class of objects with 2D and 3D topological shapes.
  • The Mesh Feature class, derived from App GeoFeature, and the parent class of objects with 2D and 3D meshes.

Properties

See Property for all property types that scripted objects can have.

These are the basic properties that essentially all objects have. These properties can be accessed from the Python console.

  • DatenExpression Engine (ExpressionEngine): a list of expressions.
  • DatenLabel (String): the user editable name of this object, it is an arbitrary UTF8 string. By default, it is the same as the Name.
  • DatenLabel2 (String): a longer, user editable description of this object, it is an arbitrary UTF8 string that may include newlines. By default, it is an empty string "".
  • DatenVisibility (Bool): whether to display the object or not.

For derived objects, only DatenLabel will be listed in the property editor by default. The other properties will be hidden.

Scripting

See also: FreeCAD Scripting Basics, and scripted objects.

See Part Feature for the general information on adding objects to the program.

A DocumentObject is created with the addObject() method of the document. However, in general, there is no need to create this object manually. It is usually better to create one of the sub-classes, for example, App FeaturePython, Part Feature, or Part Part2DObject.

import FreeCAD as App

doc = App.newDocument()
obj = App.ActiveDocument.addObject("App::DocumentObject", "Name")
obj.Label = "Custom label"