Draft Array: Difference between revisions
(Code more complete) |
(Example of first part of the code) |
||
Line 76: | Line 76: | ||
<translate> |
<translate> |
||
<!--T:17--> |
<!--T:17--> |
||
* Creates an array |
* 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 rectangular array, {{incode|xvector}}, {{incode|yvector}}, and {{incode|zvector}} determine the distance between the base points of each copy, in the X, Y, and Z directions; and {{incode|xnum}}, {{incode|ynum}}, and {{incode|znum}} are the number of copies in the respective direction. |
|||
* In case of a polar array, {{incode|center}} defines the center of the array circle, {{incode|totalangle}} is the angle of the arc in degrees to cover with copies, and {{incode|totalnum}} is the number of copies to arrange around the circle, including the original object. |
|||
* {{incode|array_list}} is returned with the new copies. |
|||
** In case of a polar array, {{incode|center}} defines the center of the array circle, {{incode|totalangle}} is the angle of the arc in degrees to cover with copies, and {{incode|totalnum}} is the number of copies to arrange around the circle, including the original object. |
|||
** {{incode|array_list}} is either a single object or a list of objects, depending on the input {{incode|objectslist}}. |
|||
* This function internally uses the {{incode|move()}} function, so it creates standalone copies of the base objects. |
|||
This function internally uses {{incode|Draft.move()}} and {{incode|Draft.rotate()}} with <code>copy=True</code>. |
|||
Example: |
|||
{{Code|code= |
|||
import FreeCAD, Draft |
|||
Rect = Draft.makeRectangle(1500, 500) |
|||
array_list = Draft.array(Rect, FreeCAD.Vector(1600, 0, 0), FreeCAD.Vector(0, 600, 0), 3, 4) |
|||
}} |
|||
=== Parametric array === <!--T:8--> |
=== Parametric array === <!--T:8--> |
Revision as of 03:09, 15 November 2018
Draft Array |
Menu location |
---|
Draft → Array |
Workbenches |
Draft, Arch |
Default shortcut |
None |
Introduced in version |
- |
See also |
PathArray, Draft PointArray, Draft Clone |
Description
The Array tool creates an orthogonal (3-axes) or polar array from a selected object.
This tool can be used on 2D shapes created with the Draft Workbench but can also be used on many types of 3D objects such as those created with the Part Workbench or PartDesign Workbench.
To position copies along a path use Draft PathArray; to position copies at specified points use Draft PointArray; to create copies or clones, and manually place them use Draft Move, Draft Rotate, and Draft Clone.
How to use
- Select an object with which you wish to make an array.
- Press the Draft Array button. If no object is selected, you will be invited to select one.
- The Array object is immediately created. You must change the properties of the array to change the number and direction of copies 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.
Options
There are no options for this tool. Either it works with the selected object or not.
Properties
- DataBase: specifies the object to duplicate in the array.
- DataArray Type: specifies the type of array to create, either "ortho" or "polar".
- DataFuse: if it is
true
, and the copies intersect with each other, they will be fused together into a single shape.
For orthogonal arrays:
- DataInterval X: specifies the interval between each copy on the X axis.
- DataInterval Y: specifies the interval between each copy on the Y axis.
- DataInterval Z: specifies the interval between each copy on the Z axis.
- DataNumber X: specifies the number of copies on the X axis.
- DataNumber Y: specifies the number of copies on the Y axis.
- DataNumber Z: specifies the number of copies on the Z axis.
For polar arrays:
- DataAxis: specifies the normal direction of the array circle.
- DataCenter: specifies the center point of the array circle.
- DataAngle: specifies the aperture of the circular arc to cover with copies; use 360 to cover an entire circle.
- DataNumber Polar: specifies the number of copies to place in the circular arrangement.
- DataInterval Axis: specifies the interval between each copy on the DataAxis direction.
Scripting
See also: Draft API and FreeCAD Scripting Basics.
The Array tool can be used in macros and from the Python console by using two different functions, depending on if you wish to obtain standalone copies of your base object, or a parametric array object that stays linked to the original object.
Simple array
The base signature is
array_list = array(objectslist, arg1, arg2, arg3, arg4=None, arg5=None, arg6=None)
To create a rectangular array, use it like this:
array_list = array(objectslist, xvector, yvector, xnum, ynum)
array_list = array(objectslist, xvector, yvector, zvector, xnum, ynum, znum)
To create a polar array, use it like this:
array_list = array(objectslist, center, totalangle, totalnum)
- Creates an array from the objects contained in
objectslist
, which can be a single object or a list of objects. - In case of a rectangular array,
xvector
,yvector
, andzvector
determine the distance between the base points of each copy, in the X, Y, and Z directions; andxnum
,ynum
, andznum
are the number of copies in the respective direction. - In case of a polar array,
center
defines the center of the array circle,totalangle
is the angle of the arc in degrees to cover with copies, andtotalnum
is the number of copies to arrange around the circle, including the original object. array_list
is returned with the new copies.array_list
is either a single object or a list of objects, depending on the inputobjectslist
.
This function internally uses Draft.move()
and Draft.rotate()
with copy=True
.
Example:
import FreeCAD, Draft
Rect = Draft.makeRectangle(1500, 500)
array_list = Draft.array(Rect, FreeCAD.Vector(1600, 0, 0), FreeCAD.Vector(0, 600, 0), 3, 4)
Parametric array
For rectangular array:
makeArray (object,xvector,yvector,xnum,ynum,[name])
makeArray (object,xvector,yvector,zvector,xnum,ynum,znum,[name])
For polar array:
makeArray (object,center,totalangle,totalnum,[name])
- Creates an array of the given object with, in case of rectangular array, xnum of iterations in the x direction at xvector distance between iterations, and same for y direction with yvector and ynum, and for zvector and znum if that version is used. In case of polar array, center is a vector, totalangle is the angle to cover (in degrees) and totalnum is the number of objects, including the original.
- The result of this function is a parametric Draft Array object.
Example:
import FreeCAD,Draft
Draft.array(FreeCAD.ActiveDocument.ActiveObject,FreeCAD.Vector(2,0,0),FreeCAD.Vector(0,2,0),2,2)