Part Part2DObject/de: Difference between revisions

From FreeCAD Documentation
(Created page with "== Einleitung ==")
 
(Created page with "Ein Part Part2DObject, oder formal ein {{incode|Part::Part2DObject}}, ist ein einfaches Element mit einer topologische Form, das...")
Line 5: Line 5:
[[File:Tree_Part2D.svg|32px]]
[[File:Tree_Part2D.svg|32px]]


A [[Part Part2DObject|Part Part2DObject]], or formally a {{incode|Part::Part2DObject}}, is a simple element with a [[Part_TopoShape|topological shape]] associated that can be displayed in the [[3D view|3D view]].
Ein [[Part Part2DObject/de|Part Part2DObject]], oder formal ein {{incode|Part::Part2DObject}}, ist ein einfaches Element mit einer [[Part_TopoShape/de|topologische Form]], das in der [[3D view/de|3D Ansicht]] angezeigt werden kann.


The {{incode|Part::Part2DObject}} is derived from a [[Part Feature|Part Feature]], but is specialized for 2D geometry, given that its shape will lie on a plane. This plane is defined by its {{PropertyData|Placement}} 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.
The {{incode|Part::Part2DObject}} is derived from a [[Part Feature|Part Feature]], but is specialized for 2D geometry, given that its shape will lie on a plane. This plane is defined by its {{PropertyData|Placement}} 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.

Revision as of 23:11, 17 January 2020

Einleitung

Ein Part Part2DObject, oder formal ein Part::Part2DObject, ist ein einfaches Element mit einer topologische Form, das in der 3D Ansicht angezeigt werden kann.

The 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 DatenPlacement 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.

How to use

The Part Part2DObject is an internal object, so it cannot be created from the graphical interface, only from the Python console as described in the Scripting section.

The 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.

Properties

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

A Part Part2DObject (Part::Part2DObject class) is derived from a Part Feature (Part::Feature class), therefore it shares all the latter's properties.

In addition to the properties described in Part Feature, the Part Part2DObject has the following properties in the property editor.

Data

Attachment

  • DatenMap Mode (Enumeration): Deactivated by 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: Deactivated, Translate origin, Object's XY, Object's XZ, Object's YZ, Plane face, Tangent to surface, Normal to edge, Frenet NB, Frenet TN, Frenet TB, Concentric, Revolution section, Plane by 3 points, Normal to 3 points, Folding, Inertia 2-3, Align O-N-X, Align O-N-Y, Align O-X-Y, Align O-X-N, Align O-Y-N, Align O-Y-X.

See Part Attachment for more information on all mapping modes.

The following two properties are normally hidden. They become visible once DatenMap Mode is something other than Deactivated.

  • DatenMap Reversed (Bool): it defaults to false; if it is true the Z direction will be reversed. For example, a sketch will be flipped upside down.
  • DatenAttachment 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 Base point (vector), and a Rotation (axis and angle). See Placement.

Hidden properties Data

Attachment

  • DatenAttacher Type (String): class name of the attach engine object driving the attachment. It defaults to Attacher::AttachEnginePlane.
  • DatenSupport (LinkSubList): it is the plane or face supporting the 2D geometry. It defaults to an empty list [].
  • DatenMap Path Parameter (Float): sets point of curve to map a sketch to. It goes from 0 to 1, which corresponds to the start and end. It defaults to 0.

View

Grid

  • AnsichtGrid Size (Length): the size of the spacing of the local grid lines in the 3D view; it defaults to 10 mm.
  • AnsichtGrid Snap (Bool): it defaults to false; if true the grid can be used to snap points.
  • AnsichtGrid Style (Enumeration): the style of the grid lines; Dashed (default) or Light.
  • AnsichtShow Grid (Bool): it defaults to false; if true a grid local to the object will be displayed in the 3D view. This grid is independent of the Draft grid.
  • AnsichtTight Grid (Bool): if true (default) the local grid will be localized around the origin of the shape, otherwise it will extend itself more.

Hidden properties View

All other view properties, including hidden properties, are those of the base Part Feature object.

Scripting

See also: FreeCAD Scripting Basics, and scripted objects.

See Part Feature for the general information on adding objects to the program.

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"

This basic Part::Part2DObject doesn't have a Proxy object so it can't be fully used for sub-classing.

Therefore, for Python scripting, the recommendation is to create the Part::Part2DObjectPython object.

import FreeCAD as App

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

For example, most tools from the Draft Workbench, like Draft Line, Draft Rectangle, Draft Polygon, etc., are Part::Part2DObjectPython objects with a custom icon and additional properties.