App FeaturePython

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

View

Base

Display Options

Selection

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"