Part Part2DObject: Difference between revisions
Renatorivo (talk | contribs) No edit summary |
(Property_Attacher_type -> Property_Attacher_Type (capital T). For consistency.) |
||
(39 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
{{TOCright}} |
|||
<translate> |
<translate> |
||
Line 9: | Line 10: | ||
<!--T:2--> |
<!--T:2--> |
||
A [[ |
A [[Part_Part2DObject|Part Part2DObject]], or formally a {{incode|Part::Part2DObject}}, is a simple element with a [[Part_TopoShape|topological shape]] that can be displayed in the [[3D_view|3D view]]. |
||
<!--T:3--> |
<!--T:3--> |
||
The {{incode|Part::Part2DObject}} is derived from |
The {{incode|Part::Part2DObject}} is derived from the [[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. |
||
<!--T:24--> |
<!--T:24--> |
||
Line 18: | Line 19: | ||
<!--T:25--> |
<!--T:25--> |
||
{{Caption|Simplified diagram of the relationships between the core objects in |
{{Caption|Simplified diagram of the relationships between the core objects in FreeCAD}} |
||
==Usage== <!--T:20--> |
==Usage== <!--T:20--> |
||
<!--T:21--> |
<!--T:21--> |
||
The [[Part Part2DObject|Part Part2DObject]] is an internal object, so it cannot be created from the graphical interface, only from the [[Python console|Python console]] as described in the [[ |
The [[Part Part2DObject|Part Part2DObject]] is an internal object, so it cannot be created from the graphical interface, only from the [[Python console|Python console]] as described in the [[#Scripting|Scripting]] section. |
||
<!--T:4--> |
<!--T:4--> |
||
The {{incode|Part::Part2DObject}} is defined in the [[ |
The {{incode|Part::Part2DObject}} is defined in the [[Part_Workbench|Part Workbench]] but can be used as the base class for [[Scripted_objects|scripted objects]] in all [[Workbenches|workbenches]] that produce 2D geometrical shapes. For example, it is the base object for sketches ([[Sketcher_SketchObject|Sketcher SketchObject]]), and for most objects created with the [[Draft_Workbench|Draft Workbench]]. |
||
<!--T:5--> |
<!--T:5--> |
||
Line 37: | Line 38: | ||
<!--T:22--> |
<!--T:22--> |
||
The [[Part_Part2DObject|Part Part2DObject]] ({{incode|Part::Part2DObject}} class) is derived from the [[Part_Feature|Part Feature]] ({{incode|Part::Feature}} class) and inherits all its properties. |
|||
<!--T:9--> |
<!--T:9--> |
||
The Part Part2DObject also has the following additional properties in the [[Property_editor|property editor]]. Hidden properties can be shown by using the {{MenuCommand|Show all}} command in the context menu of the [[Property_editor|property editor]]. |
|||
=== Data === <!--T:10--> |
=== Data === <!--T:10--> |
||
<!--T:11--> |
|||
{{TitleProperty|Attachment}} |
|||
⚫ | * {{PropertyData|Map Mode|Enumeration}}: {{value|Deactivated}} by default. This property determines a plane which the object will use as reference for 2D geometry. Clicking on the ellipsis {{KEY|...}} (three dots), to the right of the entry field |
||
<!--T:23--> |
|||
See [[Part Attachment|Part Attachment]] for more information on all mapping modes. |
|||
<!--T:31--> |
|||
The following two properties are normally hidden. They become visible once {{PropertyData|Map Mode}} is something other than {{value|Deactivated}}. |
|||
⚫ | |||
⚫ | |||
==== Hidden properties Data ==== <!--T:26--> |
|||
<!--T:35--> |
|||
{{TitleProperty|Base}} |
|||
<!--T:36--> |
|||
* {{PropertyData|Proxy|PythonObject}}: a custom class associated with this object. This only exists for the [[Python|Python]] version. See [[Part_Part2DObject#Scripting|Scripting]]. |
|||
<!--T:27--> |
<!--T:27--> |
||
{{TitleProperty|Attachment}} |
{{TitleProperty|Attachment}} |
||
<!--T: |
<!--T:11--> |
||
* {{PropertyData|Attacher Type|String}}: class name of the attach engine object driving the attachment. It defaults to {{incode|Attacher::AttachEnginePlane}}. |
* <div id="Property_Attacher_Type"></div>{{PropertyData|Attacher Type|String|Hidden}}: class name of the attach engine object driving the attachment. It defaults to {{incode|Attacher::AttachEnginePlane}}. |
||
* {{PropertyData|Support|LinkSubList}}: it is the plane or face supporting the 2D geometry. It defaults to an empty list {{incode|[]}}. |
* <div id="Property_Support"></div>{{PropertyData|Support|LinkSubList}}: it is the plane or face supporting the 2D geometry. It defaults to an empty list {{incode|[]}}. |
||
⚫ | * <div id="Property_Map_Mode"></div>{{PropertyData|Map Mode|Enumeration}}: {{value|Deactivated}} by default. This property determines a plane which the object will use as reference for 2D geometry. Clicking on the ellipsis {{KEY|...}} (three dots), to the right of the entry field starts the [[Part_EditAttachment|Part EditAttachment]] command that allows selecting the supporting plane by picking different elements in the [[3D_view|3D view]]. The different modes are: {{value|Deactivated}}, {{value|Translate origin}}, {{value|Object's XY}}, {{value|Object's XZ}}, {{value|Object's YZ}}, {{value|Plane face}}, {{value|Tangent to surface}}, {{value|Normal to edge}}, {{value|Frenet NB}}, {{value|Frenet TN}}, {{value|Frenet TB}}, {{value|Concentric}}, {{value|Revolution section}}, {{value|Plane by 3 points}}, {{value|Normal to 3 points}}, {{value|Folding}}, {{value|Inertia 2-3}}, {{value|Align O-N-X}}, {{value|Align O-N-Y}}, {{value|Align O-X-Y}}, {{value|Align O-X-N}}, {{value|Align O-Y-N}}, {{value|Align O-Y-X}}. |
||
⚫ | |||
⚫ | |||
⚫ | |||
=== View === <!--T:12--> |
|||
⚫ | * <div id="Property_Attachment_Offset"></div>{{PropertyData|Attachment Offset|Placement}}: the position of the object in the [[3D_view|3D view]], with respect to the attachment object's placement. The placement is defined by a {{incode|Base}} point (vector), and a {{incode|Rotation}} (axis and angle). See [[Placement|Placement]]. Hidden if {{PropertyData|Map Mode}} is {{value|Deactivated}}. |
||
<!--T:13--> |
|||
{{TitleProperty|Grid}} |
|||
* {{PropertyView|Grid Size|Length}}: the size of the spacing of the local grid lines in the [[3D view|3D view]]; it defaults to {{value|10 mm}}. |
|||
* {{PropertyView|Grid Snap|Bool}}: it defaults to {{FALSE}}; if {{TRUE}} the grid can be used to snap points. |
|||
* {{PropertyView|Grid Style|Enumeration}}: the style of the grid lines; {{value|Dashed}} (default) or {{value|Light}}. |
|||
* {{PropertyView|Show Grid|Bool}}: it defaults to {{FALSE}}; if {{TRUE}} a grid local to the object will be displayed in the [[3D view|3D view]]. This grid is independent of the [[Draft_ToggleGrid|Draft Grid]]. |
|||
* {{PropertyView|Tight 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 ==== <!--T:29--> |
|||
<!--T:37--> |
|||
{{TitleProperty|Base}} |
|||
<!--T:38--> |
|||
* {{PropertyView|Proxy|PythonObject}}: a custom view provider class associated with this object. This only exists for the [[Python|Python]] version. See [[Part_Part2DObject#Scripting|Scripting]]. |
|||
<!--T:30--> |
|||
All other view properties, including hidden properties, are those of the base [[Part_Feature|Part Feature]] object. |
|||
== Scripting == <!--T:14--> |
== Scripting == <!--T:14--> |
||
<!--T:15--> |
<!--T:15--> |
||
{{Emphasis|See also:}} [[ |
{{Emphasis|See also:}} [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]] and [[Scripted_objects|scripted objects]]. |
||
<!--T:16--> |
<!--T:16--> |
||
Line 103: | Line 66: | ||
<!--T:17--> |
<!--T:17--> |
||
A Part2DObject is created with the {{incode|addObject()}} method of the document. |
A Part2DObject is created with the {{incode|addObject()}} method of the document. |
||
</translate> |
</translate> |
||
{{Code|code= |
{{Code|code= |
||
Line 112: | Line 76: | ||
}} |
}} |
||
<translate> |
<translate> |
||
<!--T:32--> |
|||
This basic {{incode|Part::Part2DObject}} doesn't have a Proxy object so it can't be fully used for sub-classing. |
|||
<!--T:33--> |
<!--T:33--> |
||
For [[Python|Python]] subclassing you should create a {{incode|Part::Part2DObjectPython}} object. |
|||
</translate> |
</translate> |
||
Line 129: | Line 90: | ||
<translate> |
<translate> |
||
<!--T:34--> |
|||
For example, most tools from the [[Draft_Workbench|Draft Workbench]], like [[Draft_Line|Draft Line]], [[Draft_Rectangle|Draft Rectangle]], [[Draft_Polygon|Draft Polygon]], etc., are {{incode|Part::Part2DObjectPython}} objects with a custom icon and additional properties. |
|||
</translate> |
</translate> |
||
{{ |
{{Document_objects_navi{{#translation:}}}} |
||
{{Userdocnavi{{#translation:}}}} |
{{Userdocnavi{{#translation:}}}} |
||
{{clear}} |
Latest revision as of 16:22, 3 July 2022
Introduction
A Part Part2DObject, or formally a Part::Part2DObject
, is a simple element with a topological shape that can be displayed in the 3D view.
The 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
Usage
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.
The Part Part2DObject (Part::Part2DObject
class) is derived from the Part Feature (Part::Feature
class) and inherits all its properties.
The Part Part2DObject also has the following additional properties in the property editor. Hidden properties can be shown by using the Show all command in the context menu of the property editor.
Data
Attachment
- Data (Hidden)Attacher Type (
String
): class name of the attach engine object driving the attachment. It defaults toAttacher::AttachEnginePlane
. - DataSupport (
LinkSubList
): it is the plane or face supporting the 2D geometry. It defaults to an empty list[]
. - DataMap 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 starts the Part EditAttachment command 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
. - DataMap Reversed (
Bool
): it defaults tofalse
; if it istrue
the Z direction will be reversed. For example, a sketch will be flipped upside down. Hidden if DataMap Mode isDeactivated
. - Data (Hidden)Map Path Parameter (
Float
): sets point of curve to map a sketch to. It goes from0
to1
, which corresponds to thestart
andend
. It defaults to0
. - 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 aBase
point (vector), and aRotation
(axis and angle). See Placement. Hidden if DataMap Mode isDeactivated
.
Scripting
See also: FreeCAD Scripting Basics and scripted objects.
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 Part::Part2DObjectPython
object.
import FreeCAD as App
doc = App.newDocument()
obj = App.ActiveDocument.addObject("Part::Part2DObjectPython", "Name")
obj.Label = "Custom label"
- Core: App DocumentObject
- Basic: App FeaturePython, App GeoFeature, Part Feature, Mesh Feature, Fem FemMeshObject
- Internal shapes: Part TopoShape, Mesh MeshObject, Fem FemMesh
- Structure: App DocumentObjectGroup (Std Group), App Part (Std Part), App Link (Std LinkMake)
- Derived: Part Part2DObject, Sketcher SketchObject, PartDesign Body, PartDesign Feature
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub