| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | """Provides functions to create Array objects. |
| | |
| | This includes orthogonal arrays, polar arrays, and circular arrays. |
| | """ |
| | |
| | |
| | |
| |
|
| | |
| | |
| | import FreeCAD as App |
| | import draftutils.utils as utils |
| | import draftutils.gui_utils as gui_utils |
| |
|
| | from draftutils.messages import _wrn, _err |
| | from draftutils.translate import translate |
| | from draftobjects.array import Array |
| |
|
| | if App.GuiUp: |
| | from draftviewproviders.view_array import ViewProviderDraftArray |
| | from draftviewproviders.view_draftlink import ViewProviderDraftLink |
| |
|
| |
|
| | def make_array(base_object, arg1, arg2, arg3, arg4=None, arg5=None, arg6=None, use_link=True): |
| | """Create a Draft Array of the given object. |
| | |
| | Rectangular array |
| | ----------------- |
| | make_array(object, xvector, yvector, xnum, ynum) |
| | make_array(object, xvector, yvector, zvector, xnum, ynum, znum) |
| | |
| | xnum of iterations in the x direction |
| | at xvector distance between iterations, same for y direction |
| | with yvector and ynum, same for z direction with zvector and znum. |
| | |
| | Polar array |
| | ----------- |
| | make_array(object, center, totalangle, totalnum) for polar array, or |
| | |
| | center is a vector, totalangle is the angle to cover (in degrees) |
| | and totalnum is the number of objects, including the original. |
| | |
| | Circular array |
| | -------------- |
| | make_array(object, rdistance, tdistance, axis, center, ncircles, symmetry) |
| | |
| | In case of a circular array, rdistance is the distance of the |
| | circles, tdistance is the distance within circles, axis the rotation-axis, |
| | center the center of rotation, ncircles the number of circles |
| | and symmetry the number of symmetry-axis of the distribution. |
| | |
| | To Do |
| | ----- |
| | The `Array` class currently handles three types of arrays, |
| | orthogonal, polar, and circular. In the future, probably they should be |
| | split in separate classes so that they are easier to manage. |
| | """ |
| | found, doc = utils.find_doc(App.activeDocument()) |
| | if not found: |
| | _err(translate("draft", "No active document. Aborting.")) |
| | return None |
| |
|
| | if use_link: |
| | |
| | |
| | new_obj = doc.addObject("Part::FeaturePython", "Array", Array(None), None, True) |
| | else: |
| | new_obj = doc.addObject("Part::FeaturePython", "Array") |
| | Array(new_obj) |
| |
|
| | new_obj.Base = base_object |
| | if arg6: |
| | if isinstance(arg1, (int, float, App.Units.Quantity)): |
| | new_obj.ArrayType = "circular" |
| | new_obj.RadialDistance = arg1 |
| | new_obj.TangentialDistance = arg2 |
| | new_obj.Axis = arg3 |
| | new_obj.Center = arg4 |
| | new_obj.NumberCircles = arg5 |
| | new_obj.Symmetry = arg6 |
| | else: |
| | new_obj.ArrayType = "ortho" |
| | new_obj.IntervalX = arg1 |
| | new_obj.IntervalY = arg2 |
| | new_obj.IntervalZ = arg3 |
| | new_obj.NumberX = arg4 |
| | new_obj.NumberY = arg5 |
| | new_obj.NumberZ = arg6 |
| | elif arg4: |
| | new_obj.ArrayType = "ortho" |
| | new_obj.IntervalX = arg1 |
| | new_obj.IntervalY = arg2 |
| | new_obj.NumberX = arg3 |
| | new_obj.NumberY = arg4 |
| | else: |
| | new_obj.ArrayType = "polar" |
| | new_obj.Center = arg1 |
| | new_obj.Angle = arg2 |
| | new_obj.NumberPolar = arg3 |
| |
|
| | if App.GuiUp: |
| | if use_link: |
| | ViewProviderDraftLink(new_obj.ViewObject) |
| | else: |
| | if new_obj.ArrayType == "circular": |
| | new_obj.Proxy.execute( |
| | new_obj |
| | ) |
| | ViewProviderDraftArray(new_obj.ViewObject) |
| | gui_utils.format_object(new_obj, new_obj.Base) |
| | new_obj.ViewObject.Proxy.resetColors(new_obj.ViewObject) |
| | new_obj.Base.ViewObject.hide() |
| | gui_utils.select(new_obj) |
| |
|
| | return new_obj |
| |
|
| |
|
| | def makeArray( |
| | baseobject, arg1, arg2, arg3, arg4=None, arg5=None, arg6=None, name="Array", use_link=False |
| | ): |
| | """Create an Array. DEPRECATED. Use 'make_array'.""" |
| | _wrn( |
| | "Do not use this function directly; instead, use " |
| | "'make_ortho_array', 'make_polar_array', " |
| | "or 'make_circular_array'." |
| | ) |
| |
|
| | return make_array(baseobject, arg1, arg2, arg3, arg4, arg5, arg6, use_link) |
| |
|
| |
|
| | |
| |
|