Draft Polygon: Difference between revisions

From FreeCAD Documentation
No edit summary
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Page_in_progress}}
<languages/>
<languages/>
<translate>
<translate>

<!--T:18-->
<!--T:18-->
{{Docnav
{{Docnav
|[[Draft_Ellipse|Ellipse]]
|[[Draft_Rectangle|Rectangle]]
|[[Draft_Rectangle|Rectangle]]
|[[Draft_BSpline|BSpline]]
|[[Draft_Module|Draft]]
|[[Draft_Module|Draft]]
|IconL=Draft_Ellipse.svg
|IconL=Draft_Rectangle.svg
|IconR=Draft_Rectangle.svg
|IconR=Draft_BSpline.svg
|IconC=Workbench_Draft.svg
|IconC=Workbench_Draft.svg
}}
}}
Line 14: Line 16:
{{GuiCommand
{{GuiCommand
|Name=Draft Polygon
|Name=Draft Polygon
|MenuLocation=Draft → Polygon
|MenuLocation=Drafting → Polygon
|Workbenches=[[Draft_Module|Draft]], [[Arch_Module|Arch]]
|Workbenches=[[Draft_Module|Draft]], [[Arch_Module|Arch]]
|Shortcut={{KEY|P}} {{KEY|G}}
|Shortcut={{KEY|P}} {{KEY|G}}
|Version=0.7
|Version=0.7
|SeeAlso=[[Draft_Circle|Draft Circle]], [[Draft_Pattern|Draft Pattern]]
}}
}}


Line 24: Line 25:


<!--T:2-->
<!--T:2-->
The Polygon tool creates a regular polygon inscribed in a circumference by picking two points, the center and the radius. It uses the [[Draft_Linestyle|Draft Linestyle]] set on the [[Draft_Tray|Draft Tray]].
The [[Image:Draft_Polygon.svg|24px]] [[Draft_Polygon|Draft Polygon]] command creates a regular polygon inscribed in a circle. It uses the [[Draft_Linestyle|Draft Linestyle]] set on the [[Draft_Tray|Draft Tray]].

<!--T:12-->
A Draft Polygon can be switched from inscribed to circumscribed by changing its {{PropertyData|Draw Mode}} property.


</translate>
</translate>
Line 35: Line 39:


<!--T:4-->
<!--T:4-->
# There are several ways to invoke the command:
# Press the {{Button|[[Image:Draft_Polygon.svg|16px]] [[Draft Polygon]]}} button, or press {{KEY|P}} then {{KEY|G}} keys.
#* Press the {{Button|[[Image:Draft_Polygon.svg|16px]] [[Draft_Polygon|Draft Polygon]]}} button.
# Adjust the desired number of sides in the options dialog.
#* Select the {{MenuCommand|Drafting → [[Image:Draft_Polygon.svg|16px]] Polygon}} option from the menu.
# Click a first point on the 3D view, or type a [[Draft_Coordinates|coordinate]] and press the {{Button|[[Image:Draft_AddPoint.svg|16px]] [[Draft_AddPoint|add point]]}} button.
#* Use the keyboard shortcut: {{KEY|P}} then {{KEY|G}}.
# Click another point on the 3D view, or type a radius value to define the polygon radius.
# Adjust the desired number of {{MenuCommand|Sides}} in the options dialog.
# Click the first point in the [[3D_view|3D view]], or type [[Draft_Coordinates|coordinates]] and press the {{Button|[[Image:Draft_AddPoint.svg|16px]] Enter point}} button.
# Click another point in the [[3D_view|3D view]], or type a {{MenuCommand|Radius}} value to define the polygon radius.


==Options==
<!--T:11-->
The polygon can be edited by double clicking on the element in the tree view, or by pressing the {{Button|[[Image:Draft Edit.svg|16px]] [[Draft Edit]]}} button. Then you can move the center and radius points to a new position.


<!--T:12-->
<!--T:5-->
* To enter coordinates manually, simply enter the numbers, then press {{KEY|Enter}} between each X, Y and Z component. You can press the {{Button|[[Image:Draft_AddPoint.svg|16px]] Enter point}} button when you have the desired values to insert the point.
The polygon is created inscribed in a circle of the specified radius; it can be switched to circumscribed after creation by changing its draw mode property.
* Press {{KEY|T}} or click the checkbox to toggle ''continue'' mode. If continue mode is on, the Polygon command will restart after you finish it, allowing you to draw another one without pressing the command button again.

<!--T:13-->
The number of sides of the polygon can also be changed after creation by changing its faces number property.

==Options== <!--T:5-->
* To enter coordinates manually, simply enter the numbers, then press {{KEY|Enter}} between each X, Y and Z component. You can press the {{Button|[[Image:Draft_AddPoint.svg|16px]] [[Draft_AddPoint|add point]]}} button when you have the desired values to insert the point.
* Press {{KEY|T}} or click the checkbox to toggle ''continue'' mode. If continue mode is on, the Polygon tool will restart after you finish it, allowing you to draw another one without pressing the tool button again.
* Press {{KEY|L}} or click the checkbox to toggle ''filled'' mode. If filled mode is on, the polygon will create a filled face ({{PropertyData|Make Face}} {{TRUE}}); if not, the polygon will not make a face ({{PropertyData|Make Face}} {{FALSE}}).
* Press {{KEY|L}} or click the checkbox to toggle ''filled'' mode. If filled mode is on, the polygon will create a filled face ({{PropertyData|Make Face}} {{TRUE}}); if not, the polygon will not make a face ({{PropertyData|Make Face}} {{FALSE}}).
* Hold {{KEY|Ctrl}} while drawing to force [[Draft_Snap|snapping]] your point to the nearest snap location, independently of the distance.
* Hold {{KEY|Ctrl}} while drawing to force [[Draft_Snap|snapping]] your point to the nearest snap location, independently of the distance.
* Hold {{KEY|Shift}} while drawing to [[Draft_Constrain|constrain]] your second point horizontally or vertically in relation to the first one.
* Hold {{KEY|Shift}} while drawing to [[Draft_Constrain|constrain]] your second point horizontally or vertically in relation to the first one.
* Press {{KEY|Esc}} or the {{Button|Close}} button to abort the current command.
* Press {{KEY|Esc}} or the {{Button|Close}} button to abort the current command.

==Notes==

<!--T:11-->
* A Draft Polygon can be edited with the [[Draft_Edit|Draft Edit]] command.


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


See also: [[property_editor|Property editor]].
===Data=== <!--T:14-->
* {{PropertyData|Radius}}: specifies the radius of the circle that defines the polygon.
* {{PropertyData|Draw Mode}}: specifies if the polygon is inscribed in a circle, or circumscribed around a circle.
* {{PropertyData|Faces Number}}: specifies the number of sides of the polygon.
* {{PropertyData|Chamfer Size}}: specifies the size of the chamfers (straight segments) created on the corners of the polygon.
* {{PropertyData|Fillet Radius}}: specifies the radius of the fillets (arc segments) created on the corners of the polygon.
* {{PropertyData|Make Face}}: specifies if the shape makes a face or not. If it is {{TRUE}} a face is created, otherwise only the perimeter is considered part of the object.


A Draft Polygon object is derived from a [[Part_Part2DObject|Part Part2DObject]] and inherits all its properties. It also has the following additional properties:
===View=== <!--T:15-->
* {{PropertyView|Pattern}}: specifies a [[Draft Pattern]] with which to fill the face of the polygon. This property only works if {{PropertyData|Make Face}} is {{TRUE}}, and if {{PropertyView|Display Mode}} is "Flat Lines".
* {{PropertyView|Pattern Size}}: specifies the size of the [[Draft Pattern]].


===Data===
==Scripting== <!--T:7-->

{{Emphasis|See also:}} [[Draft API]] and [[FreeCAD Scripting Basics]].
{{TitleProperty|Draft}}

<!--T:14-->
* {{PropertyData|Area|Area}}: (read-only) specifies the area of the face of the polygon. The value will be {{value|0.0}} if {{PropertyData|Make Face}} if {{FALSE}}.
* {{PropertyData|Chamfer Size|Length}}: specifies the length of the chamfers at the corners of the polygon.
* {{PropertyData|Draw Mode|Enumeration}}: specifies if the polygon is {{value|inscribed}} in a circle or {{value|circumscribed}} around a circle.
* {{PropertyData|Faces Number|Integer}}: specifies the number of sides of the polygon.
* {{PropertyData|Fillet Radius|Length}}: specifies the radius of the fillets at the corners of the polygon.
* {{PropertyData|Make Face|Bool}}: specifies if the polygon makes a face or not. If it is {{TRUE}} a face is created, otherwise only the perimeter is considered part of the object.
* {{PropertyData|Radius|Length}}: specifies the radius of the circle that defines the polygon.

===View===

{{TitleProperty|Draft}}

<!--T:15-->
* {{PropertyView|Pattern|Enumeration}}: specifies the [[Draft_Pattern|Draft Pattern]] with which to fill the face of the polygon. This property only works if {{PropertyData|Make Face}} is {{TRUE}} and if {{PropertyView|Display Mode}} is {{value|Flat Lines}}.
* {{PropertyView|Pattern Size|Float}}: specifies the size of the [[Draft_Pattern|Draft Pattern]].

==Scripting==

<!--T:7-->
See also: [https://www.freecadweb.org/api Autogenerated API documentation] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].


<!--T:16-->
<!--T:16-->
To create a Draft Polygon use the {{incode|make_polygon}} method ({{Version|0.19}}) of the Draft module. This method replaces the deprecated {{incode|makePolygon}} method.
The Polygon tool can be used in [[macros]] and from the [[Python]] console by using the following function:


</translate>
</translate>
{{Code|code=
{{Code|code=
Polygon = makePolygon(nfaces, radius=1, inscribed=True, placement=None, face=None, support=None)
polygon = make_polygon(nfaces, radius=1, inscribed=True, placement=None, face=None, support=None)
}}
}}
<translate>
<translate>
<!--T:8-->
<!--T:8-->
* Creates a {{incode|Polygon}} object with the given number of faces ({{incode|nfaces}}), and based on a circle of {{incode|radius}} in millimeters.
* Creates a {{incode|polygon}} object with the given number of faces ({{incode|nfaces}}), and based on a circle of {{incode|radius}} in millimeters.
* If {{incode|inscribed}} is {{incode|True}}, the polygon is inscribed in the circle, otherwise it will be circumscribed.
* If {{incode|inscribed}} is {{incode|True}}, the polygon is inscribed in the circle, otherwise it will be circumscribed.
** One of the vertices of the polygon will lie on the X axis if no other placement is given.
* If {{incode|placement}} is {{incode|None}} the shape is created at the origin and one of its vertices will lie on the X axis.
* If a {{incode|placement}} is given, it is used; otherwise the shape is created at the origin.
* If {{incode|face}} is {{incode|True}}, the shape will make a face, that is, it will appear filled.
* If {{incode|face}} is {{incode|True}}, the shape will make a face, that is, it will appear filled.


Line 93: Line 112:
</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD, Draft
import FreeCAD as App
import Draft


doc = App.newDocument()
Polygon1 = Draft.makePolygon(4, radius=500)
Polygon2 = Draft.makePolygon(5, radius=750)


polygon1 = Draft.make_polygon(4, radius=500)
ZAxis = FreeCAD.Vector(0, 0, 1)
polygon2 = Draft.make_polygon(5, radius=750)
p3 = FreeCAD.Vector(1000, 1000, 0)
place3 = FreeCAD.Placement(p3, FreeCAD.Rotation(ZAxis, 90))


zaxis = App.Vector(0, 0, 1)
Polygon3 = Draft.makePolygon(6, radius=1450, placement=place3)
p3 = App.Vector(1000, 1000, 0)
place3 = App.Placement(p3, App.Rotation(zaxis, 90))

Polygon3 = Draft.make_polygon(6, radius=1450, placement=place3)

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



<!--T:17-->
<!--T:17-->
{{Docnav
{{Docnav
|[[Draft_Ellipse|Ellipse]]
|[[Draft_Rectangle|Rectangle]]
|[[Draft_Rectangle|Rectangle]]
|[[Draft_BSpline|BSpline]]
|[[Draft_Module|Draft]]
|[[Draft_Module|Draft]]
|IconL=Draft_Ellipse.svg
|IconL=Draft_Rectangle.svg
|IconR=Draft_Rectangle.svg
|IconR=Draft_BSpline.svg
|IconC=Workbench_Draft.svg
|IconC=Workbench_Draft.svg
}}
}}
Line 119: Line 144:
{{Draft Tools navi{{#translation:}}}}
{{Draft Tools navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{clear}}

Revision as of 09:21, 30 March 2021

This documentation is a work in progress. Please don't mark it as translatable since it will change in the next hours and days.

Draft Polygon

Menu location
Drafting → Polygon
Workbenches
Draft, Arch
Default shortcut
P G
Introduced in version
0.7
See also
None

Description

The Draft Polygon command creates a regular polygon inscribed in a circle. It uses the Draft Linestyle set on the Draft Tray.

A Draft Polygon can be switched from inscribed to circumscribed by changing its DataDraw Mode property.

Regular polygon defined by the center point and the radius

Usage

  1. There are several ways to invoke the command:
    • Press the Draft Polygon button.
    • Select the Drafting → Polygon option from the menu.
    • Use the keyboard shortcut: P then G.
  2. Adjust the desired number of Sides in the options dialog.
  3. Click the first point in the 3D view, or type coordinates and press the Enter point button.
  4. Click another point in the 3D view, or type a Radius value to define the polygon radius.

Options

  • To enter coordinates manually, simply enter the numbers, then press Enter between each X, Y and Z component. You can press the Enter point button when you have the desired values to insert the point.
  • Press T or click the checkbox to toggle continue mode. If continue mode is on, the Polygon command will restart after you finish it, allowing you to draw another one without pressing the command button again.
  • Press L or click the checkbox to toggle filled mode. If filled mode is on, the polygon will create a filled face (DataMake Face true); if not, the polygon will not make a face (DataMake Face false).
  • Hold Ctrl while drawing to force snapping your point to the nearest snap location, independently of the distance.
  • Hold Shift while drawing to constrain your second point horizontally or vertically in relation to the first one.
  • Press Esc or the Close button to abort the current command.

Notes

  • A Draft Polygon can be edited with the Draft Edit command.

Properties

See also: Property editor.

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

Data

Draft

  • DataArea (Area): (read-only) specifies the area of the face of the polygon. The value will be 0.0 if DataMake Face if false.
  • DataChamfer Size (Length): specifies the length of the chamfers at the corners of the polygon.
  • DataDraw Mode (Enumeration): specifies if the polygon is inscribed in a circle or circumscribed around a circle.
  • DataFaces Number (Integer): specifies the number of sides of the polygon.
  • DataFillet Radius (Length): specifies the radius of the fillets at the corners of the polygon.
  • DataMake Face (Bool): specifies if the polygon makes a face or not. If it is true a face is created, otherwise only the perimeter is considered part of the object.
  • DataRadius (Length): specifies the radius of the circle that defines the polygon.

View

Draft

  • ViewPattern (Enumeration): specifies the Draft Pattern with which to fill the face of the polygon. This property only works if DataMake Face is true and if ViewDisplay Mode is Flat Lines.
  • ViewPattern Size (Float): specifies the size of the Draft Pattern.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

To create a Draft Polygon use the make_polygon method (introduced in version 0.19) of the Draft module. This method replaces the deprecated makePolygon method.

polygon = make_polygon(nfaces, radius=1, inscribed=True, placement=None, face=None, support=None)
  • Creates a polygon object with the given number of faces (nfaces), and based on a circle of radius in millimeters.
  • If inscribed is True, the polygon is inscribed in the circle, otherwise it will be circumscribed.
  • If placement is None the shape is created at the origin and one of its vertices will lie on the X axis.
  • If face is True, the shape will make a face, that is, it will appear filled.

Example:

import FreeCAD as App
import Draft

doc = App.newDocument()

polygon1 = Draft.make_polygon(4, radius=500)
polygon2 = Draft.make_polygon(5, radius=750)

zaxis = App.Vector(0, 0, 1)
p3 = App.Vector(1000, 1000, 0)
place3 = App.Placement(p3, App.Rotation(zaxis, 90))

Polygon3 = Draft.make_polygon(6, radius=1450, placement=place3)

doc.recompute()