Part::Part2DObject is derived from a Part Feature, but is specialized for 2D geometry, given that its shape will lie on a plane. This plane is defined by its DataPlacement property (position, normal, and rotation). However, the plane can also be defined by supporting geometrical elements, such as the plane created by three arbitrary vertices, or a face of a solid body.
Simplified diagram of the relationships between the core objects in the program. The
Part::Part2DObject class is specialized for 2D shapes, so it is the base class for planar objects created with the Draft and Sketcher workbenches. It includes an extension that allows it to be attached to faces and planes.
Part::Part2DObject is defined in the Part Workbench but can be used as the base class for scripted objects in all workbenches that produce 2D geometrical shapes. For example, it is the base object for sketches (Sketcher SketchObject), and for most objects created with the Draft Workbench.
Workbenches can add more properties to this basic element to produce an object with complex behavior.
See Property for all property types that scripted objects can have.
In addition to the properties described in Part Feature, the Part Part2DObject has the following properties in the property editor. Hidden properties can be shown by using the Show all command in the context menu of the property editor.
- DataMap Mode (
Deactivatedby default. This property determines a plane which the object will use as reference for 2D geometry. Clicking on the ellipsis (three dots), to the right of the entry field opens the Part Attachment task panel that allows selecting the supporting plane by picking different elements in the 3D view. The different modes are:
Tangent to surface,
Normal to edge,
Plane by 3 points,
Normal to 3 points,
See Part Attachment for more information on all mapping modes.
The following two properties are normally hidden. They become visible once DataMap Mode is something other than
- DataMap Reversed (
Bool): it defaults to ; if it is the Z direction will be reversed. For example, a sketch will be flipped upside down.
- DataAttachment Offset (
Placement): the position of the object in the 3D view, with respect to the attachment object's placement. The placement is defined by a
Basepoint (vector), and a
Rotation(axis and angle). See Placement.
Hidden properties Data
- DataProxy (
PythonObject): a custom class associated with this object. This only exists for the Python version. See Scripting.
- DataAttacher Type (
String): class name of the attach engine object driving the attachment. It defaults to
- DataSupport (
LinkSubList): it is the plane or face supporting the 2D geometry. It defaults to an empty list
- DataMap Path Parameter (
Float): sets point of curve to map a sketch to. It goes from
1, which corresponds to the
end. It defaults to
- ViewGrid Size (
Length): the size of the spacing of the local grid lines in the 3D view; it defaults to
- ViewGrid Snap (
Bool): it defaults to ; if the grid can be used to snap points.
- ViewGrid Style (
Enumeration): the style of the grid lines;
- ViewShow Grid (
Bool): it defaults to ; if a grid local to the object will be displayed in the 3D view. This grid is independent of the Draft Grid.
- ViewTight Grid (
Bool): if (default) the local grid will be localized around the origin of the shape, otherwise it will extend itself more.
Hidden properties View
- ViewProxy (
PythonObject): a custom view provider class associated with this object. This only exists for the Python version. See Scripting.
All other view properties, including hidden properties, are those of the base Part Feature object.
See Part Feature for the general information on adding objects to the document.
A Part2DObject is created with the
addObject() method of the document.
import FreeCAD as App doc = App.newDocument() obj = App.ActiveDocument.addObject("Part::Part2DObject", "Name") obj.Label = "Custom label"
Part::Part2DObject doesn't have a Proxy object so it can't be fully used for sub-classing.
Therefore, for Python subclassing, you should create the
import FreeCAD as App doc = App.newDocument() obj = App.ActiveDocument.addObject("Part::Part2DObjectPython", "Name") obj.Label = "Custom label"