App FeaturePython: Difference between revisions
(For example, the Draft Text, Draft Dimension, and Working plane proxy elements of the Draft Workbench are App::FeaturePython) |
No edit summary |
||
(34 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
{{TOCright}} |
|||
<translate> |
<translate> |
||
== Introduction == <!--T:1--> |
== Introduction == <!--T:1--> |
||
⚫ | |||
</translate> |
|||
⚫ | |||
[[File:Feature.svg|32px]] |
|||
<translate> |
|||
<!--T: |
<!--T:29--> |
||
This is a simple object that by default doesn't have many properties, for example it doesn't have a [[Placement|placement]] or a [[Part_TopoShape|topological shape]]. Depending on the properties that are assigned to it, it can be used to manage different types of data. |
|||
<!--T:3--> |
<!--T:3--> |
||
[[ |
[[Image:FreeCAD_core_objects.svg|800px]] |
||
<!--T:4--> |
<!--T:4--> |
||
{{Caption|Simplified diagram of the relationships between the core objects in |
{{Caption|Simplified diagram of the relationships between the core objects in FreeCAD}} |
||
== |
== Usage == <!--T:5--> |
||
<!--T:6--> |
<!--T:6--> |
||
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. |
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. |
||
<!--T: |
<!--T:28--> |
||
⚫ | 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]]. |
|||
== Properties == <!--T:8--> |
== Properties == <!--T:8--> |
||
⚫ | |||
⚫ | |||
⚫ | |||
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]]. |
|||
<!--T:11--> |
<!--T:11--> |
||
See [[Property|Property]] for all property types that scripted objects can have. |
See [[Property|Property]] for all property types that scripted objects can have. |
||
⚫ | |||
The [[App_FeaturePython|App FeaturePython]] ({{incode|App::FeaturePython}} class) is derived from the basic [[App_DocumentObject|App DocumentObject]] ({{incode|App::DocumentObject}} class) and inherits all its properties. It also has several additional properties. |
|||
<!--T:12--> |
<!--T:12--> |
||
These are the properties available in the [[ |
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]]. |
||
=== Data === <!--T:13--> |
=== Data === <!--T:13--> |
||
Line 43: | Line 43: | ||
<!--T:14--> |
<!--T:14--> |
||
{{TitleProperty|Base}} |
{{TitleProperty|Base}} |
||
⚫ | |||
⚫ | |||
==== Hidden properties Data ==== <!--T:16--> |
|||
<!--T:17--> |
<!--T:17--> |
||
* {{PropertyData| |
* {{PropertyData|Proxy|PythonObject|Hidden}}: a custom class associated with this object. |
||
* {{PropertyData| |
* {{PropertyData|Label|String}}: the user editable name of this object, it is an arbitrary UTF8 string. |
||
⚫ | |||
⚫ | |||
* {{PropertyData| |
* {{PropertyData|Expression Engine|ExpressionEngine|Hidden}}: a list of expressions. By default, it is empty {{value|[]}}. |
||
* {{PropertyData|Visibility|Bool|Hidden}}: whether to display the object or not. |
|||
=== View === <!--T:18--> |
=== View === <!--T:18--> |
||
<!--T: |
<!--T:22--> |
||
{{TitleProperty|Base}} |
{{TitleProperty|Base}} |
||
⚫ | |||
⚫ | |||
<!--T:20--> |
<!--T:20--> |
||
{{TitleProperty|Display Options}} |
|||
* {{PropertyView| |
* {{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| |
* {{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. |
||
* {{PropertyView|Visibility}}: if it is {{TRUE}}, the object appears in the [[3D view|3D view]]; otherwise it is invisible. By default this property can be toggled on and off by pressing the {{KEY|Space}} bar in the keyboard. |
|||
<!--T:32--> |
|||
{{TitleProperty|Selection}} |
|||
<!--T: |
<!--T:33--> |
||
* {{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|Proxy}}: a class associated with this view provider. By default it is empty. |
|||
⚫ | * {{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. |
||
== Scripting == <!--T:23--> |
== Scripting == <!--T:23--> |
||
<!--T:24--> |
<!--T:24--> |
||
{{Emphasis|See also:}} [[ |
{{Emphasis|See also:}} [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]] and [[Scripted_objects|scripted objects]]. |
||
<!--T:25--> |
<!--T:25--> |
||
See [[Part_Feature|Part Feature]] for the general information on adding objects to the |
See [[Part_Feature|Part Feature]] for the general information on adding objects to the document. |
||
<!--T:26--> |
<!--T:26--> |
||
Line 93: | Line 93: | ||
<translate> |
<translate> |
||
⚫ | For example, the [[Draft_Text|Draft Text]], [[Draft_Dimension|Draft Dimension]], and [[ |
||
⚫ | |||
⚫ | |||
</translate> |
</translate> |
||
{{Document_objects_navi{{#translation:}}}} |
|||
⚫ |
Latest revision as of 07:43, 22 February 2022
Introduction
An App FeaturePython object, or formally an App::FeaturePython
, is a simple instance of the App DocumentObject in Python.
This is a simple object that by default doesn't have many properties, for example it doesn't have a placement or a topological shape. Depending on the properties that are assigned to it, it can be used to manage different types of data.
Simplified diagram of the relationships between the core objects in FreeCAD
Usage
The 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 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.
Properties
See Property for all property types that scripted objects can have.
The App FeaturePython (App::FeaturePython
class) is derived from the basic App DocumentObject (App::DocumentObject
class) and inherits all its properties. It also has several additional properties.
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.
Data
Base
- Data (Hidden)Proxy (
PythonObject
): a custom class associated with this object. - DataLabel (
String
): the user editable name of this object, it is an arbitrary UTF8 string. - Data (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""
. - Data (Hidden)Expression Engine (
ExpressionEngine
): a list of expressions. By default, it is empty[]
. - Data (Hidden)Visibility (
Bool
): whether to display the object or not.
View
Base
- View (Hidden)Proxy (
PythonObject
): a custom viewprovider class associated with this object.
Display Options
- ViewDisplay Mode (
Enumeration
): it is empty by default. - ViewShow In Tree (
Bool
): it defaults totrue
, 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 ViewShow In Tree can be switched back totrue
. - ViewVisibility (
Bool
): it defaults totrue
, 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
- ViewOn 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 toDisabled
, 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. - ViewSelection Style (
Enumeration
): it controls the way the object is highlighted if it has a Shape. If it isShape
, the entire shape (vertices, edges, and faces) will be highlighted in the 3D view; if it isBoundBox
a bounding box will appear surrounding the object and will be highlighted.
Scripting
See also: FreeCAD Scripting Basics and scripted objects.
See Part Feature for the general information on adding objects to the document.
An App FeaturePython is created with the addObject()
method of the document.
import FreeCAD as App
doc = App.newDocument()
obj = App.ActiveDocument.addObject("App::FeaturePython", "Name")
obj.Label = "Custom label"
- Core: App DocumentObject
- Basic: App FeaturePython, App GeoFeature, Part Feature, Mesh Feature, Fem FemMeshObject
- Internal shapes: Part TopoShape, Mesh MeshObject, Fem FemMesh
- Structure: App DocumentObjectGroup (Std Group), App Part (Std Part), App Link (Std LinkMake)
- Derived: Part Part2DObject, Sketcher SketchObject, PartDesign Body, PartDesign Feature
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub