Macro ArrayCopy: Difference between revisions
Renatorivo (talk | contribs) No edit summary |
(Use {{MacroCode}}) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
|||
{{Macro|Icon=Text-x-python|Name=ArrayCopy|Description=This macro copies the selected object several times, on an array grid|Author=Yorik|Version=1.0|Date=2014-05-04}} |
|||
|Name=ArrayCopy |
|||
|Icon=Macro_ArrayCopy.png |
|||
|Description=This macro copies the selected object several times, on an array grid You can define the number of rows and columns and the distance between them. |
|||
|Author=Yorik |
|||
|Version=1.0 |
|||
|Date=2014-05-04 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/9/9d/Macro_ArrayCopy.png ToolBar Icon] |
|||
}} |
|||
==Description== <!--T:2--> |
|||
This macro copies the selected object several times, on an array grid. You can define the number of rows and columns and the distance between them. |
This macro copies the selected object several times, on an array grid. You can define the number of rows and columns and the distance between them. |
||
==Script== <!--T:4--> |
|||
</translate> |
</translate> |
||
ToolBar Icon [[Image:Macro_ArrayCopy.png]] |
|||
'''Macro_ArrayCopy.FCMacro''' |
|||
⚫ | |||
⚫ | |||
import FreeCAD, FreeCADGui, Part |
import FreeCAD, FreeCADGui, Part |
Latest revision as of 00:59, 8 May 2020
Description |
---|
This macro copies the selected object several times, on an array grid You can define the number of rows and columns and the distance between them. Macro version: 1.0 Last modified: 2014-05-04 FreeCAD version: All Download: ToolBar Icon Author: Yorik |
Author |
Yorik |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.0 |
Date last modified |
2014-05-04 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
None |
Description
This macro copies the selected object several times, on an array grid. You can define the number of rows and columns and the distance between them.
Script
Macro_ArrayCopy.FCMacro
import FreeCAD, FreeCADGui, Part from PySide import QtGui,QtCore def proceed(): try: u = (int(l1.text()),float(l2.text())) v = (int(l3.text()),float(l4.text())) except: FreeCAD.Console.PrintError("Wrong input! Only numbers allowed...\n") sel = FreeCADGui.Selection.getSelection() if sel: sel = sel[0] name = sel.Name shape = sel.Shape for column in range(u[0]): for row in range(v[0]): if (column != 0) or (row != 0): delta = FreeCAD.Vector(column*u[1],row*v[1],0) newshape = sel.Shape.copy() newshape.translate(delta) newobject = FreeCAD.ActiveDocument.addObject("Part::Feature",name) newobject.Shape = newshape else: FreeCAD.Console.PrintError("Error: One object must be selected") hide() def hide(): dialog.hide() dialog = QtGui.QDialog() dialog.resize(200,300) dialog.setWindowTitle("Array") la = QtGui.QVBoxLayout(dialog) t1 = QtGui.QLabel("number of columns") la.addWidget(t1) l1 = QtGui.QLineEdit() la.addWidget(l1) t2 = QtGui.QLabel("distance between columns") la.addWidget(t2) l2 = QtGui.QLineEdit() la.addWidget(l2) t3 = QtGui.QLabel("number of rows") la.addWidget(t3) l3 = QtGui.QLineEdit() la.addWidget(l3) t4 = QtGui.QLabel("distance between rows") la.addWidget(t4) l4 = QtGui.QLineEdit() la.addWidget(l4) okbox = QtGui.QDialogButtonBox(dialog) okbox.setOrientation(QtCore.Qt.Horizontal) okbox.setStandardButtons(QtGui.QDialogButtonBox.Cancel