Part Prism: Difference between revisions

From FreeCAD Documentation
(Properties)
(Scripting)
Line 64: Line 64:
== Scripting ==
== Scripting ==


See also: [https://freecad.github.io/SourceDoc/ Autogenerated API documentation], [[Part_scripting|Part scripting]] and [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]].
A Part Prism is created with the {{Incode|addObject()}} method of the document.

A Part Prism can be created with the {{Incode|addObject()}} method of the document:


</translate>
</translate>
Line 72: Line 74:
<translate>
<translate>


* Where {{Incode|myPrism}} is the name for the object. The name must be unique for the entire document.
* Where {{Incode|"myPrism"}} is the name for the object.
* The function returns the newly created object.
* The function returns the newly created object.


Example:
The {{Incode|Label}} is the user editable name for the object. It can be easily changed by


</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD as App
prism.Label = "new myPrismName"
}}
<translate>


doc = App.activeDocument()
You can access and modify attributes of the {{Incode|prism}} object. For example, you may wish to modify the number of sides of the base polygon, the circumferential radius or one of the two angles.


prism = doc.addObject("Part::Prism", "myPrism")
</translate>
{{Code|code=
prism.Polygon = 5
prism.Polygon = 5
prism.Circumradius = 10
prism.Circumradius = 10
Line 92: Line 91:
prism.FirstAngle = 22.5
prism.FirstAngle = 22.5
prism.SecondAngle = 45
prism.SecondAngle = 45
prism.Placement = App.Placement(App.Vector(1, 2, 3), App.Rotation(60, 75, 30))

doc.recompute()
}}
}}
<translate>
<translate>


The result will be a new prism with the given attributes.

You can change its placement and orientation with:

</translate>
{{Code|code=
prism.Placement = FreeCAD.Placement(FreeCAD.Vector(1, 2, 3), FreeCAD.Rotation(60, 75, 30))
}}
<translate>


<!--T:11-->
<!--T:11-->
Line 116: Line 109:


</translate>
</translate>
{{Part Tools navi{{#translation:}}}}
{{Part_Tools_navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}

Revision as of 09:30, 2 March 2022

This documentation is not finished. Please help and contribute documentation.

GuiCommand model explains how commands should be documented. Browse Category:UnfinishedDocu to see more incomplete pages like this one. See Category:Command Reference for all commands.

See WikiPages to learn about editing the wiki pages, and go to Help FreeCAD to learn about other ways in which you can contribute.

Part Prism

Menu location
Part → Create primitives → Prism
Workbenches
Part
Default shortcut
None
Introduced in version
0.14
See also
Part Primitives

Description

A Part Prism is a parametric solid that can be created with the Part Primitives command. It is the result of extruding a regular polygon along a straight path. In the coordinate system defined by its DataPlacement property, the bottom face of the prism lies on the XY plane with its center at the origin and one of its vertices on the X axis.

Usage

See Part Primitives.

Example

Part Prism from the scripting example

A Part Prism object created with the scripting example below is shown here.

Properties

See also: Property editor.

A Part Prism 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.

Prism

  • DataPolygon (IntegerConstraint): The number of sides of the polygon. The default is 6.
  • DataCircumradius (Length): The radius of the circle that circumscribes the polygon, the distance from the center of the polygon to one of its vertices. The default is 2mm.
  • DataHeight (Length): The height of the prism. The default is 10mm.
  • DataFirst Angle (Angle): The angle between the extrusion direction of the prism and its positive Z axis, measured around its Y axis. The angle is positive towards its positive X axis. Valid range: 0° <= value < 90°. The default is . introduced in version 0.19
  • DataSecond Angle (Angle): The angle between the extrusion direction of the prism and its positive Z axis, measured around its X axis. The angle is positive towards its positive Y axis. Valid range: 0° <= value < 90°. The default is . introduced in version 0.19

Scripting

See also: Autogenerated API documentation, Part scripting and FreeCAD Scripting Basics.

A Part Prism can be created with the addObject() method of the document:

prism = FreeCAD.ActiveDocument.addObject("Part::Prism", "myPrism")
  • Where "myPrism" is the name for the object.
  • The function returns the newly created object.

Example:

import FreeCAD as App

doc = App.activeDocument()

prism = doc.addObject("Part::Prism", "myPrism")
prism.Polygon = 5
prism.Circumradius = 10
prism.Height = 50
prism.FirstAngle = 22.5
prism.SecondAngle = 45
prism.Placement = App.Placement(App.Vector(1, 2, 3), App.Rotation(60, 75, 30))

doc.recompute()