App DocumentObject/ru: Difference between revisions

From FreeCAD Documentation
(Created page with "== Введение ==")
 
(Updating to match new version of source page)
 
(4 intermediate revisions by 2 users not shown)
Line 6: Line 6:
[[File:Px.svg|32px]]
[[File:Px.svg|32px]]


An [[App_DocumentObject|App DocumentObject]] object, or formally an {{incode|App::DocumentObject}}, is the base class of all object classes handled in the document.
Объект [[App_DocumentObject/ru|App DocumentObject]], или формально {{incode|App::DocumentObject}}, это базовый класс всех классов объектов, поддерживаемых в документе.


<div class="mw-translate-fuzzy">
In general terms, a "DocumentObject" is any "thing" that can appear in the [[tree view|tree view]], and which is saved and restored when opening a document.
В общих словах, "DocumentObject" это любая "вещь", которая может появиться в [[tree view/ru|древе проекта]], и которая сохраняется или восстанавливается при открытии документа.
</div>


[[File:App_DocumentObject_example.png]]
[[File:App_DocumentObject_example.png]]
Line 16: Line 18:
[[File:FreeCAD_core_objects.svg|800px]]
[[File:FreeCAD_core_objects.svg|800px]]


{{Caption|Simplified diagram of the relationships between the core objects in the program. The {{incode|App::DocumentObject}} class is the base class of essentially all objects in the software.}}
{{Caption|Simplified diagram of the relationships between the core objects in FreeCAD}}


== Usage ==
== Usage ==


The [[App_DocumentObject|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.
The [[App_DocumentObject|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 program.


Some of the most important DocumentObjects are the following:
Some of the most important DocumentObjects are the following:
* The [[App_FeaturePython|App FeaturePython]] class, an empty object that can be used for different purposes, depending on the added properties.
* The [[App_FeaturePython|App FeaturePython]] class, an empty object that can be used for different purposes, depending on the added properties.
* The [[App_GeoFeature|App GeoFeature]] class, the base object of all geometrical objects, that is, of objects that have a [[Placement|Placement]] property that defines their position in the [[3D view|3D view]].
* The [[App_GeoFeature|App GeoFeature]] class, the base object of all geometrical objects, that is, of objects that have a [[Placement|Placement]] property that defines their position in the [[3D_view|3D view]].
* The [[Part_Feature|Part Feature]] class, derived from App GeoFeature, and the parent class of objects with 2D and 3D [[Part_TopoShape|topological shapes]].
* The [[Part_Feature|Part Feature]] class, derived from App GeoFeature, and the parent class of objects with 2D and 3D [[Part_TopoShape|topological shapes]].
* The [[Mesh_Feature|Mesh Feature]] class, derived from App GeoFeature, and the parent class of objects with 2D and 3D [[Mesh_MeshObject|meshes]].
* The [[Mesh_Feature|Mesh Feature]] class, derived from App GeoFeature, and the parent class of objects with 2D and 3D [[Mesh_MeshObject|meshes]].
Line 34: Line 36:
These are the basic properties that essentially all objects have. These properties can be accessed from the [[Python console|Python console]].
These are the basic properties that essentially all objects have. These properties can be accessed from the [[Python console|Python console]].


* {{PropertyData|Expression Engine|ExpressionEngine}}: a list of expressions.
* {{PropertyData|Label|String}}: the user editable name of this object, it is an arbitrary UTF8 string. By default, it is the same as the {{incode|Name}}.
* {{PropertyData|Label|String}}: the user editable name of this object, it is an arbitrary UTF8 string. By default, it is the same as the {{incode|Name}}.
* {{PropertyData|Label2|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 {{value|""}}.
* {{PropertyData|Label2|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 {{value|""}}.
* {{PropertyData|Expression Engine|ExpressionEngine}}: a list of expressions.
* {{PropertyData|Visibility|Bool}}: whether to display the object or not.
* {{PropertyData|Visibility|Bool}}: whether to display the object or not.


Line 43: Line 45:
== Scripting ==
== Scripting ==


{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]], and [[scripted objects|scripted objects]].
{{Emphasis|See also:}} [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]] and [[Scripted_objects|scripted objects]].


See [[Part_Feature|Part Feature]] for the general information on adding objects to the program.
See [[Part_Feature|Part Feature]] for the general information on adding objects to the document.


A DocumentObject is created with the {{incode|addObject()}} method of the document. However, in general, there is no need to create this object manually. It is usually better to sub-class one of the more complex sub-classes, for example, [[App_FeaturePython|App FeaturePython]], [[App_GeoFeature|App GeoFeature]], [[Part_Feature|Part Feature]], [[Part_Part2DObject|Part Part2DObject]], etc.
A DocumentObject is created with the {{incode|addObject()}} method of the document. However, in general, there is no need to create this object manually. It is usually better to subclass one of the more complex classes, for example, [[App_FeaturePython|App FeaturePython]], [[App_GeoFeature|App GeoFeature]], [[Part_Feature|Part Feature]], [[Part_Part2DObject|Part Part2DObject]], etc.


{{Code|code=
{{Code|code=
Line 58: Line 60:




{{Document objects navi{{#translation:}}}}
{{Document_objects_navi{{#translation:}}}}

{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}

Latest revision as of 07:44, 22 February 2022

Other languages:

Введение

Объект App DocumentObject, или формально App::DocumentObject, это базовый класс всех классов объектов, поддерживаемых в документе.

В общих словах, "DocumentObject" это любая "вещь", которая может появиться в древе проекта, и которая сохраняется или восстанавливается при открытии документа.

Tree view showing different objects in the document. Each of them is a "document object", ultimately derived from the base App::DocumentObject class.

Simplified diagram of the relationships between the core objects in FreeCAD

Usage

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 program.

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.

  • ДанныеLabel (String): the user editable name of this object, it is an arbitrary UTF8 string. By default, it is the same as the Name.
  • ДанныеLabel2 (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 "".
  • ДанныеExpression Engine (ExpressionEngine): a list of expressions.
  • ДанныеVisibility (Bool): whether to display the object or not.

For derived objects, only ДанныеLabel 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 document.

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 subclass one of the more complex classes, for example, App FeaturePython, App GeoFeature, Part Feature, Part Part2DObject, etc.

import FreeCAD as App

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