App FeaturePython/ru: Difference between revisions

From FreeCAD Documentation
(Created page with "== Составление скриптов ==")
(Updating to match new version of source page)
 
(21 intermediate revisions by one other user not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{TOCright}}


== Введение ==
== Введение ==


<div class="mw-translate-fuzzy">
An [[Image:Feature.svg|32px]] [[App FeaturePython|App FeaturePython]] object, or formally an {{incode|App::FeaturePython}}, is a simple instance of the [[App_DocumentObject|App DocumentObject]] in [[Python|Python]].
Объект [[Image:Feature.svg|32px]] [[App FeaturePython/ru|App FeaturePython]], или формально {{incode|Приложение::FeaturePython}}, является простым экземпляром [[App_DocumentObject/ru|App DocumentObject]] в [[Python/ru|Python]].
</div>


<div class="mw-translate-fuzzy">
This is a simple object that by default doesn't have many properties, for example, no [[Placement|placement]] nor [[Part_TopoShape|topological shape]]. This object is for general purpose use; depending on the properties that are assigned to it, it can be used to manage different types of data.
Это простой объект, который по умолчанию не имеет многих свойств, например таких как [[Placement/ru|разположение]] и [[Part_TopoShape/ru|топологическая форма]]. Этот объект предназначен для общего использования; в зависимости от назначенных ему свойств его можно использовать для управления различными типами данных.
</div>


[[Image:FreeCAD_core_objects.svg|800px]]
[[Image:FreeCAD_core_objects.svg|800px]]


<div class="mw-translate-fuzzy">
{{Caption|Simplified diagram of the relationships between the core objects in the program. The {{incode|App::FeaturePython}} class is a simple implementation of the {{incode|App::DocumentObject}} that can be used for any purpose, as it doesn't have a [[Part_TopoShape|TopoShape]] by default.}}
{{Caption|Упрощенная схема взаимосвязей между основными объектами в программе. Класс {{incode|App::FeaturePython}} является простой реализацией {{incode|App::DocumentObject}}, который можно использовать для любых целей, так как по умолчанию в нем нет [[Part_TopoShape/ru|TopoShape]].}}
</div>


== Применение ==
== Применение ==


[[App_FeaturePython/ru|App FeaturePython]] является внутренним объектом, поэтому его нельзя создать с помощью графического интерфейса. Он предназначен для подклассов классов, которые будут обрабатывать различные типы данных.
The [[App_FeaturePython|App FeaturePython]] is an internal object, so it cannot be created from the graphical interface. It is meant to be sub-classed by classes that will handle different types of data.


For example, the [[Draft_Text|Draft Text]], [[Draft_Dimension|Draft Dimension]], and [[Draft_WorkingPlaneProxy|Draft WorkingPlaneProxy]] objects of the [[Draft_Workbench|Draft Workbench]] are {{incode|App::FeaturePython}} objects with a custom icon and additional properties. They hold data but not an actual [[Part_TopoShape|Part TopoShape]].
See [[App_FeaturePython#Scripting|Scripting]] for more information.

If the desired object should have a placement, a shape, an attachment or other complex properties, it is better to create one of the more complex classes, for example, [[App_GeoFeature|App GeoFeature]], [[Part_Feature|Part Feature]], or [[Part_Part2DObject|Part Part2DObject]].


== Свойства ==
== Свойства ==


See [[Property|Property]] for all property types that scripted objects can have.
An [[App_FeaturePython|App FeaturePython]] ({{incode|App::FeaturePython}} class) is derived from the basic [[App_DocumentObject|App DocumentObject]] ({{incode|App::DocumentObject}} class), therefore it shares all the latter's properties.


<div class="mw-translate-fuzzy">
In addition to the properties described in [[App_DocumentObject|App DocumentObject]], the FeaturePython has a basic view provider, so it does appear in the [[tree view|tree view]].
[[App_FeaturePython/ru|App FeaturePython]] ({{incode|App::FeaturePython}} класс) является производным от базового [[App_DocumentObject/ru|App DocumentObject]] ({{incode|App::DocumentObject}} класса), поэтому он разделяет все свойства последнего.
</div>


These are the properties available in the [[Property_editor|property editor]]. Hidden properties can be shown by using the {{MenuCommand|Show all}} command in the context menu of the [[Property_editor|property editor]].
See [[Property|Property]] for all property types that scripted objects can have.


=== Свойства объекта ===
These are the properties available in the [[property editor|property editor]]. Hidden properties can be shown by using the {{MenuCommand|Show all}} command in the context menu of the [[property editor|property editor]].


{{TitleProperty|Основные}}
=== Данные ===

{{TitleProperty|Base}}


* {{PropertyData|Proxy|PythonObject|Hidden}}: a custom class associated with this object.
* {{PropertyData|Proxy|PythonObject|Hidden}}: a custom class associated with this object.
Line 37: Line 46:
* {{PropertyData|Visibility|Bool|Hidden}}: whether to display the object or not.
* {{PropertyData|Visibility|Bool|Hidden}}: whether to display the object or not.


=== Свойства отображения ===
=== View ===


{{TitleProperty|Основные}}
These properties correspond to the basic properties of the base [[viewprovider|viewprovider]], {{incode|Gui::ViewProviderDocumentObject}}, that is inherited by all viewproviders in the software.


* {{PropertyView|Proxy|PythonObject|Hidden}}: a custom [[Viewprovider|viewprovider]] class associated with this object.
{{TitleProperty|Base}}

* {{PropertyView|Proxy|PythonObject|Hidden}}: a custom view provider class associated with this object. This property only exist for those classes that are able to assign a custom class.


{{TitleProperty|Display Options}}
{{TitleProperty|Display Options}}
* {{PropertyView|Display Mode|Enumeration}}: it is empty by default.
* {{PropertyView|Display Mode|Enumeration}}: it is empty by default.
* {{PropertyView|Show In Tree|Bool}}: it defaults to {{TRUE}}, in which case the object will appear in the [[tree view|tree view]]; otherwise, the object will be hidden in the tree view. Once an object in the tree is invisible, you can see it again by opening the context menu over the name of the document (right-click), and selecting {{CheckBox|TRUE|Show hidden items}}. Then the hidden item can be chosen and {{PropertyView|Show In Tree}} can be switched back to {{TRUE}}.
* {{PropertyView|Show In Tree|Bool}}: it defaults to {{TRUE}}, in which case the object will appear in the [[Tree_view|Tree view]]; otherwise, the object will be hidden in the tree view. Once an object in the tree is invisible, you can see it again by opening the context menu over the name of the document (right-click), and selecting {{CheckBox|TRUE|Show hidden items}}. Then the hidden item can be chosen and {{PropertyView|Show In Tree}} can be switched back to {{TRUE}}.
* {{PropertyView|Visibility|Bool}}: it defaults to {{TRUE}}, in which case the object will be visible in the [[3D_view|3D view]] if it has a [[Part_TopoShape|Shape]], otherwise it will be invisible. By default this property can be toggled on and off by selecting the object, and pressing the {{KEY|Space}} bar in the keyboard.
* {{PropertyView|Visibility|Bool}}: it defaults to {{TRUE}}, in which case the object will be visible in the [[3D_view|3D view]] if it has a [[Part_TopoShape|Shape]], otherwise it will be invisible. By default this property can be toggled on and off by selecting the object, and pressing the {{KEY|Space}} bar.


{{TitleProperty|Selection}}
{{TitleProperty|Selection}}


* {{PropertyView|On Top When Selected|Enumeration}}: it controls the way in which the selection occurs in the [[3D_view|3D view]] if the object has a [[Part_TopoShape|Shape]], and there are many objects partially covered by others. It defaults to {{value|Disabled}}, meaning that no special highlighting will occur; {{value|Enabled}} means that the object will appear on top of any other object when selected; {{value|Object}} means that the object will appear on top only if the entire object is selected in the [[tree_view|tree view]]; {{value|Element}} means that the object will appear on top only if a subelement (vertex, edge, face) is selected in the [[3D_view|3D view]].
* {{PropertyView|On Top When Selected|Enumeration}}: it controls the way in which the selection occurs in the [[3D_view|3D view]] if the object has a [[Part_TopoShape|Shape]], and there are many objects partially covered by others. It defaults to {{value|Disabled}}, meaning that no special highlighting will occur; {{value|Enabled}} means that the object will appear on top of any other object when selected; {{value|Object}} means that the object will appear on top only if the entire object is selected in the [[Tree_view|Tree view]]; {{value|Element}} means that the object will appear on top only if a subelement (vertex, edge, face) is selected in the [[3D_view|3D view]].
* {{PropertyView|Selection Style|Enumeration}}: it controls the way the object is highlighted if it has a [[Part_TopoShape|Shape]]. If it is {{value|Shape}}, the entire shape (vertices, edges, and faces) will be highlighted in the [[3D view|3D view]]; if it is {{value|BoundBox}} a bounding box will appear surrounding the object and will be highlighted.
* {{PropertyView|Selection Style|Enumeration}}: it controls the way the object is highlighted if it has a [[Part_TopoShape|Shape]]. If it is {{value|Shape}}, the entire shape (vertices, edges, and faces) will be highlighted in the [[3D_view|3D view]]; if it is {{value|BoundBox}} a bounding box will appear surrounding the object and will be highlighted.


== Составление скриптов ==
== Составление скриптов ==


<div class="mw-translate-fuzzy">
{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]], and [[scripted objects|scripted objects]].
{{Emphasis|Смотрите так же:}} [[FreeCAD Scripting Basics/ru|Основы составления скриптов в FreeCAD]], и [[scripted objects/ru|скриптовые объекты]].
</div>


<div class="mw-translate-fuzzy">
See [[Part_Feature|Part Feature]] for the general information on adding objects to the program.
Общие сведения о добавлении объектов в программу смотрите в разделе [[Part_Feature/ru|Объект "Part::Feature"]].
</div>


An App FeaturePython is created with the {{incode|addObject()}} method of the document.
App FeaturePython создается с помощью метода {{incode|AddObject()}} документа.


{{Code|code=
{{Code|code=
Line 71: Line 82:
}}
}}


For example, the [[Draft_Text|Draft Text]], [[Draft_Dimension|Draft Dimension]], and [[Draft_WorkingPlaneProxy|Working plane proxy]] elements of the [[Draft_Workbench|Draft Workbench]] are {{incode|App::FeaturePython}} objects with a custom icon and additional properties. They hold data but not an actual [[Part_TopoShape|Part TopoShape]].

If the desired object should have a placement, a shape, an attachment, or other complex properties, it is better to create one of the more complex classes, for example, [[App_GeoFeature|App GeoFeature]], [[Part_Feature|Part Feature]], or [[Part_Part2DObject|Part Part2DObject]].


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

Latest revision as of 06:23, 22 February 2022

Other languages:

Введение

Объект App FeaturePython, или формально Приложение::FeaturePython, является простым экземпляром App DocumentObject в Python.

Это простой объект, который по умолчанию не имеет многих свойств, например таких как разположение и топологическая форма. Этот объект предназначен для общего использования; в зависимости от назначенных ему свойств его можно использовать для управления различными типами данных.

Упрощенная схема взаимосвязей между основными объектами в программе. Класс App::FeaturePython является простой реализацией App::DocumentObject, который можно использовать для любых целей, так как по умолчанию в нем нет TopoShape.

Применение

App FeaturePython является внутренним объектом, поэтому его нельзя создать с помощью графического интерфейса. Он предназначен для подклассов классов, которые будут обрабатывать различные типы данных.

For example, the Draft Text, Draft Dimension, and Draft WorkingPlaneProxy objects of the Draft Workbench are App::FeaturePython objects with a custom icon and additional properties. They hold data but not an actual Part TopoShape.

If the desired object should have a placement, a shape, an attachment or other complex properties, it is better to create one of the more complex classes, for example, App GeoFeature, Part Feature, or Part Part2DObject.

Свойства

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

App FeaturePython (App::FeaturePython класс) является производным от базового App DocumentObject (App::DocumentObject класса), поэтому он разделяет все свойства последнего.

These are the properties available in the property editor. Hidden properties can be shown by using the Show all command in the context menu of the property editor.

Свойства объекта

Основные

  • Данные (Hidden)Proxy (PythonObject): a custom class associated with this object.
  • ДанныеLabel (String): the user editable name of this object, it is an arbitrary UTF8 string.
  • Данные (Hidden)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 "".
  • Данные (Hidden)Expression Engine (ExpressionEngine): a list of expressions. By default, it is empty [].
  • Данные (Hidden)Visibility (Bool): whether to display the object or not.

Свойства отображения

Основные

  • Вид (Hidden)Proxy (PythonObject): a custom viewprovider class associated with this object.

Display Options

  • ВидDisplay Mode (Enumeration): it is empty by default.
  • ВидShow In Tree (Bool): it defaults to true, in which case the object will appear in the Tree view; otherwise, the object will be hidden in the tree view. Once an object in the tree is invisible, you can see it again by opening the context menu over the name of the document (right-click), and selecting Show hidden items. Then the hidden item can be chosen and ВидShow In Tree can be switched back to true.
  • ВидVisibility (Bool): it defaults to true, in which case the object will be visible in the 3D view if it has a Shape, otherwise it will be invisible. By default this property can be toggled on and off by selecting the object, and pressing the Space bar.

Selection

  • ВидOn Top When Selected (Enumeration): it controls the way in which the selection occurs in the 3D view if the object has a Shape, and there are many objects partially covered by others. It defaults to Disabled, meaning that no special highlighting will occur; Enabled means that the object will appear on top of any other object when selected; Object means that the object will appear on top only if the entire object is selected in the Tree view; Element means that the object will appear on top only if a subelement (vertex, edge, face) is selected in the 3D view.
  • ВидSelection Style (Enumeration): it controls the way the object is highlighted if it has a Shape. If it is Shape, the entire shape (vertices, edges, and faces) will be highlighted in the 3D view; if it is BoundBox a bounding box will appear surrounding the object and will be highlighted.

Составление скриптов

Общие сведения о добавлении объектов в программу смотрите в разделе Объект "Part::Feature".

App FeaturePython создается с помощью метода AddObject() документа.

import FreeCAD as App

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