Draft PolarArray: Difference between revisions

From FreeCAD Documentation
(Updated Scripting)
Line 137: Line 137:
<translate>
<translate>


== Scripting, non-parametric array == <!--T:27-->
=== Non-parametric array ===

<!--T:28-->
When using the {{Button|[[Image:Draft_PolarArray.svg|16px]] [[Draft_PolarArray|PolarArray]]}} tool, a parametric {{incode|"Array"}} object is created. This can be scripted as described in the previous section.


<!--T:29-->
<!--T:29-->
However, to obtain standalone copies of the base object, the simple {{incode|Draft.array}} function can be used. This will create simple copies, not a new parametric object.
To create a non-parametric polar array use the {{incode|array}} method of the Draft module. Note that this method returns {{incode|None}}.

<!--T:30-->
To create a polar array, use it like this:


</translate>
</translate>
{{Code|code=
{{Code|code=
array_list = array(objectslist, center, angle, number)
array(objectslist, center, angle, number)
}}
}}
<translate>
<translate>

<!--T:31-->
* Creates an array from the objects contained in {{incode|objectslist}}, which can be a single object or a list of objects.
** In case of a polar array, {{incode|center}} defines the center of the array circle, {{incode|angle}} is the angle of the arc in degrees to cover with copies, and {{incode|number}} is the number of copies to arrange on the circular arc, not including the original object.
** {{incode|array_list}} is returned with the new copies. It is either a single object or a list of objects, depending on the input {{incode|objectslist}}.

<!--T:32-->
This function internally uses {{incode|Draft.rotate()}} with <code>copy=True</code>.


<!--T:33-->
<!--T:33-->
Line 173: Line 159:


tri = Draft.make_polygon(3, 600)
tri = Draft.make_polygon(3, 600)
center = App.Vector(-3200, 0, 0)
center = App.Vector(-1600, 0, 0)


array_list = Draft.array(tri, center, 180, 5)
Draft.array(tri, center, 270, 8)
doc.recompute()
doc.recompute()
}}
}}

Revision as of 13:33, 23 May 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 PolarArray

Menu location
Modification → Array tools → Polar array
Workbenches
Draft
Default shortcut
None
Introduced in version
0.19
See also
Draft OrthoArray, Draft CircularArray, Draft PathArray, Draft PathLinkArray, Draft PointArray, Draft Clone

Description

The Draft PolarArray tool creates an array from a selected object placing the copies along a circumference.

This tool can be used on any object that has a Part TopoShape, meaning 2D shapes created with the Draft Workbench, but also 3D solids created with other workbenches, for example, Part, PartDesign, or Arch. It can also create App Links instead of simple copies.

A polar array of an object.

Usage

  1. Select the object that you wish to array.
  2. Press the Polar array button. If no object is selected, you will be invited to select one before proceeding.
  3. The task panel is launched where you can select the polar angle, the number of elements, and the center of the axis of rotation.
  4. You can click on the 3D view to simultaneously set the position of the center of rotation, and complete the command. Otherwise, just press Enter or the OK button to complete the operation.

Notes

  • By default, the axis of rotation is the positive Z axis (0, 0, 1). This can be changed in the property editor after the object is created.
  • Each element in the array is an exact clone of the original object, but the entire array is considered a single unit in terms of properties and appearance.
  • This command creates the same parametric "Array" object as the one created with the OrthoArray and CircularArray tools. Therefore, the array can be converted to orthogonal, polar, or circular by changing its DataArray Type property.

Options

These are the options displayed in the task panel.

  • Polar angle: the angle which determines where the last element of the array will be placed in the polar arrangement. The angle is positive in the counter-clockwise direction, and negative in the clockwise direction.
  • Number of elements: the number of elements in the array. Minimum of 2, maximum of 99.
  • Center of rotation: the coordinates through which the axis of rotation goes through.
  • Reset point: it resets the center of rotation to the origin (0, 0, 0).
  • Fuse: if it is checked, the resulting objects in the array will fuse together if they touch each other. This only works if Link array is unchecked.
  • Link array: if it is checked, the resulting array will be a "Link array". This array internally uses App Link objects, so it is more efficient when handling many copies of complex shapes. However, in this case, the objects cannot be fused together.
  • Press Esc or the Cancel button to abort the current command.

Note: if a Link array is created, this object cannot be converted to a regular array. And similarly, a regular array cannot be converted to a Link array. Therefore, you must choose the type of array that you want at creation time.

Properties

A PolarArray object internally is the same object produced with the OrthoArray tool. It is based on Part Feature (Part::Feature class), and thus shares all properties of the latter.

See the OrthoArray tool for the complete description of the properties. All properties apply, except for those under the Orthogonal array and Circular array groups.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

Parametric array

To create a parametric polar array use the make_array method (introduced in version 0.19) of the Draft module. This method replaces the deprecated makeArray method. The make_array method can create Draft OrthoArrays, Draft PolarArrays and Draft CircularArrays. For each array type one or more wrappers are available.

The main method:

array = make_array(base_object, arg1, arg2, arg3, arg4=None, arg5=None, arg6=None, use_link=True)

The wrapper for polar arrays is:

array = make_polar_array(base_object,
                         number=5, angle=360, center=App.Vector(0, 0, 0),
                         use_link=True)
  • base_object is the object to be arrayed. It can also be the Label (string) of an object in the current document.
  • number is the number of copies in the polar pattern, including the original object.
  • angle is the angle of the polar arc in degrees.
  • center is the vector that defines the center of the polar pattern.
  • If use_link is True the created copies will be App Links instead of regular copies.
  • array is returned with the created array object.

Example:

import FreeCAD as App
import Draft

doc = App.newDocument()

tri = Draft.make_polygon(3, 600)
center = App.Vector(-1600, 0, 0)

array = Draft.make_polar_array(tri, 8, 270, center)
doc.recompute()

Non-parametric array

To create a non-parametric polar array use the array method of the Draft module. Note that this method returns None.

array(objectslist, center, angle, number)

Example:

import FreeCAD as App
import Draft

doc = App.newDocument()

tri = Draft.make_polygon(3, 600)
center = App.Vector(-1600, 0, 0)

Draft.array(tri, center, 270, 8)
doc.recompute()