Part RegularPolygon: Difference between revisions

From FreeCAD Documentation
(Revising...)
(Undo revision 1282083 by David69 (talk)Please don't rush like that. And please, please look at all other pages belonging to the workbench before making these adhoc changes.)
Tag: Undo
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{UnfinishedDocu{{#translation:}}}} <!-- Note: Screenshot + Formatted Parameters + Scripting section. -->
<translate>
<translate>


Line 16: Line 15:
{{GuiCommand
{{GuiCommand
|Name=Part RegularPolygon
|Name=Part RegularPolygon
|MenuLocation=Part → [[Part_Primitives|Create primitives]] → Regular Polygon
|MenuLocation=Part → [[Part_Primitives|Create primitives]] → Regular polygon
|Workbenches=[[Part_Workbench|Part]]
|Workbenches=[[Part_Workbench|Part]], [[OpenSCAD_Workbench|OpenSCAD]]
|Version=0.14
|Version=0.14
|SeeAlso=[[Part_Primitives|Part Primitives]]
|SeeAlso=[[Part_Primitives|Part Primitives]]
Line 33: Line 32:
==Usage== <!--T:3-->
==Usage== <!--T:3-->


<!--T:13-->
See [[Part_Primitives#Usage|Part Primitives]].
See [[Part_Primitives#Usage|Part Primitives]].


== Example ==
== Example == <!--T:14-->


<!--T:15-->
[[Image:Part_RegularPolygon_Scripting_Example.png|thumb|Part RegularPolygon from the scripting example]]
[[Image:Part_RegularPolygon_Scripting_Example.png|thumb|Part RegularPolygon from the scripting example]]


<!--T:16-->
A Part RegularPolygon object created with the [[#Scripting|scripting example]] below is shown here.
A Part RegularPolygon object created with the [[#Scripting|scripting example]] below is shown here.


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


<!--T:18-->
See also: [[Property_editor|Property editor]].
See also: [[Property_editor|Property editor]].


<!--T:19-->
A Part Regular polygon object is derived from a [[Part_Feature|Part Feature]] object and inherits all its properties. It also has the following additional properties:
A Part RegularPolygon object is derived from a [[Part_Feature|Part Feature]] object and inherits all its properties. It also has the following additional properties:


=== Data ===
=== Data === <!--T:20-->


<!--T:21-->
{{TitleProperty|Attachment}}

<!--T:22-->
The object has the same attachment properties as a [[Part_Part2DObject#Data|Part Part2DObject]].

<!--T:23-->
{{TitleProperty|Regular Polygon}}
{{TitleProperty|Regular Polygon}}


<!--T:24-->
* {{PropertyData|Polygon|Integer}}: The number of sides of the polygon which describes the cross section of the Part Prism
* {{PropertyData|Circumradius|Length}}: The circumradius is the distance from the centre of the polygon to a vertex.
* {{PropertyData|Polygon|IntegerConstraint}}: The number of sides of the polygon. The default is {{Value|6}}.
* {{PropertyData|Circumradius|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 {{Value|2mm}}.


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


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

<!--T:27-->
A Part RegularPolygon can be created with the {{Incode|addObject()}} method of the document:


</translate>
</translate>
{{Code|code=
{{Code|code=
regularPolygon = FreeCAD.ActiveDocument.addObject("Part::RegularPolygon", "myRegularPolygon")
poly = FreeCAD.ActiveDocument.addObject("Part::RegularPolygon", "myPolygon")
}}
}}
<translate>
<translate>


<!--T:28-->
* Where {{Incode|myRegularPolygon}} is the name for the object. The name must be unique for the entire document.
* Where {{Incode|"myPolygon"}} is the name for the object.
* The function returns the newly created object.
* The function returns the newly created object.


<!--T:29-->
The {{Incode|Label}} is the user editable name for the object. It can be easily changed by
Example:


</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD as App
regularPolygon.Label = "new myRegularPolygonName"

}}
doc = App.activeDocument()
<translate>


poly = doc.addObject("Part::RegularPolygon", "myPolygon")
You can access and modify attributes of the {{Incode|regularPolygon}} object. For example, you may wish to modify the length, width and height parameters.
poly.Polygon = 5
poly.Circumradius = 8
poly.Placement = App.Placement(App.Vector(1, 2, 3), App.Rotation(60, 30, 15))


doc.recompute()
</translate>
{{Code|code=
regularPolygon.Polygon = 5
regularPolygon.Circumradius = 8
}}
}}
<translate>
<translate>


You can change its placement and orientation with:

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


<!--T:12-->
<!--T:12-->
Line 103: Line 114:


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

Latest revision as of 12:16, 26 June 2023

Part RegularPolygon

Menu location
Part → Create primitives → Regular polygon
Workbenches
Part, OpenSCAD
Default shortcut
None
Introduced in version
0.14
See also
Part Primitives

Description

A Part RegularPolygon is a parametric shape that can be created with the Part Primitives command. In the coordinate system defined by its DataPlacement property, the polygon 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 RegularPolygon from the scripting example

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

Properties

See also: Property editor.

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

Regular Polygon

  • 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.

Scripting

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

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

poly = FreeCAD.ActiveDocument.addObject("Part::RegularPolygon", "myPolygon")
  • Where "myPolygon" is the name for the object.
  • The function returns the newly created object.

Example:

import FreeCAD as App

doc = App.activeDocument()

poly = doc.addObject("Part::RegularPolygon", "myPolygon")
poly.Polygon = 5
poly.Circumradius = 8
poly.Placement = App.Placement(App.Vector(1, 2, 3), App.Rotation(60, 30, 15))

doc.recompute()