Std Part: Difference between revisions

From FreeCAD Documentation
(More complete "Scripting" information)
m (__setstate__ and __getstate__ has been replaced)
 
(130 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:17-->
<!--T:17-->
{{Docnav
{{Docnav
|
|
|[[Std Group|Group]]
|[[Std_Group|Group]]
|[[Std_Base|Std Base]]
|[[PartDesign_Workbench|PartDesign]]
|IconL=
|IconL=
|IconR=Std_Group.svg
|IconC=Workbench_PartDesign.svg
|IconR=Group.svg
|IconC=Freecad.svg
}}
}}


Line 17: Line 18:
|Workbenches=All
|Workbenches=All
|Version=0.17
|Version=0.17
|SeeAlso=[[Std Group|Std Group]], [[PartDesign Body|PartDesign Body]]
|SeeAlso=[[Std_Group|Std Group]], [[PartDesign_Body|PartDesign Body]]
}}
}}


Line 23: Line 24:


<!--T:3-->
<!--T:3-->
[[Std_Part|Std Part]] (internally called [[App_Part|App Part]]) is a general purpose container that keeps together a group of objects so that they can be moved together as a unit in the [[3D_view|3D view]].
{{Button|[[File:Std_Part.svg|16px]] [[Std_Part|Std Part]]}} (internally called [[App_Part|App Part]]) is a general purpose container that keeps together a group of objects so that they can be moved together as a unit in the [[3D_view|3D view]].


<!--T:4-->
<!--T:4-->
A Std Part was developed to be used in assemblies, as one of its principal characteristics is that it has an {{MenuCommand|Origin}} object which includes local X, Y, and Z axes, and standard planes. This Origin can serve as the reference to position and attach other objects inside the Std Part. The Std Part is principally envisioned to contain objects with a solid [[Part_TopoShape|Part TopoShape]], like [[Part_Primitives|Part Primitives]] and [[PartDesign_Body|PartDesign Bodies]], and other Std Parts in order to create complex arrangements of sub-assemblies. Nevertheless, it can also contain other objects like [[Mesh_Workbench|Mesh objects]] and [[Sketch|Sketches]].
The Std Part element was developed to be the basic building block to create mechanical [[assembly|assemblies]]. In particular, it is meant to arrange objects that have a [[Part_TopoShape|Part TopoShape]], like [[Part_Primitives|Part Primitives]], [[PartDesign_Body|PartDesign Bodies]], and other [[Part_Feature|Part Features]]. The Std Part provides an [[#Origin|Origin object]] with local X, Y, and Z axes, and standard planes, that can be used as reference to position the contained objects. In addition, Std Parts may be nested inside other Std Parts to create a big assembly from smaller sub-assemblies.

<!--T:54-->
Although it is primarily intended for solid bodies, the Std Part can be used to manage any object that has a [[Placement|Placement]] property, so it can also contain [[Mesh_Feature|Mesh Features]], [[Sketch|sketches]], and other objects derived from the [[App_GeoFeature|App GeoFeature]] class.


<!--T:5-->
<!--T:5-->
Do not confuse the {{Button|[[File:PartDesign_Body.svg|16px]] [[PartDesign_Body|PartDesign Body]]}} with the {{Button|[[File:Std_Part.svg|16px]] [[Std_Part|Std Part]]}}. The first one is a specific object used in the [[File:Workbench_PartDesign.svg|24px]] [[PartDesign_Workbench|PartDesign Workbench]], intended to model a [[PartDesign_Body#Single_contiguous_solid|single contiguous solid]] by means of [[PartDesign_Feature|PartDesign Features]]. On the other hand, the [[Std_Part|Std Part]] is not used for modelling, just to arrange different objects in space, with the intention to create [[assembly|assemblies]].
The Std Part tool is not defined by a particular workbench, but by the base system. It is found in the {{MenuCommand|structure toolbar}}.

<!--T:87-->
The {{Button|[[File:Std_Part.svg|16px]] [[Std_Part|Std Part]]}} tool is not defined by a particular workbench, but by the base system, thus it is found in the {{MenuCommand|structure toolbar}} that is available in all [[Workbenches|workbenches]]. To group objects arbitrarily without considering their position, use {{Button|[[File:Std_Group.svg|16px]] [[Std_Group|Std Group]]}}; this object does not affect the placements of the elements that it contains, it is essentially just a folder that is used to keep the [[Tree_view|Tree view]] organized.


</translate>
</translate>
Line 36: Line 43:


<!--T:21-->
<!--T:21-->
{{Caption|Left: elements inside a Std Part in the [[tree_view|tree view]]. Right: objects arranged in space, referred to the Origin defined by a Part.}}
{{Caption|Left: elements inside a Std Part in the [[Tree_view|Tree view]]. Right: objects positioned in space, referred to the Origin of the Std Part.}}


===Example uses=== <!--T:7-->
==Usage== <!--T:11-->
* As an assembly container that groups objects to be manufactured separately then glued or screwed together, like a wooden table.
* When importing a STEP assembly in FreeCAD, the main assembly and its sub-assemblies are Part containers.
* A part that is composed of multiple non-fused components, like a ball bearing.

===Active Status=== <!--T:8-->
A FreeCAD document can contain multiple Parts. Only one Part can be active at a time. An active Part will be displayed in the tree with a light blue background color.
</translate>
[[File:Std Part-tree-active.png|none]]
<translate>
===Origin=== <!--T:9-->
The Origin consists of the three standard axes (X, Y, Z) and three standard planes (XY, XZ and YZ). Sketches can be attached to these planes. All elements inside the Part are referenced to the Part's Origin; which means that the Part can be moved and rotated in reference to the global coordinate system without affecting the placement of elements inside it.
</translate>
[[File:PartDesign_Body_tree-02.png|none]]
<translate>
===Visibility Management=== <!--T:10-->
The Part's visibility supersedes the visibility of any object it contains. If the Part is hidden, the objects it contains will be hidden as well, even if their visibility is set to true. Multiple objects inside a Part can be visible at a time.

==How to use== <!--T:11-->


<!--T:12-->
<!--T:12-->
# Press the {{Button|[[File:Std_Part.svg|16px]] [[Std_Part|Std Part]]}} button. An empty Part is created and automatically becomes ''[[Std_Part#Active_status|active]]''.
# Press the {{Button|[[File:Std_Part.svg|16px]] [[Std_Part|Create part]]}} button.
# An empty Part is created and automatically becomes ''[[Std_Part#Active_status|active]]''.
# To add objects to a Part, drag and drop them over the Part in the [[tree_view|tree view]].
# To remove objects from a Part, drag them out of the Part, and onto the document label at the top of the [[tree_view|tree view]].
# To add objects to the Part, select them in [[Tree_view|Tree view]], and drag and drop them onto the Part.
# To remove objects from the Part, drag them out of the Part, and onto the document label at the top of the [[Tree_view|Tree view]].
# Objects can also be added and removed by editing the {{PropertyData|Group}} property of the Part.


=== Notes ===
== Notes == <!--T:55-->


<!--T:56-->
* As of v0.19, a given object can only belong to a single Part.
* An object can only belong to a single Part.
* Double-click the Part in the [[tree view|tree view]] or open the context menu (right-click) and select {{MenuCommand|Toggle active part}} to activate or deactivate the Part. If another Part is active, it will be deactivated. See [[Std_Part#Active_status|active status]] for more information.
* 3D operations like [[Part_Boolean|Part Boolean]] cannot be applied to Parts. For example, you cannot select two Parts, and perform a [[Part_Fuse|Part Fuse]] or [[Part_Cut|Part Cut]].


==Properties== <!--T:13-->
==Properties== <!--T:13-->


<!--T:57-->
A [[Std_Part|Std Part]] is internally called [[App_Part|App Part]] ({{incode|App::Part}} class), and is derived from an [[App_GeoFeature|App GeoFeature]] ({{incode|App::GeoFeature}} class), therefore it shares most of the latter's properties.
The [[Std_Part|Std Part]], internally called [[App_Part|App Part]] ({{incode|App::Part}} class), is derived from the [[App_GeoFeature|App GeoFeature]] ({{incode|App::GeoFeature}} class) and inherits all its properties. It also has several additional properties. Notably properties that help it manage information in the context of an assembly, for example, {{PropertyData|Type}}, {{PropertyData|Id}}, {{PropertyData|License}}, {{PropertyData|LicenseURL}} and {{PropertyData|Group}}.


<!--T:59-->
In addition to the properties described in [[App_GeoFeature|App GeoFeature]], the App Part class has some properties that help it manage information in the context of an assembly, for example, {{PropertyData|Type}}, {{PropertyData|Id}}, {{PropertyData|License}}, {{PropertyData|LicenseURL}}, {{PropertyData|Color}}, and {{PropertyData|Group}}.
These are the properties available 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:60-->
These are the properties available 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:61-->
{{TitleProperty|Base}}
{{TitleProperty|Base}}


<!--T:14-->
<!--T:14-->
* {{PropertyData|Type|String}}: a description for this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|Type|String}}: a description for this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|Id|String}}: and ID or part number of this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|Material|Link}}: the material for this object.
* {{PropertyData|Meta|Map|Hidden}}: map with additional meta information. By default, it is empty <code>{}</code>.
* {{PropertyData|Id|String}}: an identification or part number for this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|Uid|UUID|Hidden}}: the [https://en.wikipedia.org/wiki/Universally_unique_identifier universally unique identifier] (UUID) (128-bit number) of the object. This is assigned at creation time.
* {{PropertyData|License|String}}: a field to specify the license for this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|License|String}}: a field to specify the license for this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|LicenseURL|String}}: a field to specify the web address to the license or contract for this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|LicenseURL|String}}: a field to specify the web address to the license or contract for this object. By default, it is an empty string {{value|""}}.
* {{PropertyData|Color|Color}}: a tuple of three floating point RGBA values {{value|(r,g,b,a)}} to define the color of the object; by default it is {{value|(1.0, 1.0, 1.0, 1.0)}}, which is displayed as {{value|[255,255,255]}} on base 255, <span style="background-color:#fff; color:#000; width:3em; height:12pt; padding: 2px 1em 2px;">white</span>.
* {{PropertyData|Color|Color}}: a tuple of four floating point RGBA values {{value|(r,g,b,a)}} to define the color of the object; by default it is {{value|(1.0, 1.0, 1.0, 1.0)}}, which is displayed as {{value|[255,255,255]}} on base 255, <span style="background-color:#fff; color:#000; border: 1px solid #888888; width:3em; height:12pt; padding: 2px 1em 2px;">white color</span>.
* {{PropertyData|Placement|Placement}}: the position of the object in the [[3D view|3D view]]. The placement is defined by a {{incode|Base}} point (vector), and a {{incode|Rotation}} (axis and angle). See [[Placement|Placement]].
* {{PropertyData|Placement|Placement}}: the position of the object in the [[3D_view|3D view]]. The placement is defined by a {{incode|Base}} point (vector), and a {{incode|Rotation}} (axis and angle). See [[Placement|Placement]].
** {{PropertyData|Angle}}: the angle of rotation around the {{PropertyData|Axis}}. By default, it is {{value|0°}} (zero degrees).
** {{PropertyData|Angle}}: the angle of rotation around the {{PropertyData|Axis}}. By default, it is {{value|0°}} (zero degrees).
** {{PropertyData|Axis}}: the unit vector that defines the axis of rotation for the placement. Each component is a floating point value between {{value|0}} and {{value|1}}. If any value is above {{value|1}}, the vector is normalized so that the magnitude of the vector is {{value|1}}. By default, it is the positive Z axis, {{value|(0, 0, 1)}}.
** {{PropertyData|Axis}}: the unit vector that defines the axis of rotation for the placement. Each component is a floating point value between {{value|0}} and {{value|1}}. If any value is above {{value|1}}, the vector is normalized so that the magnitude of the vector is {{value|1}}. By default, it is the positive Z axis, {{value|(0, 0, 1)}}.
** {{PropertyData|Position}}: a vector with the 3D coordinates of the base point. By default, it is the origin {{value|(0, 0, 0)}}.
** {{PropertyData|Position}}: a vector with the 3D coordinates of the base point. By default, it is the origin {{value|(0, 0, 0)}}.
* {{PropertyData|Label|String}}: the user editable name of this object, it is an arbitrary UTF8 string.
* {{PropertyData|Label|String}}: the user editable name of this object, it is an arbitrary UTF8 string.
* {{PropertyData|Label2|String|Hidden}}: a longer, user editable description of this object, it is an arbitrary UTF8 string that may include newlines. By default, it is an empty string {{value|""}}.
* {{PropertyData|Expression Engine|ExpressionEngine|Hidden}}: a list of expressions. By default, it is empty {{value|[]}}.
* {{PropertyData|Visibility|Bool|Hidden}}: whether to display the object or not.
* {{PropertyData|Origin|Link|Hidden}}: the [[App_OriginGroupExtension|App Origin]] object that is the positional reference for all elements listed in {{PropertyData|Group}}.
* {{PropertyData|Group|LinkList}}: a list of referenced objects. By default, it is empty {{value|[]}}.
* {{PropertyData|Group|LinkList}}: a list of referenced objects. By default, it is empty {{value|[]}}.
* {{PropertyData|_ Group Touched|Bool|Hidden}}: whether the group is touched or not.


=== View === <!--T:64-->
==== Hidden properties Data ====


<!--T:89-->
* {{PropertyData|Material|Map}}: map with material properties. By default, it is empty <code>{}</code>.
{{TitleProperty|Display Options}}
* {{PropertyData|Meta|Map}}: map with additional meta information. By default, it is empty <code>{}</code>.
* {{PropertyData|Uid|UUID}}: UUID of the object.
* {{PropertyData|Label2|String}}: a longer, user editable description of this object, it is an arbitrary UTF8 string that may include newlines. By default, it is an empty string {{value|""}}.
* {{PropertyData|Expression Engine|ExpressionEngine}}: a list of expressions. By default, it is empty {{value|[]}}.
* {{PropertyData|Visibility|Bool}}: whether to display the object or not.
* {{PropertyData|Origin|Link}}: Origin object linked to the group.
* {{PropertyData|_ Group Touched|Bool}}: whether the group is touched or not.


<!--T:90-->
=== View ===
* {{PropertyView|Display Mode|Enumeration}}: {{value|Group}}.
* {{PropertyView|Show In Tree|Bool}}: if it is {{TRUE}}, the object appears in the [[Tree_view|Tree view]]. Otherwise, it is set as invisible.
* {{PropertyView|Visibility|Bool}}: if it is {{TRUE}}, the object appears in the [[3D_view|3D view]]; otherwise it is invisible. By default this property can be toggled on and off by pressing the {{KEY|Space}} bar in the keyboard.


<!--T:91-->
The App Part only has five of the properties of the basic [[App_GeoFeature|App GeoFeature]], and it does not have hidden properties.
{{TitleProperty|Selection}}


<!--T:92-->
{{TitleProperty|Base}}

* {{PropertyView|Display Mode|Enumeration}}: {{value|Group}}.
* {{PropertyView|On Top When Selected|Enumeration}}: {{value|Disabled}} (default), {{value|Enabled}}, {{value|Object}}, {{value|Element}}.
* {{PropertyView|On Top When Selected|Enumeration}}: {{value|Disabled}} (default), {{value|Enabled}}, {{value|Object}}, {{value|Element}}.
* {{PropertyView|Selection Style|Enumeration}}: {{value|Shape}} (default), {{value|BoundBox}}. If the option is {{value|Shape}}, the entire shape (vertices, edges, and faces) will be highlighted in the [[3D view|3D view]]; if it is {{value|BoundBox}} only the bounding box will be highlighted.
* {{PropertyView|Selection Style|Enumeration}}: {{value|Shape}} (default), {{value|BoundBox}}. If the option is {{value|Shape}}, the entire shape (vertices, edges, and faces) will be highlighted in the [[3D_view|3D view]]; if it is {{value|BoundBox}} only the bounding box will be highlighted.
* {{PropertyView|Show In Tree|Bool}}: if it is {{TRUE}}, the object appears in the [[tree view|tree view]]. Otherwise, it is set as invisible.
* {{PropertyView|Visibility|Bool}}: if it is {{TRUE}}, the object appears in the [[3D view|3D view]]; otherwise it is invisible. By default this property can be toggled on and off by pressing the {{KEY|Space}} bar in the keyboard.


==Limitations== <!--T:15-->
== Detailed explanation == <!--T:70-->


<!--T:16-->
===Active status=== <!--T:8-->
* Even when a Part is active, newly created objects are not placed inside the Part, but at the bottom of the tree. Simply drag and drop them over the Part.
* A Part has no shape. It is therefore not possible to apply most 3D operations on a Part, such as Part Booleans.
* At this time, [[Draft Snap|Draft Snaps]] do not work on selected Part containers or on objects inside a Part container.
* ''Redactor's note: at this time, it is unclear whether the Part's active status serves a purpose.''


== Inheritance == <!--T:22-->
<!--T:71-->
An open document can contain multiple Parts. But only one Part can be active. The active Part is displayed in the [[Tree_view|tree view]] with the background color specified by the {{MenuCommand|Active container}} value in the [[Preferences_Editor#Colors|preferences editor]] (by default, light blue). It will also be shown with bold text.


<!--T:23-->
<!--T:80-->
To activate or de-activate a Part:
A [[Std_Part|Std Part]] is formally an instance of the class {{incode|App::Part}}, whose parent is the basic [[App_GeoFeature|App GeoFeature]] ({{incode|App::GeoFeature}} class).
* Double click on it on the [[Tree_view|Tree view]], or
* Open the context menu (right click) and select {{MenuCommand|Toggle active part}}.


</translate>
<!--T:24-->
[[File:FreeCAD_core_objects.svg|800px]]
[[File:Std_Part_active.png]]
<translate>


<!--T:25-->
<!--T:81-->
{{Caption|Document with two Std Parts, of which the second one is active.}}
{{Caption|Simplified diagram of the relationships between the core objects in the program. The {{incode|App::Part}} class is a simple group that has a position in 3D space, and controls the placement of other objects it contains.}}

===Origin=== <!--T:9-->

<!--T:74-->
The Origin consists of the three standard axes (X, Y, Z) and three standard planes (XY, XZ and YZ). [[Sketch|Sketches]] and other objects can be attached to these elements when creating them.

</translate>
[[File:Part_Origin_tree.png]] [[File:Part_Origin_view.png]]
<translate>

<!--T:82-->
{{Caption|Left: Part Origin in the [[Tree_view|Tree view]]. Right: representation of the Origin elements in the [[3D_view|3D view]].}}

<!--T:83-->
{{Emphasis|Note:}} the Origin is an [[App_OriginGroupExtension|App Origin]] object ({{incode|App::Origin}} class), while the axes and planes are objects of type {{incode|App::Line}} and {{incode|App::Plane}} respectively. Each of these elements can be hidden and unhidden individually with the {{KEY|Space}} bar; this is useful to choose the correct reference when creating other objects.

<!--T:84-->
{{Emphasis|Note 2:}} all elements inside the Part are referenced to the Part's Origin which means that the Part can be moved and rotated in reference to the global coordinate system without affecting the placement of the elements inside.

===Visibility Management=== <!--T:10-->

<!--T:75-->
The Part's visibility supersedes the visibility of any object it contains. If the Part is hidden, the objects it contains will be hidden as well, even if their individual {{PropertyView|Visibility}} property is set to {{TRUE}}. If the Part is visible, then each object's {{PropertyView|Visibility}} determines whether the object is shown or not.

<!--T:85-->
[[File:Part_Visibility_off.png]] [[File:Part_Visibility_on.png]]
{{Caption|The visibility of the Std Part determines whether the objects grouped under it are shown in the [[3D_view|3D view]] or not. Left: the Part is hidden, so none of the objects will be shown in the [[3D_view|3D view]]. Right: the Part is visible, so each object controls its own visibility.}}


== Scripting == <!--T:26-->
== Scripting == <!--T:26-->


<!--T:76-->
{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]], and [[scripted objects|scripted objects]].
{{Emphasis|See also:}} [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]] and [[Scripted_objects|scripted objects]].


<!--T:77-->
See [[Part_Feature|Part Feature]] for the general information on adding objects to the program.
See [[Part_Feature|Part Feature]] for the general information on adding objects to the document.


<!--T:27-->
<!--T:27-->
A Std Part ([[App_Part|App Part]]) is created with the {{incode|addObject()}} method of the document. Once a Part exists, other objects can be added to it with the {{incode|addObject()}} or {{incode|addObjects()}} methods of this Part.
A Std Part ([[App_Part|App Part]]) is created with the {{incode|addObject()}} method of the document. Once a Part exists, other objects can be added to it with the {{incode|addObject()}} or {{incode|addObjects()}} methods.

</translate>
</translate>
{{Code|code=
{{Code|code=
Line 148: Line 173:


doc = App.newDocument()
doc = App.newDocument()
obj = App.ActiveDocument.addObject("App::Part", "Part")
part = App.ActiveDocument.addObject("App::Part", "Part")


bod1 = App.ActiveDocument.addObject("PartDesign::Body", "Body")
obj1 = App.ActiveDocument.addObject("PartDesign::Body", "Body")
bod2 = App.ActiveDocument.addObject("Part::Box", "Box")
obj2 = App.ActiveDocument.addObject("Part::Box", "Box")


obj.addObjects([bod1, bod2])
part.addObjects([obj1, obj2])
App.ActiveDocument.recompute()
App.ActiveDocument.recompute()
}}
}}
<translate>
<translate>

<!--T:88-->
You cannot create a scripted {{incode|App::Part}}. However, you can add {{incode|App::Part}} behavior to a scripted {{incode|Part::FeaturePython}} object by using the following code:

</translate>
{{Code|code=
class MyGroup(object):
def __init__(self, obj=None):
self.Object = obj
if obj:
self.attach(obj)

def dumps(self):
return

def loads(self, _state):
return

def attach(self, obj):
obj.addExtension("App::OriginGroupExtensionPython")
obj.Origin = FreeCAD.ActiveDocument.addObject("App::Origin", "Origin")

def onDocumentRestored(self, obj):
self.Object = obj

class ViewProviderMyGroup(object):
def __init__(self, vobj=None):
if vobj:
vobj.Proxy = self
self.attach(vobj)
else:
self.ViewObject = None

def attach(self, vobj):
vobj.addExtension("Gui::ViewProviderOriginGroupExtensionPython")
self.ViewObject = vobj

def dumps(self):
return None

def loads(self, _state):
return None

App.ActiveDocument.addObject("Part::FeaturePython",
"Group",
group.MyGroup(),
group.ViewProviderMyGroup(),
True)
}}
<translate>



<!--T:18-->
<!--T:18-->
{{Docnav
{{Docnav
|
|
|[[Std Group|Group]]
|[[Std_Group|Group]]
|[[Std_Base|Std Base]]
|[[PartDesign_Workbench|PartDesign]]
|IconL=
|IconL=
|IconR=Std_Group.svg
|IconC=Workbench_PartDesign.svg
|IconR=Group.svg
|IconC=Freecad.svg
}}
}}

<!--T:19-->
{{Std Base}}
{{PartDesign Tools navi}}

<!--T:20-->
{{Userdocnavi}}


</translate>
</translate>
{{Std_Base_navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}

Latest revision as of 10:47, 26 January 2024

Std Part

Menu location
None
Workbenches
All
Default shortcut
None
Introduced in version
0.17
See also
Std Group, PartDesign Body

Description

Std Part (internally called App Part) is a general purpose container that keeps together a group of objects so that they can be moved together as a unit in the 3D view.

The Std Part element was developed to be the basic building block to create mechanical assemblies. In particular, it is meant to arrange objects that have a Part TopoShape, like Part Primitives, PartDesign Bodies, and other Part Features. The Std Part provides an Origin object with local X, Y, and Z axes, and standard planes, that can be used as reference to position the contained objects. In addition, Std Parts may be nested inside other Std Parts to create a big assembly from smaller sub-assemblies.

Although it is primarily intended for solid bodies, the Std Part can be used to manage any object that has a Placement property, so it can also contain Mesh Features, sketches, and other objects derived from the App GeoFeature class.

Do not confuse the PartDesign Body with the Std Part. The first one is a specific object used in the PartDesign Workbench, intended to model a single contiguous solid by means of PartDesign Features. On the other hand, the Std Part is not used for modelling, just to arrange different objects in space, with the intention to create assemblies.

The Std Part tool is not defined by a particular workbench, but by the base system, thus it is found in the structure toolbar that is available in all workbenches. To group objects arbitrarily without considering their position, use Std Group; this object does not affect the placements of the elements that it contains, it is essentially just a folder that is used to keep the Tree view organized.

Left: elements inside a Std Part in the Tree view. Right: objects positioned in space, referred to the Origin of the Std Part.

Usage

  1. Press the Create part button.
  2. An empty Part is created and automatically becomes active.
  3. To add objects to the Part, select them in Tree view, and drag and drop them onto the Part.
  4. To remove objects from the Part, drag them out of the Part, and onto the document label at the top of the Tree view.
  5. Objects can also be added and removed by editing the DataGroup property of the Part.

Notes

  • An object can only belong to a single Part.
  • 3D operations like Part Boolean cannot be applied to Parts. For example, you cannot select two Parts, and perform a Part Fuse or Part Cut.

Properties

The Std Part, internally called App Part (App::Part class), is derived from the App GeoFeature (App::GeoFeature class) and inherits all its properties. It also has several additional properties. Notably properties that help it manage information in the context of an assembly, for example, DataType, DataId, DataLicense, DataLicenseURL and DataGroup.

These are the properties available in the property editor. Hidden properties can be shown by using the Show all command in the context menu of the property editor.

Data

Base

  • DataType (String): a description for this object. By default, it is an empty string "".
  • DataMaterial (Link): the material for this object.
  • Data (Hidden)Meta (Map): map with additional meta information. By default, it is empty {}.
  • DataId (String): an identification or part number for this object. By default, it is an empty string "".
  • Data (Hidden)Uid (UUID): the universally unique identifier (UUID) (128-bit number) of the object. This is assigned at creation time.
  • DataLicense (String): a field to specify the license for this object. By default, it is an empty string "".
  • DataLicenseURL (String): a field to specify the web address to the license or contract for this object. By default, it is an empty string "".
  • DataColor (Color): a tuple of four floating point RGBA values (r,g,b,a) to define the color of the object; by default it is (1.0, 1.0, 1.0, 1.0), which is displayed as [255,255,255] on base 255, white color.
  • DataPlacement (Placement): the position of the object in the 3D view. The placement is defined by a Base point (vector), and a Rotation (axis and angle). See Placement.
    • DataAngle: the angle of rotation around the DataAxis. By default, it is (zero degrees).
    • DataAxis: the unit vector that defines the axis of rotation for the placement. Each component is a floating point value between 0 and 1. If any value is above 1, the vector is normalized so that the magnitude of the vector is 1. By default, it is the positive Z axis, (0, 0, 1).
    • DataPosition: a vector with the 3D coordinates of the base point. By default, it is the origin (0, 0, 0).
  • DataLabel (String): the user editable name of this object, it is an arbitrary UTF8 string.
  • Data (Hidden)Label2 (String): a longer, user editable description of this object, it is an arbitrary UTF8 string that may include newlines. By default, it is an empty string "".
  • Data (Hidden)Expression Engine (ExpressionEngine): a list of expressions. By default, it is empty [].
  • Data (Hidden)Visibility (Bool): whether to display the object or not.
  • Data (Hidden)Origin (Link): the App Origin object that is the positional reference for all elements listed in DataGroup.
  • DataGroup (LinkList): a list of referenced objects. By default, it is empty [].
  • Data (Hidden)_ Group Touched (Bool): whether the group is touched or not.

View

Display Options

  • ViewDisplay Mode (Enumeration): Group.
  • ViewShow In Tree (Bool): if it is true, the object appears in the Tree view. Otherwise, it is set as invisible.
  • ViewVisibility (Bool): if it is true, the object appears in the 3D view; otherwise it is invisible. By default this property can be toggled on and off by pressing the Space bar in the keyboard.

Selection

  • ViewOn Top When Selected (Enumeration): Disabled (default), Enabled, Object, Element.
  • ViewSelection Style (Enumeration): Shape (default), BoundBox. If the option is Shape, the entire shape (vertices, edges, and faces) will be highlighted in the 3D view; if it is BoundBox only the bounding box will be highlighted.

Detailed explanation

Active status

An open document can contain multiple Parts. But only one Part can be active. The active Part is displayed in the tree view with the background color specified by the Active container value in the preferences editor (by default, light blue). It will also be shown with bold text.

To activate or de-activate a Part:

  • Double click on it on the Tree view, or
  • Open the context menu (right click) and select Toggle active part.

Document with two Std Parts, of which the second one is active.

Origin

The Origin consists of the three standard axes (X, Y, Z) and three standard planes (XY, XZ and YZ). Sketches and other objects can be attached to these elements when creating them.

Left: Part Origin in the Tree view. Right: representation of the Origin elements in the 3D view.

Note: the Origin is an App Origin object (App::Origin class), while the axes and planes are objects of type App::Line and App::Plane respectively. Each of these elements can be hidden and unhidden individually with the Space bar; this is useful to choose the correct reference when creating other objects.

Note 2: all elements inside the Part are referenced to the Part's Origin which means that the Part can be moved and rotated in reference to the global coordinate system without affecting the placement of the elements inside.

Visibility Management

The Part's visibility supersedes the visibility of any object it contains. If the Part is hidden, the objects it contains will be hidden as well, even if their individual ViewVisibility property is set to true. If the Part is visible, then each object's ViewVisibility determines whether the object is shown or not.

The visibility of the Std Part determines whether the objects grouped under it are shown in the 3D view or not. Left: the Part is hidden, so none of the objects will be shown in the 3D view. Right: the Part is visible, so each object controls its own visibility.

Scripting

See also: FreeCAD Scripting Basics and scripted objects.

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

A Std Part (App Part) is created with the addObject() method of the document. Once a Part exists, other objects can be added to it with the addObject() or addObjects() methods.

import FreeCAD as App

doc = App.newDocument()
part = App.ActiveDocument.addObject("App::Part", "Part")

obj1 = App.ActiveDocument.addObject("PartDesign::Body", "Body")
obj2 = App.ActiveDocument.addObject("Part::Box", "Box")

part.addObjects([obj1, obj2])
App.ActiveDocument.recompute()

You cannot create a scripted App::Part. However, you can add App::Part behavior to a scripted Part::FeaturePython object by using the following code:

class MyGroup(object):
    def __init__(self, obj=None):
        self.Object = obj
        if obj:
            self.attach(obj)

    def dumps(self):
        return

    def loads(self, _state):
        return

    def attach(self, obj):
        obj.addExtension("App::OriginGroupExtensionPython")
        obj.Origin = FreeCAD.ActiveDocument.addObject("App::Origin", "Origin")

    def onDocumentRestored(self, obj):
        self.Object = obj

class ViewProviderMyGroup(object):
    def __init__(self, vobj=None):
        if vobj:
            vobj.Proxy = self
            self.attach(vobj)
        else:
            self.ViewObject = None

    def attach(self, vobj):
        vobj.addExtension("Gui::ViewProviderOriginGroupExtensionPython")
        self.ViewObject = vobj

    def dumps(self):
        return None

    def loads(self, _state):
        return None

App.ActiveDocument.addObject("Part::FeaturePython",
                             "Group",
                             group.MyGroup(),
                             group.ViewProviderMyGroup(),
                             True)