Difference between revisions of "PartDesign Body"

From FreeCAD Documentation
Jump to navigation Jump to search
(→‎Inheritance: The PartDesign::Body and PartDesign::Feature classes used in the PartDesign Workbench are intended to build parametric 3D solids, and thus are derived from the basic Part::Feature class.)
Line 102: Line 102:
  
 
<!--T:45-->
 
<!--T:45-->
The active Body can be defined from the [[Python console|Python console]] using the {{incode|setActiveObject}} method of the {{incode|ActiveView}}.
+
The active Body can be defined from the [[Python console|Python console]] by using the {{incode|setActiveObject}} method of the {{incode|ActiveView}}. The first argument is the fixed string {{incode|"pdbody"}}, and the second object is the Body object previously created in the document.
 
</translate>
 
</translate>
 
{{Code|code=
 
{{Code|code=
 
import FreeCAD as App
 
import FreeCAD as App
 
import FreeCADGui as Gui
 
import FreeCADGui as Gui
 
+
App.newDocument()
...
+
App.ActiveDocument.addObject("PartDesign::Body")
  
 
obj =  App.ActiveDocument.Body
 
obj =  App.ActiveDocument.Body

Revision as of 16:04, 8 December 2019

Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎italiano • ‎polski • ‎română • ‎русский
Arrow-left.svg Previous: Group.svg Group

PartDesign Body.svg PartDesign Body

Menu location
Part Design → Create body
Workbenches
PartDesign
Default shortcut
None
Introduced in version
0.17
See also
Std Part, feature editing


Description

A PartDesign Body is the base element to create solids shapes with the PartDesign Workbench. It can contain sketches, datums objects, and PartDesign features in order to produce a single contiguous solid.

The Body provides an Origin object which includes local X, Y, and Z axes, and planes. These elements can be used as references to attach sketches and primitive objects.

Since the Body is supposed to be a single contiguous solid, it can be moved entirely as a unit, without moving the individual features. Multiple bodies can be placed inside Std Parts in order to create assemblies.

PartDesign Body tree.png PartDesign Body example.png

Left: the tree view showing the features that sequentially produce the final shape of the object. Right: the final object visible in the 3D view.


How to use

If no previous solid is selected:

  1. Press the PartDesign Body.svg Body button. An empty Body is created and automatically becomes active.
  2. Now you can press PartDesign NewSketch.svg New sketch to create a sketch in the Body that can be used with PartDesign Pad.svg Pad.
  3. Alternatively, add a primitive solid feature, for example, PartDesign AdditiveBox.svg Additive box.

If a solid object is selected:

  1. Press the PartDesign Body.svg Body button. A new body is created containing a single BaseFeature. This BaseFeature element is a simple reference to another object previously created or imported into the document. The BaseFeature can also be created by dragging that solid into an empty Body. This is done when we have a pre-existing solid (for example, created with the Part Workbench or imported from a Step file) that we want to modify further with PartDesign tools.

Notes

  • An existing Body cannot be selected when pressing PartDesign Body.svg Body button. However, an existing Body can be used as the BaseFeature by adding that object to the DataBase Feature property.
  • If no Body currently exists, when PartDesign NewSketch.svg New sketch is pressed on the PartDesign toolbar, a new Body will be automatically created.
  • Double-click the Body in the tree view or open the context menu (right-click) and select Toggle active body to activate or deactivate the Body. If another Body is active, it will be deactivated.

Properties

A PartDesign Body (PartDesign::Body 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 PartDesign Body has the following properties in the property editor.

Data

Base

  • DataTip: displays and sets the feature defined as "Tip".
  • DataBase Feature: displays and sets the external shape used as base feature. It does not apply if a PartDesign feature is the base feature.
  • DataGroup: lists the referenced objects inside the Body.

View

Base

  • ViewDisplay Mode Body: sets the display between two modes:
    • Through (default) exposes everything inside the body (features, datums, sketches, etc.). It is the mode used in adding and editing features inside the body.
    • Tip exposes only the shape of the Body itself according to the set tip; everything else including sketches is hidden from view and cannot be displayed. Practical use: "Tip" allows selection of edges and faces of the Body to create operations from other workbenches.

Full description

Active status

An open document can contain multiple Bodies. To add a new feature to a specific Body, it needs to be made active. An active body will be displayed in the tree view with the background color specified by the Active container value in the preferences editor (by default, light blue). An active body will also be shown in bold text.

To activate a Body:

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

PartDesign Body active.png

Activating a Body automatically switches the interface to the PartDesign Workbench. Only a single Body can be active at a time.

The active Body can be defined from the Python console by using the setActiveObject method of the ActiveView. The first argument is the fixed string "pdbody", and the second object is the Body object previously created in the document.

import FreeCAD as App
import FreeCADGui as Gui
App.newDocument()
App.ActiveDocument.addObject("PartDesign::Body")

obj =  App.ActiveDocument.Body
Gui.ActiveDocument.ActiveView.setActiveObject("pdbody", obj)

Origin

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, and planes along with axes can be used to create other datum (reference) geometry. All elements inside the Body are referenced to the Body's Origin; which means that the body can be moved and rotated in reference to the global coordinate system without affecting the placement of elements inside the body.

PartDesign Body tree-02.png

Base Feature

The base feature is by definition the first PartDesign feature created in the Body. But it is possible to use a solid shape, either imported or modelled in other workbenches, as a base feature to which sketches and other features can be added.

PartDesign Body tree-03.png

Tip

The tip is the feature that is exposed outside the Body. It is automatically set to the last feature at the bottom of the tree. But sometimes it can be useful to change it to an earlier feature in the Body tree, which in effect rolls back its history; then it is possible to add features that should have been added earlier. In the Body tree, the feature set to tip displays a green dot with a white down arrow in it.

PartDesign Body tree-04.png

For more details, see the PartDesign MoveTip.png Move Tip page.

Visibility Management

The Body's visibility supersedes the visibility of any object it contains. If the Body is hidden, the objects it contains will be hidden as well, even if their visibility is set to true. Only one feature can be visible at a time. Selecting a hidden feature and pressing the space bar will make it visible, and automatically hide the previously visible feature.

Interaction with other workbenches

By default, objects underneath a Body are selectable, and this is of course required to edit and add features in PartDesign. But selecting a Body's features to create operations from other workbenches (like Part or Draft) is not advised, as the results may be unexpected; in all cases, an error labelled Links go out of the allowed scope will appear in the Report view.

Therefore, for interactions with other workbenches, only the Body itself should be selected from the Model tree. In cases where it is necessary to select specific topology on the Body (vertex, edge, face), then the Body's Display Mode Body view property can be switched from Through (default) to Tip. This property is accessible from the View panel. In Tip mode, access to the objects under the Body (features, datums, sketches) is disabled; everything but the tip feature will be hidden in the 3D view, no matter which object is set as visible.

Once operations in other workbenches are completed, do not forget to reset the Display Mode Body property to Through to be able to edit the Body.

Inheritance

FreeCAD core objects.svg

Simplified diagram of the relationships between the core objects in the program. The PartDesign::Body and PartDesign::Feature classes used in the PartDesign Workbench are intended to build parametric 3D solids, and thus are derived from the basic Part::Feature class.


Scripting

See also: FreeCAD Scripting Basics, and scripted objects.

See Part Feature for the general information.

A PartDesign Body is created with the addObject() method of the document. Once a body exists, features, like additive and subtractive primitives, can be added and attached to that body.

import FreeCAD as App

doc = App.newDocument()
obj = App.ActiveDocument.addObject('PartDesign::Body', 'Body')
obj.Label = "Custom label"

feature = App.ActiveDocument.addObject('PartDesign::AdditiveBox', 'Box')
obj.addObject(feature)
App.ActiveDocument.recompute()
Arrow-left.svg Previous: Group.svg Group