Part Box: Difference between revisions

From FreeCAD Documentation
m (Precise Label.)
Line 89: Line 89:


<!--T:27-->
<!--T:27-->
* Where {{Incode|myBox}} is the Label for the object.
* Where {{Incode|myBox}} is the user editable name for the object.
* The function returns the newly created object.
* The function returns the newly created object.


The Label of the object can be easily changed by
The label text of the object can be easily changed by


</translate>
</translate>
{{Code|code=
{{Code|code=
box.Label = "new boxLabelText"
box.Label = "new myBoxName"
}}
}}
<translate>
<translate>

Revision as of 08:01, 17 February 2022

Part Box

Menu location
Part → Primitives → Cube
Workbenches
Part
Default shortcut
None
Introduced in version
-
See also
Part Primitives

Description

The Box command from the Part Workbench inserts a parametric, rectangular cuboid, geometric primitive into the active document. By default, the Box command will insert a 10x10x10 mm cube, positioned at the origin, with the label "cube". These parameters may be modified after the object has been added.

Part_Box

Usage

  1. Switch to the Part Workbench
  2. There are several ways to invoke the command:
    • Press the Cube button in the toolbar.
    • Select the Part → Primitives → Cube from the menu bar.

Result: The default result is a box with an equal length, width and height of 10 mm. It is attached to the global xy-plane and one edge is coincident with the global z-axis.

The properties of the box can be edited later, either in the property editor or by double-clicking on the box in the model tree.

Example

Part Box scripting example.

A Part Box object with the values of the bottom scripting example are shown here.

Notes

By default, a box is created with three sides (edges) of equal length, each one 10 mm long.

Properties

See also: Property editor.

A Part Box object is derived from a Part Feature object and inherits all its properties. It also has the following additional properties:

Data

Attachment

The object has the same attachment properties as a Part Part2DObject.

Base

The objects placement and its label.

Box

  • DataLength (Length): The length of the box. This is the dimension in the x-direction.
  • DataWidth (Length): The width of the box. This is the dimension in the y-direction.
  • DataHeight (Length): The height of the box. This is the dimension in the z-direction.

Scripting

A Part Box can be created using the following function:

box = FreeCAD.ActiveDocument.addObject("Part::Box", "myBox")
  • Where myBox is the user editable name for the object.
  • The function returns the newly created object.

The label text of the object can be easily changed by

box.Label = "new myBoxName"

You can access and modify attributes of the box object. For example, you may wish to modify the length, width and height parameters.

box.Length = 4
box.Width = 8
box.Height = 12

You can change its placement with:

box.Placement = FreeCAD.Placement(FreeCAD.Vector(1, 2, 3), FreeCAD.Rotation(75, 60, 30))