23
"""Provides functions to create circular Array objects."""
31
import draftmake.make_array as make_array
32
import draftutils.utils as utils
34
from draftutils.messages import _err
35
from draftutils.translate import translate
38
def make_circular_array(base_object,
39
r_distance=100, tan_distance=50,
41
axis=App.Vector(0, 0, 1), center=App.Vector(0, 0, 0),
43
"""Create a circular array from the given object.
47
base_object: Part::Feature or str
48
Any of object that has a `Part::TopoShape` that can be duplicated.
49
This means most 2D and 3D objects produced with any workbench.
50
If it is a string, it must be the `Label` of that object.
51
Since a label is not guaranteed to be unique in a document,
52
it will use the first object found with this label.
54
r_distance: float, optional
56
Radial distance to the next ring of circular arrays.
58
tan_distance: float, optional
60
The tangential distance between two elements located
61
in the same circular ring.
62
The tangential distance together with the radial distance
63
determine how many copies are created.
67
The number of layers or rings of repeated objects.
68
The original object stays at the center, and is counted
69
as a layer itself. So, if you want at least one layer of circular
70
copies, this number must be at least 2.
72
symmetry: int, optional
74
It indicates how many lines of symmetry the entire circular pattern
75
has. That is, with 1, the array is symmetric only after a full
78
When it is 2, the array is symmetric at 0 and 180 degrees.
79
When it is 3, the array is symmetric at 0, 120, and 240 degrees.
80
When it is 4, the array is symmetric at 0, 90, 180, and 270 degrees.
83
axis: Base::Vector3, optional
84
It defaults to `App.Vector(0, 0, 1)` or the `+Z` axis.
85
The unit vector indicating the axis of rotation.
87
center: Base::Vector3, optional
88
It defaults to `App.Vector(0, 0, 0)` or the global origin.
89
The point through which the `axis` passes to define
92
use_link: bool, optional
93
It defaults to `True`.
94
If it is `True` the produced copies are not `Part::TopoShape` copies,
95
but rather `App::Link` objects.
96
The Links repeat the shape of the original `base_object` exactly,
97
and therefore the resulting array is more memory efficient.
99
Also, when `use_link` is `True`, the `Fuse` property
100
of the resulting array does not work; the array doesn't
101
contain separate shapes, it only has the original shape repeated
102
many times, so there is nothing to fuse together.
104
If `use_link` is `False` the original shape is copied many times.
105
In this case the `Fuse` property is able to fuse
106
all copies into a single object, if they touch each other.
111
A scripted object of type `'Array'`.
112
Its `Shape` is a compound of the copies of the original object.
115
If there is a problem it will return `None`.
119
make_ortho_array, make_polar_array, make_path_array, make_point_array
121
_name = "make_circular_array"
123
found, base_object = utils.find_object(base_object, doc=App.activeDocument())
125
_err(translate("draft","Wrong input: base_object not in document."))
129
utils.type_check([(r_distance, (int, float, App.Units.Quantity)),
130
(tan_distance, (int, float, App.Units.Quantity))],
133
_err(translate("draft","Wrong input: must be a number or quantity."))
137
utils.type_check([(number, int),
138
(symmetry, int)], name=_name)
140
_err(translate("draft","Wrong input: must be an integer number."))
144
utils.type_check([(axis, App.Vector),
145
(center, App.Vector)], name=_name)
147
_err(translate("draft","Wrong input: must be a vector."))
150
use_link = bool(use_link)
152
new_obj = make_array.make_array(base_object,
153
arg1=r_distance, arg2=tan_distance,
154
arg3=axis, arg4=center,
155
arg5=number, arg6=symmetry,