Skip to content

Commit

Permalink
Draft: move circular, ortho, and polar make functions
Browse files Browse the repository at this point in the history
Previously they were in `draftobjects`, but since they
don't define new objects, just create objects,
they are moved to `draftmake`.

Also ajust the `CMakeLists.txt` and the corresponding Gui Commands
which use these make functions.

These functions internally use the `Draft.makeArray` function.
We will put comments as reminders so that when this function
is moved to its own module, we can update the derived functions.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed May 18, 2020
1 parent 021b07b commit 681b33d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/Mod/Draft/CMakeLists.txt
Expand Up @@ -86,20 +86,23 @@ SET(Draft_make_functions
draftmake/make_block.py
draftmake/make_bspline.py
draftmake/make_circle.py
draftmake/make_circulararray.py
draftmake/make_clone.py
draftmake/make_copy.py
draftmake/make_drawingview.py
draftmake/make_ellipse.py
draftmake/make_facebinder.py
draftmake/make_fillet.py
draftmake/make_line.py
draftmake/make_orthoarray.py
draftmake/make_patharray.py
draftmake/make_polygon.py
draftmake/make_point.py
draftmake/make_pointarray.py
draftmake/make_polararray.py
draftmake/make_polygon.py
draftmake/make_rectangle.py
draftmake/make_shapestring.py
draftmake/make_shape2dview.py
draftmake/make_shapestring.py
draftmake/make_sketch.py
draftmake/make_wire.py
draftmake/make_wpproxy.py
Expand All @@ -113,14 +116,11 @@ SET(Draft_objects
draftobjects/bezcurve.py
draftobjects/block.py
draftobjects/bspline.py
draftobjects/circulararray.py
draftobjects/circle.py
draftobjects/clone.py
draftobjects/drawingview.py
draftobjects/ellipse.py
draftobjects/facebinder.py
draftobjects/orthoarray.py
draftobjects/polararray.py
draftobjects/draft_annotation.py
draftobjects/fillet.py
draftobjects/draftlink.py
Expand Down
7 changes: 7 additions & 0 deletions src/Mod/Draft/Draft.py
Expand Up @@ -338,6 +338,13 @@
from draftviewproviders.view_array import ViewProviderDraftArray
from draftviewproviders.view_array import _ViewProviderDraftArray

# from draftmake.make_circulararray import make_circular_array
# from draftmake.make_orthoarray import make_ortho_array
# from draftmake.make_orthoarray import make_ortho_array2d
# from draftmake.make_orthoarray import make_rect_array
# from draftmake.make_orthoarray import make_rect_array2d
# from draftmake.make_polararray import make_polar_array

# facebinder
from draftmake.make_facebinder import make_facebinder, makeFacebinder
from draftobjects.facebinder import Facebinder, _Facebinder
Expand Down
Expand Up @@ -20,13 +20,14 @@
# * USA *
# * *
# ***************************************************************************
"""Provides the object code for Draft CircularArray."""
## @package circulararray
"""Provides functions for creating circular arrays in a plane."""
## @package make_circulararray
# \ingroup DRAFT
# \brief This module provides the object code for Draft CircularArray.
# \brief Provides functions for creating circular arrays in a plane.

import FreeCAD as App
import Draft
# import draftmake.make_array as make_array
import draftutils.utils as utils
from draftutils.messages import _msg, _err
from draftutils.translate import _tr
Expand Down Expand Up @@ -141,6 +142,7 @@ def make_circular_array(obj,

_msg("use_link: {}".format(bool(use_link)))

# new_obj = make_array.make_array()
new_obj = Draft.makeArray(obj,
arg1=r_distance, arg2=tan_distance,
arg3=axis, arg4=center,
Expand Down
Expand Up @@ -20,13 +20,14 @@
# * USA *
# * *
# ***************************************************************************
"""Provide the object code for Draft Array."""
## @package orthoarray
"""Provides functions for creating orthogonal arrays in 2D and 3D."""
## @package make_orthoarray
# \ingroup DRAFT
# \brief Provide the object code for Draft Array.
# \brief Provides functions for creating orthogonal arrays in 2D and 3D.

import FreeCAD as App
import Draft
# import draftmake.make_array as make_array
import draftutils.utils as utils
from draftutils.messages import _msg, _wrn, _err
from draftutils.translate import _tr
Expand Down Expand Up @@ -179,6 +180,7 @@ def make_ortho_array(obj,

_msg("use_link: {}".format(bool(use_link)))

# new_obj = make_array.make_array()
new_obj = Draft.makeArray(obj,
arg1=v_x, arg2=v_y, arg3=v_z,
arg4=n_x, arg5=n_y, arg6=n_z,
Expand Down Expand Up @@ -273,6 +275,7 @@ def make_ortho_array2d(obj,

_msg("use_link: {}".format(bool(use_link)))

# new_obj = make_array.make_array()
new_obj = Draft.makeArray(obj,
arg1=v_x, arg2=v_y,
arg3=n_x, arg4=n_y,
Expand Down
Expand Up @@ -20,13 +20,14 @@
# * USA *
# * *
# ***************************************************************************
"""Provide the object code for Draft PolarArray."""
## @package polararray
"""Provides functions for creating polar arrays in a plane."""
## @package make_polararray
# \ingroup DRAFT
# \brief This module provides the object code for Draft PolarArray.
# \brief Provides functions for creating polar arrays in a plane.

import FreeCAD as App
import Draft
# import draftmake.make_array as make_array
import draftutils.utils as utils
from draftutils.messages import _msg, _err
from draftutils.translate import _tr
Expand Down Expand Up @@ -106,6 +107,7 @@ def make_polar_array(obj,

_msg("use_link: {}".format(bool(use_link)))

# new_obj = make_array.make_array()
new_obj = Draft.makeArray(obj,
arg1=center, arg2=angle, arg3=number,
use_link=use_link)
Expand Down
9 changes: 6 additions & 3 deletions src/Mod/Draft/drafttaskpanels/task_circulararray.py
Expand Up @@ -278,7 +278,7 @@ def create_object(self):
# of this class, the GuiCommand.
# This is needed to schedule geometry manipulation
# that would crash Coin3D if done in the event callback.
_cmd = "draftobjects.circulararray.make_circular_array"
_cmd = "DD.make_circular_array"
_cmd += "("
_cmd += "App.ActiveDocument." + sel_obj.Name + ", "
_cmd += "r_distance=" + str(self.r_distance) + ", "
Expand All @@ -290,8 +290,11 @@ def create_object(self):
_cmd += "use_link=" + str(self.use_link)
_cmd += ")"

_cmd_list = ["Gui.addModule('Draft')",
"Gui.addModule('draftobjects.circulararray')",
Gui.addModule('Draft')
Gui.addModule('draftmake.make_circulararray')

_cmd_list = ["# DD = Draft # in the future",
"DD = draftmake.make_circulararray",
"obj = " + _cmd,
"obj.Fuse = " + str(self.fuse),
"Draft.autogroup(obj)",
Expand Down
9 changes: 6 additions & 3 deletions src/Mod/Draft/drafttaskpanels/task_orthoarray.py
Expand Up @@ -248,7 +248,7 @@ def create_object(self):
# of this class, the GuiCommand.
# This is needed to schedule geometry manipulation
# that would crash Coin3D if done in the event callback.
_cmd = "draftobjects.orthoarray.make_ortho_array"
_cmd = "DD.make_ortho_array"
_cmd += "("
_cmd += "App.ActiveDocument." + sel_obj.Name + ", "
_cmd += "v_x=" + DraftVecUtils.toString(self.v_x) + ", "
Expand All @@ -260,8 +260,11 @@ def create_object(self):
_cmd += "use_link=" + str(self.use_link)
_cmd += ")"

_cmd_list = ["Gui.addModule('Draft')",
"Gui.addModule('draftobjects.orthoarray')",
Gui.addModule('Draft')
Gui.addModule('draftmake.make_orthoarray')

_cmd_list = ["# DD = Draft # in the future",
"DD = draftmake.make_orthoarray",
"obj = " + _cmd,
"obj.Fuse = " + str(self.fuse),
"Draft.autogroup(obj)",
Expand Down
9 changes: 6 additions & 3 deletions src/Mod/Draft/drafttaskpanels/task_polararray.py
Expand Up @@ -242,7 +242,7 @@ def create_object(self):
# of this class, the GuiCommand.
# This is needed to schedule geometry manipulation
# that would crash Coin3D if done in the event callback.
_cmd = "draftobjects.polararray.make_polar_array"
_cmd = "DD.make_polar_array"
_cmd += "("
_cmd += "App.ActiveDocument." + sel_obj.Name + ", "
_cmd += "number=" + str(self.number) + ", "
Expand All @@ -251,8 +251,11 @@ def create_object(self):
_cmd += "use_link=" + str(self.use_link)
_cmd += ")"

_cmd_list = ["Gui.addModule('Draft')",
"Gui.addModule('draftobjects.polararray')",
Gui.addModule('Draft')
Gui.addModule('draftmake.make_polararray')

_cmd_list = ["# DD = Draft # in the future",
"DD = draftmake.make_polararray",
"obj = " + _cmd,
"obj.Fuse = " + str(self.fuse),
"Draft.autogroup(obj)",
Expand Down

0 comments on commit 681b33d

Please sign in to comment.