Part::Part2DObject is derived from the 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 FreeCAD
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.
- Data (Hidden)Attacher 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 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 starts the Part EditAttachment command 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,
- DataMap Reversed (
Bool): it defaults to
false; if it is
truethe Z direction will be reversed. For example, a sketch will be flipped upside down. Hidden if DataMap Mode is
- Data (Hidden)Map Path Parameter (
Float): sets point of curve to map a sketch to. It goes from
1, which corresponds to the
end. It defaults to
- 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 if DataMap Mode is
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"
For Python subclassing you should create a
import FreeCAD as App doc = App.newDocument() obj = App.ActiveDocument.addObject("Part::Part2DObjectPython", "Name") obj.Label = "Custom label"