Draft Polygon: Difference between revisions

From FreeCAD Documentation
(More details)
Line 39: Line 39:


==Scripting== <!--T:7-->
==Scripting== <!--T:7-->
{{emphasis|See also:}} [[FreeCAD Scripting Basics]], [[Draft API]], and the [https://www.freecadweb.org/api autogenerated API documentation].
The Polygon tool can by used in [[macros]] and from the python console by using the following function:

The Polygon tool can be used in [[macros]] and from the [[Python]] console by using the following function:


</translate>
</translate>
{{Code|code=
{{Code|code=
makePolygon(nfaces,[radius],[inscribed],[placement],[face])
Polygon = makePolygon(nfaces, radius=1, inscribed=True, placement=None, face=None, support=None)
}}
}}
<translate>
<translate>
<!--T:8-->
<!--T:8-->
* Creates a polygon object with the given number of faces and the radius.
* Creates a {{incode|Polygon}} object with the given number of faces ({{incode|nfaces}}), and based on a circle of {{incode|radius}} in millimeters.
* If inscribed is False, the polygon is circumscribed around a circle with the given radius, otherwise it is inscribed.
* 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 in given.
* If face is True, the resulting shape is displayed as a face, otherwise as a wireframe.
* If a {{incode|placement}} is given, it is used.
* Returns the newly created object.
* If {{incode|face}} is {{incode|True}}, the polygon will make a face, that is, it will appear filled.


<!--T:9-->
<!--T:9-->
Line 56: Line 59:
</translate>
</translate>
{{Code|code=
{{Code|code=
import Draft
import FreeCAD, Draft

Draft.makePolygon(5,radius=3)
Polygon1 = Draft.makePolygon(4, radius=500)
Polygon2 = Draft.makePolygon(5, radius=750)

rotation90 = App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(0,0,1), 90))
Polygon3 = Draft.makePolygon(6, radius=1450, placement=rotation90)
}}
}}
{{clear}}
{{clear}}
[[Category:Draft]]

Revision as of 23:54, 6 November 2018

Draft Polygon

Menu location
Draft → Polygon
Workbenches
Draft, Arch
Default shortcut
P G
Introduced in version
-
See also
Draft Circle

Description

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 set on the Draft Tray.

How to use

  1. Press the Draft Polygon button, or press P then G keys.
  2. Click a first point on the 3D view, or type a coordinate to indicate the center.
  3. Adjust the desired number of sides in the options dialog.
  4. Click another point on 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.
  • Press 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 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).
  • Press Ctrl while drawing to force snapping your point to the nearest snap location, independently of the distance.
  • Press Shift while drawing to constrain your second point horizontally or vertically in relation to the first one.
  • Press Esc or the Cancel button to abort the current command.

Properties

Data

  • DataRadius: specifies the radius of the circle that defines the polygon
  • DataDraw Mode: specifies if the polygon is inscribed in a circle, or circumscribed around a circle.
  • DataFaces Number: specifies the number of sides of the polygon.
  • DataChamfer Size: specifies the size of the chamfers (straight segments) created on the corners of the polygon.
  • DataFillet Radius: specifies the radius of the fillets (arc segments) created on the corners of the wire.
  • DataMake Face: 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.

View

  • ViewPattern: specifies a Draft Pattern with which to fill the face of the polygon. This property only works if DataMake Face is true.
  • ViewPattern Size: specifies the size of the Draft Pattern.

Scripting

See also: FreeCAD Scripting Basics, Draft API, and the autogenerated API documentation.

The Polygon tool can be used in macros and from the Python console by using the following function:

Polygon = makePolygon(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.
    • One of the vertices of the polygon will lie on the X axis if no other placement in given.
  • If a placement is given, it is used.
  • If face is True, the polygon will make a face, that is, it will appear filled.

Example:

import FreeCAD, Draft

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

rotation90 = App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(0,0,1), 90))
Polygon3 = Draft.makePolygon(6, radius=1450, placement=rotation90)