Part Part2DObject

From FreeCAD Documentation
Revision as of 15:53, 1 December 2019 by Renatorivo (talk | contribs) (Created page with "Un Part Part2DObject, o formalmente un {{incode|Part::Part2DObject}}, è un elemento semplice a cui è associato un {{incode|Shape}} topologico che pu...")

Introduzione

Un Part Part2DObject, o formalmente un Part::Part2DObject, è un elemento semplice a cui è associato un Shape topologico che può essere visualizzato nella Vista 3D.

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

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.

Proprietà

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.

Dati

Attachment

  • DatiMap Mode: "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.

Vista

Grid

  • VistaGrid Size: a float that determines the size of the spacing of the local grid lines in the 3D view.
  • VistaGrid Snap: if true the grid can be used to snap points.
  • VistaGrid Style: Dashed or Light; the style of the grid lines.
  • VistaShow Grid: if true a grid local to the object will be displayed in the 3D view. This grid is independent of the Draft grid.
  • VistaTight Grid: if true the local grid will be localized around the origin of the shape, otherwise it will extend itself more.

Script

See also: FreeCAD Scripting Basics, and scripted objects.

See Part Feature for the general information.

A Part 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"