Macro CloneConvert: Difference between revisions

From FreeCAD Documentation
(ver 0.6 correction placement with many objets Copy)
(ver 0.7 rewriting code with Placement and Increment and adding buttons Compound, Increment, ValueAt(),)
Line 52: Line 52:
[[File:Macro CloneConvert_01.png|220px|left|CloneConvert]]
[[File:Macro CloneConvert_01.png|220px|left|CloneConvert]]
* '''Mode'''
* '''Mode'''
* '''Clone :''' One clone of the objet(s) is create
* '''Clone :''' One clone of the objet(s) is create
* '''Copy :''' One copy of the objet(s) is create
* '''Copy :''' One copy of the objet(s) is create
* '''Comp :''' One compound of the objet(s) is create
* '''Increm. :''' incrementing the coordinates data to the original coordinates of the object (Placement, Rotation ...)<br />If this is not checked the Placement begin in coordinates 0,0,0 of FreeCAD<br />In case a compound Placement information is [0,0,0] the Placement begin in the position of object<br />If the real location is away from the base coordinates 0,0,0 use the {{KEY|ValueAt()}} button<br />for the real Placement of the subObject selected Face, Wire, Line ....
*
*
* '''{{KEY|...}} :''' This button align the YZ values on the value of X to have the same values ​​XYZ (or manually)<br />The second click reset the coordinates values to 0.0
* '''Coordinate X :''' Move the copy to the Coordinate X selected
* '''Coordinate Y :''' Move the copy to the Coordinate Y selected
* '''Coordinate X :''' Move the copy to the Coordinate X selected (Base 0,0,0 if Increm. is not checked)
* '''Coordinate Z :''' Move the copy to the Coordinate Z selected
* '''Coordinate Y :''' Move the copy to the Coordinate Y selected (Base 0,0,0 if Increm. is not checked)
* '''Coordinate Z :''' Move the copy to the Coordinate Z selected (Base 0,0,0 if Increm. is not checked)
*
*
* '''Rotation'''
* '''Rotation'''
* '''{{KEY|...}} :''' This button align the Pitch and Roll values on the value of Yaw to have the same values ​​Rotation (or manually)<br />The second click reset the rotations values to 0.0
* '''Yaw (Z ) :''' Rotate the copy to the axis Z (Yaw)
* '''Pitch ( Y ) :''' Rotate the copy to the axis Y (Pitch)
* '''Yaw (Z ) :''' Rotate the copy to the axis Z (Yaw) (Begin 0 if Increm. is not checked)
* '''Roll ( X ) :''' Rotate the copy to the axis X (Roll)
* '''Pitch ( Y ) :''' Rotate the copy to the axis Y (Pitch) (Begin 0 if Increm. is not checked)
* '''Roll ( X ) :''' Rotate the copy to the axis X (Roll) (Begin 0 if Increm. is not checked)
*
*
* '''Scale predefined'''
* '''Scale predefined'''
Line 68: Line 72:
*
*
* '''Scale free'''
* '''Scale free'''
* '''{{KEY|...}} :''' This button align the Scales values on the value of Scale X to have the same values ​​XYZ (or manually)<br />The second click reset the scales values to 1.0
* '''Scale X :''' free scale , if the value is negative '''( -10)''' , the object is scaled '''x 10''' and will be reversed in the X axis, to reduce the shape give a decimal value '''(0,5)'''
* '''Scale X :''' free scale , if the value is negative '''( -10)''' , the object is scaled '''x 10''' and will be reversed in the X axis, to reduce the shape give a decimal value '''(0,5)'''
* '''{{KEY|...}} :''' This button align the YZ values on the value of X to have the same values ​​XYZ (or manually)
* '''Scale Y :''' free scale , if the value is negative '''( -10)''' , the object is scaled '''x 10''' and will be reversed in the Y axis, to reduce the shape give a decimal value '''(0,5)'''
* '''Scale Y :''' free scale , if the value is negative '''( -10)''' , the object is scaled '''x 10''' and will be reversed in the Y axis, to reduce the shape give a decimal value '''(0,5)'''
* '''Scale Z :''' free scale , if the value is negative '''( -10)''' , the object is scaled '''x 10''' and will be reversed in the Z axis, to reduce the shape give a decimal value '''(0,5)'''
* '''Scale Z :''' free scale , if the value is negative '''( -10)''' , the object is scaled '''x 10''' and will be reversed in the Z axis, to reduce the shape give a decimal value '''(0,5)'''
*
*
* '''{{KEY|ValueAt()}} :''' Give the valueAt() the subObject selected Face, Wire, Line ...<br />This option is useful in case a compound Placement information [0,0,0] and its real location is away from the base coordinates 0,0,0<br />(gives no provide information about the rotation of the object)
* '''{{KEY|Ok}} :''' the OK button validates and launches the command, if no object is selected the {{KEY|Ok}} button will be colored in red
* '''{{KEY|Ok}} :''' the OK button validates and launches the command, if no object is selected the {{KEY|Ok}} button will be colored in red
* '''{{KEY|Reset}} :''' the Reset button puts all the values to zero
* '''{{KEY|Reset}} :''' the Reset button puts all the values to zero
Line 112: Line 117:
# ver 0.5 26/07/2015 correction rotation plusieurs objets Copy
# ver 0.5 26/07/2015 correction rotation plusieurs objets Copy
# ver 0.6 26/01/2016 correction placement avec plusieurs objets Copy
# ver 0.6 26/01/2016 correction placement avec plusieurs objets Copy
# ver 0.7 30/01/2016 reecriture du code avec Placement et ajout Increment et de boutons
__title__ = "CloneConvert"
__title__ = "CloneConvert"
__author__ = "mario52"
__author__ = "mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.06"
__version__ = "00.07"
__date__ = "26/01/2016"
__date__ = "30/01/2016"


__Comment__ = "This macro creates Copy or Clone of object(s)"
__Comment__ = "This macro creates Clone or Copy or Compound of object(s)"
__Web__ = "http://www.freecadweb.org/"
__Web__ = "http://www.freecadweb.org/"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_CloneConvert"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_CloneConvert"
Line 133: Line 139:
import PyQt4 # PyQt4
import PyQt4 # PyQt4
from PyQt4 import QtCore, QtGui # PyQt4
from PyQt4 import QtCore, QtGui # PyQt4
# print "PyQt4"


except Exception:
except Exception:
import PySide # PySide
import PySide # PySide
from PySide import QtCore, QtGui # PySide
from PySide import QtCore, QtGui # PySide
# print "PySide"

import Draft, Part, FreeCAD, math, PartGui, FreeCADGui
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui
from math import sqrt, pi, sin, cos, asin
from math import sqrt, pi, sin, cos, asin
Line 149: Line 158:
def _fromUtf8(s):
def _fromUtf8(s):
return s
return s

try:
try:
Line 175: Line 183:
global placement_Y ; placement_Y = 0.0
global placement_Y ; placement_Y = 0.0
global placement_Z ; placement_Z = 0.0
global placement_Z ; placement_Z = 0.0
global oripl_X ; oripl_X = 0.0
global oripl_Y ; oripl_Y = 0.0
global oripl_Z ; oripl_Z = 0.0
global Yaw_Z ; Yaw_Z = 0.0
global Yaw_Z ; Yaw_Z = 0.0
global Pitch_Y ; Pitch_Y = 0.0
global Pitch_Y ; Pitch_Y = 0.0
global Roll_X ; Roll_X = 0.0
global Roll_X ; Roll_X = 0.0

global switchP ; switchP = 0
global switchA ; switchA = 0
global switchS ; switchS = 0


global sel ; sel = ""
global sel ; sel = ""
Line 195: Line 204:
self.window = MainWindow
self.window = MainWindow
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(230, 520)
MainWindow.resize(230, 549)
MainWindow.setMinimumSize(QtCore.QSize(230, 549))
MainWindow.setMaximumSize(QtCore.QSize(230, 549))
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
Line 224: Line 235:
self.label_3.setGeometry(QtCore.QRect(10, 80, 91, 16))
self.label_3.setGeometry(QtCore.QRect(10, 80, 91, 16))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QtGui.QLabel(self.groupBox)
self.label_4.setGeometry(QtCore.QRect(10, 110, 91, 16))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(self.groupBox)
self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(self.groupBox)
Line 244: Line 259:
self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3"))
self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3"))
self.doubleSpinBox_3.valueChanged.connect(self.on_doubleSpinBox_3_valueChanged) #connection doubleSpinBox_3
self.doubleSpinBox_3.valueChanged.connect(self.on_doubleSpinBox_3_valueChanged) #connection doubleSpinBox_3
self.label_4 = QtGui.QLabel(self.groupBox)
self.label_4.setGeometry(QtCore.QRect(10, 110, 91, 16))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.radioButton = QtGui.QRadioButton(self.groupBox)
self.radioButton = QtGui.QRadioButton(self.groupBox)
self.radioButton.setGeometry(QtCore.QRect(10, 20, 71, 20))
self.radioButton.setGeometry(QtCore.QRect(10, 20, 51, 20))
self.radioButton.setChecked(True)
self.radioButton.setChecked(True)
self.radioButton.setObjectName(_fromUtf8("radioButton"))
self.radioButton.setObjectName(_fromUtf8("radioButton"))
Line 257: Line 268:
self.radioButton_2 = QtGui.QRadioButton(self.groupBox)
self.radioButton_2 = QtGui.QRadioButton(self.groupBox)
self.radioButton_2.setGeometry(QtCore.QRect(100, 20, 71, 20))
self.radioButton_2.setGeometry(QtCore.QRect(58, 20, 51, 20))
self.radioButton_2.setObjectName(_fromUtf8("radioButton_2"))
self.radioButton_2.setObjectName(_fromUtf8("radioButton_2"))
self.radioButton_2.setToolTip(_translate("MainWindow", "Create a copy of the object(s)", None))
self.radioButton_2.setToolTip(_translate("MainWindow", "Create a copy of the object(s)", None))
self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked) #connection radioButton_2 mode copy
self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked) #connection radioButton_2 mode copy
self.radioButton_3 = QtGui.QRadioButton(self.groupBox)
self.radioButton_3.setGeometry(QtCore.QRect(105, 20, 51, 20))
self.radioButton_3.setObjectName(_fromUtf8("radioButton_3"))
self.radioButton_3.setToolTip(_translate("MainWindow", "Create a compount of the object(s)", None))
self.radioButton_3.clicked.connect(self.on_radioButton_3_clicked) #connection radioButton_3 mode compount
self.checkBox = QtGui.QCheckBox(self.groupBox)
self.checkBox.setGeometry(QtCore.QRect(155, 20, 61, 20))
self.checkBox.setChecked(True)
self.checkBox.setToolTip(_translate("MainWindow", "Apply incremental changes to object Placement (Defaut)\n"+
"If this is not checked the Placement begin in coordinates 0,0,0 of FreeCAD\n"+
"In case a compound Placement information is [0,0,0] the Placement begin in the position of object\n"+
"If the real location is away from the base coordinates 0,0,0 use the ValueAt() button\n"
"for the real Placement of the subObject selected Face, Wire, Line ....", None))
self.checkBox.setObjectName(_fromUtf8("checkBox"))

self.pushButton_5 = QtGui.QPushButton(self.groupBox)
self.pushButton_5.setGeometry(QtCore.QRect(75, 50, 21, 22))
self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
self.pushButton_5.clicked.connect(self.on_pushButton_5_clicked) # connect on def "on_pushButton_5_clicked"

self.groupBox_2 = QtGui.QGroupBox(self.centralWidget)
self.groupBox_2 = QtGui.QGroupBox(self.centralWidget)
self.groupBox_2.setGeometry(QtCore.QRect(10, 300, 211, 51))
self.groupBox_2.setGeometry(QtCore.QRect(10, 300, 211, 51))
Line 304: Line 336:
self.doubleSpinBox_4.setProperty("value", 1.0)
self.doubleSpinBox_4.setProperty("value", 1.0)
self.doubleSpinBox_4.setObjectName(_fromUtf8("doubleSpinBox_4"))
self.doubleSpinBox_4.setObjectName(_fromUtf8("doubleSpinBox_4"))
self.doubleSpinBox_4.setToolTip(_translate("MainWindow", "Scale free X multiplied by ...", None))
self.doubleSpinBox_4.setToolTip(_translate("MainWindow", "Scale free X multiplied by ...\nIf the value is negative the object result is reverted in X axis", None))
self.doubleSpinBox_4.valueChanged.connect(self.on_doubleSpinBox_4_valueChanged) #connection doubleSpinBox_4
self.doubleSpinBox_4.valueChanged.connect(self.on_doubleSpinBox_4_valueChanged) #connection doubleSpinBox_4
Line 315: Line 347:
self.doubleSpinBox_5.setProperty("value", 1.0)
self.doubleSpinBox_5.setProperty("value", 1.0)
self.doubleSpinBox_5.setObjectName(_fromUtf8("doubleSpinBox_5"))
self.doubleSpinBox_5.setObjectName(_fromUtf8("doubleSpinBox_5"))
self.doubleSpinBox_5.setToolTip(_translate("MainWindow", "Scale free Y multiplied by ...", None))
self.doubleSpinBox_5.setToolTip(_translate("MainWindow", "Scale free Y multiplied by ...\n"+
"If the value is negative the object result is reverted in Y axis", None))
self.doubleSpinBox_5.valueChanged.connect(self.on_doubleSpinBox_5_valueChanged) #connection doubleSpinBox_5
self.doubleSpinBox_5.valueChanged.connect(self.on_doubleSpinBox_5_valueChanged) #connection doubleSpinBox_5
Line 326: Line 359:
self.doubleSpinBox_6.setProperty("value", 1.0)
self.doubleSpinBox_6.setProperty("value", 1.0)
self.doubleSpinBox_6.setObjectName(_fromUtf8("doubleSpinBox_6"))
self.doubleSpinBox_6.setObjectName(_fromUtf8("doubleSpinBox_6"))
self.doubleSpinBox_6.setToolTip(_translate("MainWindow", "Scale free Z multiplied by ...", None))
self.doubleSpinBox_6.setToolTip(_translate("MainWindow", "Scale free Z multiplied by ...\n"+
"If the value is negative the object result is reverted in Z axis", None))
self.doubleSpinBox_6.valueChanged.connect(self.on_doubleSpinBox_6_valueChanged) #connection doubleSpinBox_6
self.doubleSpinBox_6.valueChanged.connect(self.on_doubleSpinBox_6_valueChanged) #connection doubleSpinBox_6
Line 341: Line 375:
self.label_7.setObjectName(_fromUtf8("label_7"))
self.label_7.setObjectName(_fromUtf8("label_7"))
self.pushButton_3 = QtGui.QPushButton(self.groupBox_3)
self.pushButton_6 = QtGui.QPushButton(self.centralWidget)
self.pushButton_3.setGeometry(QtCore.QRect(70, 20, 21, 21))
self.pushButton_6.setGeometry(QtCore.QRect(10, 479, 65, 25))
self.pushButton_3.setToolTip(_fromUtf8("Align the Scale YZ to X"))
self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
self.pushButton_6.clicked.connect(self.on_pushButton_6_clicked) # connect on def "on_pushButton_6_clicked"
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))

self.pushButton_3.clicked.connect(self.on_pushButton03_clicked) #connection pushButton03 "..." align YZ to X
self.pushButton = QtGui.QPushButton(self.centralWidget)
self.pushButton.setGeometry(QtCore.QRect(82, 510, 65, 28))
self.pushButton.setObjectName(_fromUtf8("pushButton"))

self.pushButton_1 = QtGui.QPushButton(self.centralWidget)
self.pushButton_1.setGeometry(QtCore.QRect(10, 510, 65, 28))
self.pushButton_1.setObjectName(_fromUtf8("pushButton_1"))
self.pushButton_1.setStyleSheet("background-color: Base")
self.pushButton_1.clicked.connect(self.on_pushButton01_clicked) #connection pushButton01 "OK"
self.pushButton_2 = QtGui.QPushButton(self.centralWidget)
self.pushButton_2 = QtGui.QPushButton(self.centralWidget)
self.pushButton_2.setGeometry(QtCore.QRect(152, 480, 71, 28))
self.pushButton_2.setGeometry(QtCore.QRect(155, 510, 65, 28))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.pushButton_2.clicked.connect(self.on_pushButton02_clicked) #connection pushButton02 "Quitter"
self.pushButton_2.clicked.connect(self.on_pushButton02_clicked) #connection pushButton02 "Quitter"
self.pushButton_1 = QtGui.QPushButton(self.centralWidget)
self.pushButton_3 = QtGui.QPushButton(self.groupBox_3)
self.pushButton_1.setGeometry(QtCore.QRect(10, 480, 71, 28))
self.pushButton_3.setGeometry(QtCore.QRect(75, 20, 21, 21))
self.pushButton_1.setObjectName(_fromUtf8("pushButton_1"))
self.pushButton_3.setToolTip(_fromUtf8("Align the Scale YZ to X"))
self.pushButton_1.setStyleSheet("background-color: Base")
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.pushButton_1.clicked.connect(self.on_pushButton01_clicked) #connection pushButton01 "OK"
self.pushButton_3.clicked.connect(self.on_pushButton03_clicked) #connection pushButton03 "..." align YZ to X
self.pushButton = QtGui.QPushButton(self.centralWidget)
self.pushButton.setGeometry(QtCore.QRect(90, 480, 51, 28))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.groupBox_4 = QtGui.QGroupBox(self.centralWidget)
self.groupBox_4 = QtGui.QGroupBox(self.centralWidget)
self.groupBox_4.setGeometry(QtCore.QRect(10, 180, 211, 111))
self.groupBox_4.setGeometry(QtCore.QRect(10, 180, 211, 111))
Line 403: Line 443:
self.label_10.setGeometry(QtCore.QRect(10, 80, 81, 16))
self.label_10.setGeometry(QtCore.QRect(10, 80, 81, 16))
self.label_10.setObjectName(_fromUtf8("label_10"))
self.label_10.setObjectName(_fromUtf8("label_10"))

self.pushButton_4 = QtGui.QPushButton(self.groupBox_4)
self.pushButton_4.setGeometry(QtCore.QRect(75, 20, 21, 22))
self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
self.pushButton_4.clicked.connect(self.on_pushButton_4_clicked) # connect on def "on_pushButton_4_clicked"


self.pushButton.clicked.connect(self.on_pushButton00_clicked) #connection pushButton00 "Reset"
self.pushButton.clicked.connect(self.on_pushButton00_clicked) #connection pushButton00 "Reset"
MainWindow.setCentralWidget(self.centralWidget)
self.lineEdit = QtGui.QLineEdit(self.centralWidget)
self.lineEdit.setGeometry(QtCore.QRect(83, 481, 136, 20))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.lineEdit.setText(QtGui.QApplication.translate("Form", " ", None, QtGui.QApplication.UnicodeUTF8))


MainWindow.setCentralWidget(self.centralWidget)
self.retranslateUi(MainWindow)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
def retranslateUi(self, MainWindow):
Line 424: Line 471:
self.radioButton.setText(_translate("MainWindow", "Clone", None))
self.radioButton.setText(_translate("MainWindow", "Clone", None))
self.radioButton_2.setText(_translate("MainWindow", "Copy", None))
self.radioButton_2.setText(_translate("MainWindow", "Copy", None))
self.radioButton_3.setText(_translate("MainWindow", "Comp.", None))

self.checkBox.setText(_translate("MainWindow", "Increm.", None))

self.pushButton_4.setToolTip(_translate("MainWindow", "Align the YX degrees values to Z value \n The second click reset the rotations values to 0.0", None))
self.pushButton_4.setText(_translate("MainWindow", "...", None))
self.pushButton_5.setToolTip(_translate("MainWindow", "Align the YZ coordinates values to X value \n The second click reset the coordinates values to 0.0", None))
self.pushButton_5.setText(_translate("MainWindow", "...", None))
self.pushButton_3.setToolTip(_translate("MainWindow", "Align the YZ scale values to X scale value \n The second click reset the scales values to 1.0", None))
self.pushButton_3.setText(_translate("MainWindow", "...", None))


self.doubleSpinBox.setToolTip(_translate("MainWindow", "Place the new object to the X coordinate ", None))
self.doubleSpinBox.setToolTip(_translate("MainWindow", "Place the new object to the X coordinate ", None))
self.doubleSpinBox.setSuffix(_translate("MainWindow", " mm", None))
self.doubleSpinBox.setSuffix(_translate("MainWindow", " mm", None))
self.label_2.setText(_translate("MainWindow", "Coordinate X", None))
self.label_3.setText(_translate("MainWindow", "Coordinate Y", None))
self.doubleSpinBox_2.setToolTip(_translate("MainWindow", "Place the new object to the Y coordinate", None))
self.doubleSpinBox_2.setToolTip(_translate("MainWindow", "Place the new object to the Y coordinate", None))
self.doubleSpinBox_2.setSuffix(_translate("MainWindow", " mm", None))
self.doubleSpinBox_2.setSuffix(_translate("MainWindow", " mm", None))
self.doubleSpinBox_3.setToolTip(_translate("MainWindow", "Place the new object to the Z coordinate", None))
self.doubleSpinBox_3.setToolTip(_translate("MainWindow", "Place the new object to the Z coordinate", None))
self.doubleSpinBox_3.setSuffix(_translate("MainWindow", " mm", None))
self.doubleSpinBox_3.setSuffix(_translate("MainWindow", " mm", None))
self.label_4.setText(_translate("MainWindow", "Coordinate Z", None))


self.label_2.setText(_translate("MainWindow", "Coordinate X", None))
self.label_3.setText(_translate("MainWindow", "Coordinate Y", None))
self.label_4.setText(_translate("MainWindow", "Coordinate Z", None))


self.groupBox_2.setTitle(_translate("MainWindow", "Scale predefined", None))
self.groupBox_2.setTitle(_translate("MainWindow", "Scale predefined", None))
Line 458: Line 515:
self.comboBox.setItemText(17, _translate("MainWindow", "league", None)) #lea# league lieue = 4828032
self.comboBox.setItemText(17, _translate("MainWindow", "league", None)) #lea# league lieue = 4828032
self.comboBox.setItemText(18, _translate("MainWindow", "nautique", None)) #nmi# mile nautique = 1852000
self.comboBox.setItemText(18, _translate("MainWindow", "nautique", None)) #nmi# mile nautique = 1852000

self.groupBox_3.setTitle(_translate("MainWindow", "Scale free", None))
self.groupBox_3.setTitle(_translate("MainWindow", "Scale free", None))
self.label_5.setText(_translate("MainWindow", "Scale X", None))
self.label_5.setText(_translate("MainWindow", "Scale X", None))
self.label_6.setText(_translate("MainWindow", "Scale Y", None))
self.label_6.setText(_translate("MainWindow", "Scale Y", None))
self.label_7.setText(_translate("MainWindow", "Scale Z", None))
self.label_7.setText(_translate("MainWindow", "Scale Z", None))

self.pushButton_3.setToolTip(_translate("MainWindow", "Align the YZ scale values to X scale value ", None))
self.pushButton_3.setText(_translate("MainWindow", "...", None))
self.pushButton.setToolTip(_translate("MainWindow", "Reset the values", None))
self.pushButton.setText(_translate("MainWindow", "Reset", None))
self.pushButton_1.setToolTip(_translate("MainWindow", "Ok for Convert Copy or Compount", None))
self.pushButton_1.setText(_translate("MainWindow", "Ok", None))
self.pushButton_2.setToolTip(_translate("MainWindow", "Quit the macro", None))
self.pushButton_2.setToolTip(_translate("MainWindow", "Quit the macro", None))
self.pushButton_2.setText(_translate("MainWindow", "Quit", None))
self.pushButton_2.setText(_translate("MainWindow", "Quit", None))

self.pushButton_1.setToolTip(_translate("MainWindow", "Ok for Convert or copy", None))
self.pushButton_1.setText(_translate("MainWindow", "Ok", None))
self.pushButton_6.setToolTip(_translate("MainWindow", "Give the valueAt() the subObject selected Face, Wire, Line ...\n"+
"This option is useful in case a compound Placement information [0,0,0]\n"+
self.pushButton.setToolTip(_translate("MainWindow", "Reset", None))
"and its real location is away from the base coordinates 0,0,0\n"+
self.pushButton.setText(_translate("MainWindow", "Reset", None))
"(gives no provide information about the tilt of the object)", None))
self.pushButton_6.setText(_translate("MainWindow", "ValueAt()", None))

self.groupBox_4.setTitle(_translate("MainWindow", "Rotation", None))
self.groupBox_4.setTitle(_translate("MainWindow", "Rotation", None))
self.doubleSpinBox_7.setSuffix(_translate("MainWindow", " Deg", None))
self.doubleSpinBox_8.setSuffix(_translate("MainWindow", " Deg", None))
self.doubleSpinBox_9.setSuffix(_translate("MainWindow", " Deg", None))
self.label_8.setText(_translate("MainWindow", "Yaw ( Z )", None))
self.label_8.setText(_translate("MainWindow", "Yaw ( Z )", None))
self.label_9.setText(_translate("MainWindow", "Pitch ( Y )", None))
self.label_9.setText(_translate("MainWindow", "Pitch ( Y )", None))
self.label_10.setText(_translate("MainWindow", "Roll ( X )", None))
self.label_10.setText(_translate("MainWindow", "Roll ( X )", None))
self.doubleSpinBox_7.setSuffix(_translate("MainWindow", " Deg", None))
self.doubleSpinBox_8.setSuffix(_translate("MainWindow", " Deg", None))
self.doubleSpinBox_9.setSuffix(_translate("MainWindow", " Deg", None))


def SIGNAL_comboBox_Changed(self,text):
def SIGNAL_comboBox_Changed(self,text):
Line 558: Line 622:
global cloneCopy
global cloneCopy
cloneCopy = 1
cloneCopy = 1

def on_radioButton_2_clicked(self): # if checked then mode copy
def on_radioButton_2_clicked(self): # if checked then mode copy
global cloneCopy
global cloneCopy
cloneCopy = 0
cloneCopy = 0

def on_radioButton_3_clicked(self): # if checked then mode compount
global cloneCopy
cloneCopy = 2
def on_doubleSpinBox_valueChanged(self,value): # doubleSpinbox X
def on_doubleSpinBox_valueChanged(self,value): # doubleSpinbox X
Line 605: Line 673:
Roll_X = value
Roll_X = value


def on_pushButton03_clicked(self): # Bouton ... (align)
def on_pushButton_5_clicked(self): # Bouton ... (align) placement
global placement_X
global placement_Y
global placement_Z
global switchP

if switchP == 0:
placement_Y = placement_Z = placement_X
switchP = 1
else:
placement_Y = placement_Z = placement_X = 0.0
switchP = 0

self.doubleSpinBox.setProperty("value", placement_X)
self.doubleSpinBox_2.setProperty("value", placement_Y)
self.doubleSpinBox_3.setProperty("value", placement_Z)

def on_pushButton_6_clicked(self): # valueAt() placement detected
try:
sel = FreeCADGui.Selection.getSelection()
App.Console.PrintMessage(str(sel[0].Placement) +"\r\n")
selectionObjects = FreeCADGui.Selection.getSelectionEx() # Select an object or sub object getSelectionEx
edge = selectionObjects[0].SubObjects[0]
try:
self.lineEdit.setText(str(edge.valueAt(0,0))) # face
self.pushButton_6.setText(_translate("MainWindow", "ValueAt(0,0)", None))
App.Console.PrintMessage(str(edge.valueAt(0,0)) +"\r\n")
except Exception:
self.lineEdit.setText(str(edge.valueAt(0))) # fil
self.pushButton_6.setText(_translate("MainWindow", "ValueAt(0)", None))
App.Console.PrintMessage(str(edge.valueAt(0)) +"\r\n")
except Exception:
self.pushButton_6.setText(_translate("MainWindow", "ValueAt()", None))
App.Console.PrintError("Select one subObject, Face, Wire, Line ..."+"\r\n")
App.Console.PrintMessage("____________________________________"+"\r\n")
def on_pushButton_4_clicked(self): # Bouton ... (align) rotation
global Yaw_Z
global Pitch_Y
global Roll_X
global switchA

if switchA == 0:
Pitch_Y = Roll_X = Yaw_Z
switchA = 1
else:
Pitch_Y = Roll_X = Yaw_Z = 0.0
switchA = 0

self.doubleSpinBox_7.setProperty("value", Yaw_Z)
self.doubleSpinBox_8.setProperty("value", Pitch_Y)
self.doubleSpinBox_9.setProperty("value", Roll_X)

def on_pushButton03_clicked(self): # Bouton ... (align) uniteM
global uniteM_X
global uniteM_X
global uniteM_Y
global uniteM_Y
global uniteM_Z
global uniteM_Z
global switchS
global uniteM
global uniteM
global uniteMs
global uniteMs

uniteM_Y = uniteM_Z = uniteM_X
if switchS == 0:
self.doubleSpinBox_5.setProperty("value", uniteM_X)
self.doubleSpinBox_6.setProperty("value", uniteM_X)
uniteM_Y = uniteM_Z = uniteM_X
switchS = 1
else:
uniteM_Y = uniteM_Z = uniteM_X = 1.0
switchS = 0

self.doubleSpinBox_4.setProperty("value", uniteM_X)
self.doubleSpinBox_5.setProperty("value", uniteM_Y)
self.doubleSpinBox_6.setProperty("value", uniteM_Z)
def on_pushButton00_clicked(self): # Bouton Reset
def on_pushButton00_clicked(self): # Bouton Reset
Line 625: Line 755:
global placement_Y
global placement_Y
global placement_Z
global placement_Z
global oripl_X
global oripl_Y
global oripl_Z
global cloneCopy
global cloneCopy
global Yaw_Z
global Yaw_Z
Line 634: Line 761:
sel = ""
sel = ""
oripl_X = oripl_Y = oripl_Z = 0.0
self.pushButton_1.setToolTip(_translate("MainWindow", "Ok for Convert or copy", None))
self.pushButton_1.setToolTip(_translate("MainWindow", "Ok for Convert or copy", None))
Line 643: Line 769:
self.comboBox.setCurrentIndex(6)
self.comboBox.setCurrentIndex(6)
self.doubleSpinBox.setProperty("value", 0.0)
self.doubleSpinBox.setProperty("value", 0.0) # coordinates
self.doubleSpinBox_2.setProperty("value", 0.0)
self.doubleSpinBox_2.setProperty("value", 0.0)
self.doubleSpinBox_3.setProperty("value", 0.0)
self.doubleSpinBox_3.setProperty("value", 0.0)
self.checkBox.setChecked(True)

placement_X = placement_Y = placement_Z = 0.0
placement_X = placement_Y = placement_Z = 0.0
self.doubleSpinBox_4.setProperty("value", 1.0)
self.doubleSpinBox_4.setProperty("value", 1.0) # scale
self.doubleSpinBox_5.setProperty("value", 1.0)
self.doubleSpinBox_5.setProperty("value", 1.0)
self.doubleSpinBox_6.setProperty("value", 1.0)
self.doubleSpinBox_6.setProperty("value", 1.0)
self.doubleSpinBox_7.setProperty("value", 0.0)
self.doubleSpinBox_7.setProperty("value", 0.0) # angles
self.doubleSpinBox_8.setProperty("value", 0.0)
self.doubleSpinBox_8.setProperty("value", 0.0)
self.doubleSpinBox_9.setProperty("value", 0.0)
self.doubleSpinBox_9.setProperty("value", 0.0)
Line 660: Line 787:
uniteMs= "mm"
uniteMs= "mm"
uniteM = 1
uniteM = 1
self.lineEdit.setText("")
def on_pushButton01_clicked(self): # Bouton OK
def on_pushButton01_clicked(self): # Bouton OK
Line 678: Line 806:
global placement_Y
global placement_Y
global placement_Z
global placement_Z
global oripl_X
global oripl_Y
global oripl_Z
global sel
global sel
global Yaw_Z
global Yaw_Z
Line 686: Line 811:
global Roll_X
global Roll_X
#### Chrono begin ######################################################################### chrono begin
import time #### chrono begin
depart = time.clock() #### chrono begin
#### Chrono begin ######################################################################### chrono begin

sel = FreeCADGui.Selection.getSelection()
sel = FreeCADGui.Selection.getSelection()
Line 728: Line 858:
App.Console.PrintMessage("- - - - - - - - - -"+"\r\n")
App.Console.PrintMessage("- - - - - - - - - -"+"\r\n")
oripl_X = sel[0].Placement.Base[0]
try:
oripl_Y = sel[0].Placement.Base[1]
obj = ""
oripl_Z = sel[0].Placement.Base[2]
if cloneCopy == 1: # clone ok
import Draft
obj = ""
mess = "Clone"
if cloneCopy == 1: # clone ok
obj=Draft.clone(sel)
obj=Draft.clone(sel)
obj.Scale = (uniteM_X, uniteM_Y, uniteM_Z)
if self.checkBox.isChecked(): # if checkbox is checked then .... increment
mess = "Clone"
obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0)).multiply(App.activeDocument().getObject(obj.Name).Placement) # increment
if len(sel) > 1: # many object
else:
obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
else: # one objects
obj.Placement=App.Placement(App.Vector(oripl_X + placement_X,oripl_Y + placement_Y,oripl_Z + placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
obj.Scale = (uniteM_X, uniteM_Y, uniteM_Z)
if cloneCopy == 0: # copy ok
else: # copy ok
import Draft
mess = "Copy "
mess = "Copy "
if len(sel) > 1:
for i in range(len(sel)):
for i in range(len(sel)):
obj = Draft.scale(sel[i],delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0),copy=True,legacy=True)
obj = Draft.scale(sel[i],delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0),copy=True,legacy=True)
oripl_X = sel[i].Placement.Base[0]
if self.checkBox.isChecked(): # if checkbox is checked then .... increment
obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0)).multiply(App.activeDocument().getObject(obj.Name).Placement) # increment
oripl_Y = sel[i].Placement.Base[1]
oripl_Z = sel[i].Placement.Base[2]
else:
obj.Placement=App.Placement(App.Vector(oripl_X + placement_X,oripl_Y + placement_Y,oripl_Z + placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
else:
obj.Label = "Copy of " + obj.Label
obj = Draft.scale(sel,delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0),copy=True,legacy=True)
if cloneCopy == 2: # compound ok
obj.Placement=App.Placement(App.Vector(oripl_X + placement_X,oripl_Y + placement_Y,oripl_Z + placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
import Draft
mess = "Compount "
liste = []
########################################################################################################################
# objori = Draft.makeBlock(Gui.Selection.getSelection()) # create Block other method compound
# obj = Draft.scale([objori],delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0))
# App.activeDocument().removeObject(objori.Name)
########################################################################################################################


#######################################################################################################################
FreeCAD.ActiveDocument.recompute()
objori = App.activeDocument().addObject("Part::Compound","Compound") # create method compound
# boundinbox (dimensions hors tout)
for i in range(len(sel)):
objori.Links += App.activeDocument().getObject(sel[i].Name),
try:
boundBox_ = obj.Shape.BoundBox
liste.append(sel[i].Name)
obj = Draft.scale([objori],delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0))
boundBoxLX = boundBox_.XLength
#######################################################################################################################
boundBoxLY = boundBox_.YLength

boundBoxLZ = boundBox_.ZLength
# try: # optional delette the original objects
except:
boundBox_ = 0.0
# App.activeDocument().removeObject(objori.Name)
boundBoxLX = 0.0
# for i in liste:
boundBoxLY = 0.0
# App.activeDocument().removeObject(i)
boundBoxLZ = 0.0
# except:
# None

# volume
if self.checkBox.isChecked(): # if checkbox is checked then .... increment
volume_ = 0.0
obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0)).multiply(App.activeDocument().getObject(obj.Name).Placement) # increment
try:
volume_ = obj.Shape.Volume
else:
obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
except:
for i in range(len(obj)):
obj.Label = "Compount of " + obj.Label
volume_ += obj[i].Shape.Volume
try:
objori.Label = "Ori " + obj.Label # renamme the original object
# surface
except Exception:
surface = 0.0
None

try:
surface = obj.Shape.Area
FreeCAD.ActiveDocument.recompute()
except:
# print "[ ",placement_X," ",placement_Y," ",placement_Z," ] [ ",Yaw_Z," ",Pitch_Y," ",Roll_X," ]"
for i in range(len(obj)):
surface += obj[i].Shape.Area
# boundinbox (dimensions hors tout)
try:
boundBox_ = obj.Shape.BoundBox
App.Console.PrintMessage("Convert mm in ' "+uniteMs+" ' (1 "+uniteMs+" = "+str(uniteM)+" mm)"+"\r\n")
App.Console.PrintMessage(mess + " boundBox_X : "+str(boundBoxLX)+" mm"+"\r\n")
boundBoxLX = boundBox_.XLength
App.Console.PrintMessage(mess + " boundBox_Y : "+str(boundBoxLY)+" mm"+"\r\n")
boundBoxLY = boundBox_.YLength
App.Console.PrintMessage(mess + " boundBox_Z : "+str(boundBoxLZ)+" mm"+"\r\n")
boundBoxLZ = boundBox_.ZLength
except:
App.Console.PrintMessage(mess + " volume : "+str(volume_)+" mm3 ("+str(len(sel))+" element(s))"+"\r\n")#
boundBox_ = 0.0
App.Console.PrintMessage(mess + " surface : "+str(surface)+" mm2 ("+str(len(sel))+" element(s))"+"\r\n")#
boundBoxLX = 0.0
App.Console.PrintMessage("___________________"+"\r\n")
boundBoxLY = 0.0
self.pushButton_1.setStyleSheet("background-color: green")
boundBoxLZ = 0.0
# volume
volume_ = 0.0
try:
volume_ = obj.Shape.Volume
except:
for i in range(len(obj)):
volume_ += obj[i].Shape.Volume
# surface
surface = 0.0
try:
surface = obj.Shape.Area
except:
for i in range(len(obj)):
surface += obj[i].Shape.Area
App.Console.PrintMessage(obj.Label+"\r\n")
App.Console.PrintMessage("Convert mm in ' "+uniteMs+" ' (1 "+uniteMs+" = "+str(uniteM)+" mm)"+"\r\n")
App.Console.PrintMessage(mess + " boundBox_X : "+str(boundBoxLX)+" mm"+"\r\n")
App.Console.PrintMessage(mess + " boundBox_Y : "+str(boundBoxLY)+" mm"+"\r\n")
App.Console.PrintMessage(mess + " boundBox_Z : "+str(boundBoxLZ)+" mm"+"\r\n")
App.Console.PrintMessage(mess + " volume : "+str(volume_)+" mm3 ("+str(len(sel))+" element(s))"+"\r\n")#
App.Console.PrintMessage(mess + " surface : "+str(surface)+" mm2 ("+str(len(sel))+" element(s))"+"\r\n")#
#### Chrono end ########################################################################### chrono end
arrivee = time.clock() #### chrono end
App.Console.PrintMessage("Time : "+str("%.2f" % ((arrivee - depart)/60))+" min"+"\r\n")#### chrono end
#### Chrono end ########################################################################### chrono end
App.Console.PrintMessage("___________________"+"\r\n")
self.pushButton_1.setStyleSheet("background-color: green")

except Exception:
FreeCAD.Console.PrintError("Error interne"+"\r\n")
else:
else:
self.pushButton_1.setStyleSheet("background-color: red")#red
self.pushButton_1.setStyleSheet("background-color: red")#red
Line 799: Line 969:
FreeCAD.Console.PrintError("Select an object"+"\r\n") #App.Console.PrintMessage
FreeCAD.Console.PrintError("Select an object"+"\r\n") #App.Console.PrintMessage
sel = ""
sel = ""

def on_pushButton02_clicked(self): # Bouton Quitter
def on_pushButton02_clicked(self): # Bouton Quitter
App.Console.PrintMessage("End CloneConvert\r\n")
App.Console.PrintMessage("End CloneConvert\r\n")
Line 815: Line 985:


==Revision==
==Revision==
30/01/2016 ver 0.7 rewriting code with Placement and Increment and adding buttons Compound, Increment, ValueAt(),

26/01/2016 ver 0.6 correction placement with many objets Copy
26/01/2016 ver 0.6 correction placement with many objets Copy



Revision as of 17:36, 30 January 2016

File:Macro CloneConvert Macro CloneConvert

Description
Creates a clone of the object and the converted in the chosen position and size (inch, mm, m, µm...).

Author: mario52
Author
mario52
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Description

Creates a clone or copy of the object and the converted in the chosen position and size (inch, mm, m, µm...) or free. The base object is recognized in mm (FreeCAd base)

Uses

Run the macro, the XYZ settings, choose "Clone" or "Copy" a unit or one value of choice select your object, and click Ok button.

If no value is entered a copy or clone will be created without modification. If no object is selected the Ok button will be colored in red.

The value of the BoundingBox, Volume and Surface is diplayed in the Report view, in the case of Copy multiple object, the display will show BoundingBox 0.0.


The base is the mm example with a 1 mm cube of side :

Select in the comboBox inch, 1 inch = 25.4 mm , the fields "Scale free" automatically adjusts to 25.4 (the values ​​in "Scale-free" can be changed separately). Click Ok button, the clone created will have 25,4 mm x 25,4 mm x 25,4 mm

150% = 1,50 in the "Scale free" fields

104% = 1,04 in the "Scale free" fields

Inverse operation :

If you want to reduce an object ex: a cube 25.4 mm (1 inch) in cube 1 mm sides, use the following formula, 1 / 25.4 = 0.0393700 and enter the value 0,0393700 (with comma) in the Scale field XY and Z.

In a cube of 5 mm, made​​ 5 / 25.4 = 0.1968503 and enter the value 0,1968503 (with comma) in the Scale field XY and Z.

50% = 0,50 in the "Scale free" fields

4% = 0,04 in the "Scale free" fields


Predefined units are :

km, hm, dam, m, dm, cm, mm, µm, nm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique.

CloneConvert
CloneConvert
  • Mode
  • Clone  : One clone of the objet(s) is create
  • Copy  : One copy of the objet(s) is create
  • Comp  : One compound of the objet(s) is create
  • Increm. : incrementing the coordinates data to the original coordinates of the object (Placement, Rotation ...)
    If this is not checked the Placement begin in coordinates 0,0,0 of FreeCAD
    In case a compound Placement information is [0,0,0] the Placement begin in the position of object
    If the real location is away from the base coordinates 0,0,0 use the ValueAt() button
    for the real Placement of the subObject selected Face, Wire, Line ....
  • ... : This button align the YZ values on the value of X to have the same values ​​XYZ (or manually)
    The second click reset the coordinates values to 0.0
  • Coordinate X : Move the copy to the Coordinate X selected (Base 0,0,0 if Increm. is not checked)
  • Coordinate Y : Move the copy to the Coordinate Y selected (Base 0,0,0 if Increm. is not checked)
  • Coordinate Z : Move the copy to the Coordinate Z selected (Base 0,0,0 if Increm. is not checked)
  • Rotation
  • ... : This button align the Pitch and Roll values on the value of Yaw to have the same values ​​Rotation (or manually)
    The second click reset the rotations values to 0.0
  • Yaw (Z )  : Rotate the copy to the axis Z (Yaw) (Begin 0 if Increm. is not checked)
  • Pitch ( Y ) : Rotate the copy to the axis Y (Pitch) (Begin 0 if Increm. is not checked)
  • Roll ( X )  : Rotate the copy to the axis X (Roll) (Begin 0 if Increm. is not checked)
  • Scale predefined
  • Scale predefined : predefined scales in units, km, hm, dam, m, dm, cm, mm, µm, nm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique
    or choose a free value in the Scale free field.
  • Scale free
  • ... : This button align the Scales values on the value of Scale X to have the same values ​​XYZ (or manually)
    The second click reset the scales values to 1.0
  • Scale X : free scale , if the value is negative ( -10) , the object is scaled x 10 and will be reversed in the X axis, to reduce the shape give a decimal value (0,5)
  • Scale Y : free scale , if the value is negative ( -10) , the object is scaled x 10 and will be reversed in the Y axis, to reduce the shape give a decimal value (0,5)
  • Scale Z : free scale , if the value is negative ( -10) , the object is scaled x 10 and will be reversed in the Z axis, to reduce the shape give a decimal value (0,5)
  • ValueAt() : Give the valueAt() the subObject selected Face, Wire, Line ...
    This option is useful in case a compound Placement information [0,0,0] and its real location is away from the base coordinates 0,0,0
    (gives no provide information about the rotation of the object)
  • Ok : the OK button validates and launches the command, if no object is selected the Ok button will be colored in red
  • Reset : the Reset button puts all the values to zero
  • Quit : the Quit button exit the macro

Script

The icone

Macro_CloneConvert.FCMacro

# -*- coding: utf-8 -*-

# CloneConvert.FCMacro
# Cree un clone ou une copie de l'objet ou des objets selectionne(s) et le met e l'echelle de la grandeur choisie
# utilisation : lancer CloneConvert selectionnez un objet choisissez la grandeur et cliquez sur OK
# 
# Creates a clone of one copy the selected object and updates the selected size range
# use: start CloneConvert select an object choose the size and click OK
#

#OS: Windows Vista                                #OS: Windows 8.1
#Word size: 32-bit                                #Word size of OS: 64-bit
#Version: 0.14.3700 (Git)                         #Word size of FreeCAD: 32-bit
#Branch: releases/FreeCAD-0-14                    #Version: 0.16.5231 (Git)
#Hash: 32f5aae0a64333ec8d5d160dbc46e690510c8fe1   #Build type: Release
#Python version: 2.6.2                            #Branch: master
#Qt version: 4.5.2                                #Hash: 945638c405766faca0e5f4c1611c00151c88a2ff
#Coin version: 3.1.0                              #Python version: 2.7.8
#SoQt version: 1.4.1                              #Qt version: 4.8.6
#OCC version: 6.5.1                               #Coin version: 4.0.0a
#                                                 #OCC version: 6.8.0.oce-0.17
#

# ver 0.3 31/07/2014 PyQt4 + PySide
# ver 0.4 25/07/2015 ajout rotation
# ver 0.5 26/07/2015 correction rotation plusieurs objets Copy
# ver 0.6 26/01/2016 correction placement avec plusieurs objets Copy
# ver 0.7 30/01/2016 reecriture du code avec Placement et ajout Increment et de boutons
 
__title__ = "CloneConvert"
__author__ = "mario52"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.07"
__date__    = "30/01/2016"

__Comment__ = "This macro creates Clone or Copy or Compound of object(s)"
__Web__ = "http://www.freecadweb.org/"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_CloneConvert"
__Icon__  = "/usr/lib/freecad/Mod/plugins/icons/Macro_CloneConvert.png"
__IconW__  = "C:/Users/User Name/AppData/Roaming/FreeCAD/Macro_CloneConvert.png"
__Help__ = "start the macro and follow the instructions"
__Status__ = "stable"
__Requires__ = "Alls Freecad"
__Communication__ = "http://www.freecadweb.org/wiki/index.php?title=User:Mario52"


try:
    import PyQt4                     # PyQt4
    from PyQt4 import QtCore, QtGui  # PyQt4
#    print "PyQt4"

except Exception:
    import PySide                    # PySide
    from PySide import QtCore, QtGui # PySide
#    print "PySide"

import Draft, Part, FreeCAD, math, PartGui, FreeCADGui
from math import sqrt, pi, sin, cos, asin
from FreeCAD import Base
from decimal import *
from Draft import *
from FreeCAD import Vector, Rotation, Placement, Console
 
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s
 
try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

 
global surface     ; surface     = 0.0
global volume_     ; volume_     = 0.0
global boundBox_   ; boundBox_   = 0.0
global boundBoxLX  ; boundBoxLX  = 0.0
global boundBoxLY  ; boundBoxLY  = 0.0
global boundBoxLZ  ; boundBoxLZ  = 0.0
global boundBox_S  ; boundBox_S  = ""
global uniteM_X    ; uniteM_X    = 1.0
global uniteM_Y    ; uniteM_Y    = 1.0
global uniteM_Z    ; uniteM_Z    = 1.0
global uniteM      ; uniteM      = 1.0
global uniteMs     ; uniteMs     = "mm"   # default mm
global placement_X ; placement_X = 0.0
global placement_Y ; placement_Y = 0.0
global placement_Z ; placement_Z = 0.0
global Yaw_Z       ; Yaw_Z       = 0.0
global Pitch_Y     ; Pitch_Y     = 0.0
global Roll_X      ; Roll_X      = 0.0

global switchP     ; switchP     = 0
global switchA     ; switchA     = 0
global switchS     ; switchS     = 0

global sel         ; sel         = ""
global cloneCopy   ; cloneCopy   = 1
 
global a ; a = ""
class Ui_MainWindow(object):
 
    def __init__(self, MainWindow):
#        path = FreeCAD.ConfigGet("AppHomePath")
 
        global uniteMs
 
        self.window = MainWindow
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(230, 549)
        MainWindow.setMinimumSize(QtCore.QSize(230, 549))
        MainWindow.setMaximumSize(QtCore.QSize(230, 549))
        self.centralWidget = QtGui.QWidget(MainWindow)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.label = QtGui.QLabel(self.centralWidget)
        self.label.setGeometry(QtCore.QRect(10, 10, 191, 16))
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName(_fromUtf8("label"))
 
        self.groupBox = QtGui.QGroupBox(self.centralWidget)
        self.groupBox.setGeometry(QtCore.QRect(10, 30, 211, 141))
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
 
        self.doubleSpinBox = QtGui.QDoubleSpinBox(self.groupBox)
        self.doubleSpinBox.setGeometry(QtCore.QRect(100, 50, 101, 22))
        self.doubleSpinBox.setDecimals(7)
        self.doubleSpinBox.setMinimum(-10000000.0)
        self.doubleSpinBox.setMaximum(10000000.0)
        self.doubleSpinBox.setSingleStep(1.0)
        self.doubleSpinBox.setProperty("value", 0.0)
        self.doubleSpinBox.setObjectName(_fromUtf8("doubleSpinBox"))
        self.doubleSpinBox.valueChanged.connect(self.on_doubleSpinBox_valueChanged) #connection doubleSpinBox
 
        self.label_2 = QtGui.QLabel(self.groupBox)
        self.label_2.setGeometry(QtCore.QRect(10, 50, 91, 16))
        self.label_2.setObjectName(_fromUtf8("label_2"))
 
        self.label_3 = QtGui.QLabel(self.groupBox)
        self.label_3.setGeometry(QtCore.QRect(10, 80, 91, 16))
        self.label_3.setObjectName(_fromUtf8("label_3"))
 
        self.label_4 = QtGui.QLabel(self.groupBox)
        self.label_4.setGeometry(QtCore.QRect(10, 110, 91, 16))
        self.label_4.setObjectName(_fromUtf8("label_4"))
 
        self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(self.groupBox)
        self.doubleSpinBox_2.setGeometry(QtCore.QRect(100, 80, 101, 22))
        self.doubleSpinBox_2.setDecimals(7)
        self.doubleSpinBox_2.setMinimum(-10000000.0)
        self.doubleSpinBox_2.setMaximum(10000000.0)
        self.doubleSpinBox_2.setSingleStep(1.0)
        self.doubleSpinBox_2.setProperty("value", 0.0)
        self.doubleSpinBox_2.setObjectName(_fromUtf8("doubleSpinBox_2"))
        self.doubleSpinBox_2.valueChanged.connect(self.on_doubleSpinBox_2_valueChanged) #connection doubleSpinBox_2
 
        self.doubleSpinBox_3 = QtGui.QDoubleSpinBox(self.groupBox)
        self.doubleSpinBox_3.setGeometry(QtCore.QRect(100, 110, 101, 22))
        self.doubleSpinBox_3.setDecimals(7)
        self.doubleSpinBox_3.setMinimum(-10000000.0)
        self.doubleSpinBox_3.setMaximum(10000000.0)
        self.doubleSpinBox_3.setSingleStep(1.0)
        self.doubleSpinBox_3.setProperty("value", 0.0)
        self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3"))
        self.doubleSpinBox_3.valueChanged.connect(self.on_doubleSpinBox_3_valueChanged) #connection doubleSpinBox_3
 
        self.radioButton = QtGui.QRadioButton(self.groupBox)
        self.radioButton.setGeometry(QtCore.QRect(10, 20, 51, 20))
        self.radioButton.setChecked(True)
        self.radioButton.setObjectName(_fromUtf8("radioButton"))
        self.radioButton.setToolTip(_translate("MainWindow", "Create a clone of the object(s)", None))
        self.radioButton.clicked.connect(self.on_radioButton_clicked)     #connection radioButton mode clone
 
        self.radioButton_2 = QtGui.QRadioButton(self.groupBox)
        self.radioButton_2.setGeometry(QtCore.QRect(58, 20, 51, 20))
        self.radioButton_2.setObjectName(_fromUtf8("radioButton_2"))
        self.radioButton_2.setToolTip(_translate("MainWindow", "Create a copy of the object(s)", None))
        self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked) #connection radioButton_2 mode copy
 
        self.radioButton_3 = QtGui.QRadioButton(self.groupBox)
        self.radioButton_3.setGeometry(QtCore.QRect(105, 20, 51, 20))
        self.radioButton_3.setObjectName(_fromUtf8("radioButton_3"))
        self.radioButton_3.setToolTip(_translate("MainWindow", "Create a compount of the object(s)", None))
        self.radioButton_3.clicked.connect(self.on_radioButton_3_clicked) #connection radioButton_3 mode compount
 
        self.checkBox = QtGui.QCheckBox(self.groupBox)
        self.checkBox.setGeometry(QtCore.QRect(155, 20, 61, 20))
        self.checkBox.setChecked(True)
        self.checkBox.setToolTip(_translate("MainWindow", "Apply incremental changes to object Placement (Defaut)\n"+
                                                          "If this is not checked the Placement begin in coordinates 0,0,0 of FreeCAD\n"+
                                                          "In case a compound Placement information is [0,0,0] the Placement begin in the position of object\n"+
                                                          "If the real location is away from the base coordinates 0,0,0 use the ValueAt() button\n"
                                                          "for the real Placement of the subObject selected Face, Wire, Line ....", None))
        self.checkBox.setObjectName(_fromUtf8("checkBox"))

        self.pushButton_5 = QtGui.QPushButton(self.groupBox)
        self.pushButton_5.setGeometry(QtCore.QRect(75, 50, 21, 22))
        self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
        self.pushButton_5.clicked.connect(self.on_pushButton_5_clicked)                     # connect on def "on_pushButton_5_clicked"

        self.groupBox_2 = QtGui.QGroupBox(self.centralWidget)
        self.groupBox_2.setGeometry(QtCore.QRect(10, 300, 211, 51))
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
 
        self.comboBox = QtGui.QComboBox(self.groupBox_2)
        self.comboBox.setGeometry(QtCore.QRect(10, 20, 191, 22))
        self.comboBox.setMinimumContentsLength(0)
        self.comboBox.setObjectName(_fromUtf8("comboBox"))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.addItem(_fromUtf8(""))
        self.comboBox.setToolTip(_translate("MainWindow",u"Select unit. . .", None))
        QtCore.QObject.connect(self.comboBox, QtCore.SIGNAL("currentIndexChanged(QString)"), self.SIGNAL_comboBox_Changed)
 
        self.groupBox_3 = QtGui.QGroupBox(self.centralWidget)
        self.groupBox_3.setGeometry(QtCore.QRect(10, 360, 211, 111))
        self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
 
        self.doubleSpinBox_4 = QtGui.QDoubleSpinBox(self.groupBox_3)
        self.doubleSpinBox_4.setGeometry(QtCore.QRect(100, 20, 101, 22))
        self.doubleSpinBox_4.setDecimals(7)
        self.doubleSpinBox_4.setMinimum(-1000000)
        self.doubleSpinBox_4.setMaximum(1000000.0)
        self.doubleSpinBox_4.setSingleStep(1.0)
        self.doubleSpinBox_4.setProperty("value", 1.0)
        self.doubleSpinBox_4.setObjectName(_fromUtf8("doubleSpinBox_4"))
        self.doubleSpinBox_4.setToolTip(_translate("MainWindow", "Scale free X multiplied by ...\nIf the value is negative the object result is reverted in X axis", None))
        self.doubleSpinBox_4.valueChanged.connect(self.on_doubleSpinBox_4_valueChanged) #connection doubleSpinBox_4
 
        self.doubleSpinBox_5 = QtGui.QDoubleSpinBox(self.groupBox_3)
        self.doubleSpinBox_5.setGeometry(QtCore.QRect(100, 50, 101, 22))
        self.doubleSpinBox_5.setDecimals(7)
        self.doubleSpinBox_5.setMinimum(-1000000)
        self.doubleSpinBox_5.setMaximum(1000000.0)
        self.doubleSpinBox_5.setSingleStep(1.0)
        self.doubleSpinBox_5.setProperty("value", 1.0)
        self.doubleSpinBox_5.setObjectName(_fromUtf8("doubleSpinBox_5"))
        self.doubleSpinBox_5.setToolTip(_translate("MainWindow", "Scale free Y multiplied by ...\n"+
                                                                 "If the value is negative the object result is reverted in Y axis", None))
        self.doubleSpinBox_5.valueChanged.connect(self.on_doubleSpinBox_5_valueChanged) #connection doubleSpinBox_5
 
        self.doubleSpinBox_6 = QtGui.QDoubleSpinBox(self.groupBox_3)
        self.doubleSpinBox_6.setGeometry(QtCore.QRect(100, 80, 101, 22))
        self.doubleSpinBox_6.setDecimals(7)
        self.doubleSpinBox_6.setMinimum(-1000000)
        self.doubleSpinBox_6.setMaximum(1000000.0)
        self.doubleSpinBox_6.setSingleStep(1.0)
        self.doubleSpinBox_6.setProperty("value", 1.0)
        self.doubleSpinBox_6.setObjectName(_fromUtf8("doubleSpinBox_6"))
        self.doubleSpinBox_6.setToolTip(_translate("MainWindow", "Scale free Z multiplied by ...\n"+
                                                                 "If the value is negative the object result is reverted in Z axis", None))
        self.doubleSpinBox_6.valueChanged.connect(self.on_doubleSpinBox_6_valueChanged) #connection doubleSpinBox_6
 
        self.label_5 = QtGui.QLabel(self.groupBox_3)
        self.label_5.setGeometry(QtCore.QRect(10, 20, 53, 16))
        self.label_5.setObjectName(_fromUtf8("label_5"))
 
        self.label_6 = QtGui.QLabel(self.groupBox_3)
        self.label_6.setGeometry(QtCore.QRect(10, 50, 53, 16))
        self.label_6.setObjectName(_fromUtf8("label_6"))
 
        self.label_7 = QtGui.QLabel(self.groupBox_3)
        self.label_7.setGeometry(QtCore.QRect(10, 80, 53, 16))
        self.label_7.setObjectName(_fromUtf8("label_7"))
 
        self.pushButton_6 = QtGui.QPushButton(self.centralWidget)
        self.pushButton_6.setGeometry(QtCore.QRect(10, 479, 65, 25))
        self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
        self.pushButton_6.clicked.connect(self.on_pushButton_6_clicked) # connect on def "on_pushButton_6_clicked"

        self.pushButton = QtGui.QPushButton(self.centralWidget)
        self.pushButton.setGeometry(QtCore.QRect(82, 510, 65, 28))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))

        self.pushButton_1 = QtGui.QPushButton(self.centralWidget)
        self.pushButton_1.setGeometry(QtCore.QRect(10, 510, 65, 28))
        self.pushButton_1.setObjectName(_fromUtf8("pushButton_1"))
        self.pushButton_1.setStyleSheet("background-color: Base")
        self.pushButton_1.clicked.connect(self.on_pushButton01_clicked) #connection pushButton01 "OK"
 
        self.pushButton_2 = QtGui.QPushButton(self.centralWidget)
        self.pushButton_2.setGeometry(QtCore.QRect(155, 510, 65, 28))
        self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
        self.pushButton_2.clicked.connect(self.on_pushButton02_clicked) #connection pushButton02 "Quitter"
 
        self.pushButton_3 = QtGui.QPushButton(self.groupBox_3)
        self.pushButton_3.setGeometry(QtCore.QRect(75, 20, 21, 21))
        self.pushButton_3.setToolTip(_fromUtf8("Align the Scale YZ to X"))
        self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
        self.pushButton_3.clicked.connect(self.on_pushButton03_clicked) #connection pushButton03 "..." align YZ to X
 
        self.groupBox_4 = QtGui.QGroupBox(self.centralWidget)
        self.groupBox_4.setGeometry(QtCore.QRect(10, 180, 211, 111))
        self.groupBox_4.setObjectName(_fromUtf8("groupBox_4"))

        self.doubleSpinBox_7 = QtGui.QDoubleSpinBox(self.groupBox_4)
        self.doubleSpinBox_7.setGeometry(QtCore.QRect(100, 20, 101, 22))
        self.doubleSpinBox_7.setDecimals(7)
        self.doubleSpinBox_7.setMinimum(-360.0)
        self.doubleSpinBox_7.setMaximum(360.0)
        self.doubleSpinBox_7.setObjectName(_fromUtf8("doubleSpinBox_7"))
        self.doubleSpinBox_7.setToolTip(_translate("MainWindow", "Rotation of Yaw ( Axis Z )", None))
        self.doubleSpinBox_7.valueChanged.connect(self.on_doubleSpinBox_7_valueChanged) #connection doubleSpinBox_7

        self.doubleSpinBox_8 = QtGui.QDoubleSpinBox(self.groupBox_4)
        self.doubleSpinBox_8.setGeometry(QtCore.QRect(100, 50, 101, 22))
        self.doubleSpinBox_8.setDecimals(7)
        self.doubleSpinBox_8.setMinimum(-360.0)
        self.doubleSpinBox_8.setMaximum(360.0)
        self.doubleSpinBox_8.setObjectName(_fromUtf8("doubleSpinBox_8"))
        self.doubleSpinBox_8.setToolTip(_translate("MainWindow", "Rotation of Pitch ( Axis Y )", None))
        self.doubleSpinBox_8.valueChanged.connect(self.on_doubleSpinBox_8_valueChanged) #connection doubleSpinBox_8

        self.doubleSpinBox_9 = QtGui.QDoubleSpinBox(self.groupBox_4)
        self.doubleSpinBox_9.setGeometry(QtCore.QRect(100, 80, 101, 22))
        self.doubleSpinBox_9.setDecimals(7)
        self.doubleSpinBox_9.setMinimum(-360.0)
        self.doubleSpinBox_9.setMaximum(360.0)
        self.doubleSpinBox_9.setObjectName(_fromUtf8("doubleSpinBox_9"))
        self.doubleSpinBox_9.setToolTip(_translate("MainWindow", "Rotation of Roll ( Axis X )", None))
        self.doubleSpinBox_9.valueChanged.connect(self.on_doubleSpinBox_9_valueChanged) #connection doubleSpinBox_9

        self.label_8 = QtGui.QLabel(self.groupBox_4)
        self.label_8.setGeometry(QtCore.QRect(10, 20, 81, 16))
        self.label_8.setObjectName(_fromUtf8("label_8"))

        self.label_9 = QtGui.QLabel(self.groupBox_4)
        self.label_9.setGeometry(QtCore.QRect(10, 50, 81, 16))
        self.label_9.setObjectName(_fromUtf8("label_9"))

        self.label_10 = QtGui.QLabel(self.groupBox_4)
        self.label_10.setGeometry(QtCore.QRect(10, 80, 81, 16))
        self.label_10.setObjectName(_fromUtf8("label_10"))

        self.pushButton_4 = QtGui.QPushButton(self.groupBox_4)
        self.pushButton_4.setGeometry(QtCore.QRect(75, 20, 21, 22))
        self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
        self.pushButton_4.clicked.connect(self.on_pushButton_4_clicked) # connect on def "on_pushButton_4_clicked"

        self.pushButton.clicked.connect(self.on_pushButton00_clicked)   #connection pushButton00 "Reset"
 
        self.lineEdit = QtGui.QLineEdit(self.centralWidget)
        self.lineEdit.setGeometry(QtCore.QRect(83, 481, 136, 20))
        self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
        self.lineEdit.setText(QtGui.QApplication.translate("Form", " ", None, QtGui.QApplication.UnicodeUTF8))

        MainWindow.setCentralWidget(self.centralWidget)
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
 
    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "CloneConvert", None))
        try:
            MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint)  # cette fonction met la fenetre en avant
        except Exception:
            MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint)  # cette fonction met la fenetre en avant
        self.label.setText(_translate("MainWindow", "Object converter", None))
        self.groupBox.setTitle(_translate("MainWindow", "Mode", None))

        self.radioButton.setText(_translate("MainWindow", "Clone", None))
        self.radioButton_2.setText(_translate("MainWindow", "Copy", None))
        self.radioButton_3.setText(_translate("MainWindow", "Comp.", None))

        self.checkBox.setText(_translate("MainWindow", "Increm.", None))

        self.pushButton_4.setToolTip(_translate("MainWindow", "Align the YX degrees values to Z value \n The second click reset the rotations values to 0.0", None))
        self.pushButton_4.setText(_translate("MainWindow", "...", None))
        self.pushButton_5.setToolTip(_translate("MainWindow", "Align the YZ coordinates values to X value  \n The second click reset the coordinates values to 0.0", None))
        self.pushButton_5.setText(_translate("MainWindow", "...", None))
        self.pushButton_3.setToolTip(_translate("MainWindow", "Align the YZ scale values to X scale value  \n The second click reset the scales values to 1.0", None))
        self.pushButton_3.setText(_translate("MainWindow", "...", None))

        self.doubleSpinBox.setToolTip(_translate("MainWindow", "Place the new object to the X coordinate ", None))
        self.doubleSpinBox.setSuffix(_translate("MainWindow", " mm", None))
        self.doubleSpinBox_2.setToolTip(_translate("MainWindow", "Place the new object to the Y coordinate", None))
        self.doubleSpinBox_2.setSuffix(_translate("MainWindow", " mm", None))
        self.doubleSpinBox_3.setToolTip(_translate("MainWindow", "Place the new object to the Z coordinate", None))
        self.doubleSpinBox_3.setSuffix(_translate("MainWindow", " mm", None))

        self.label_2.setText(_translate("MainWindow", "Coordinate X", None))
        self.label_3.setText(_translate("MainWindow", "Coordinate Y", None))
        self.label_4.setText(_translate("MainWindow", "Coordinate Z", None))

        self.groupBox_2.setTitle(_translate("MainWindow", "Scale predefined", None))
        self.comboBox.setToolTip(_translate("MainWindow", "Convert your object to . . .", None))
        self.comboBox.setCurrentIndex(6)
        self.comboBox.setItemText(0, _translate("MainWindow", "km", None))         #km #        = 1000000
        self.comboBox.setItemText(1, _translate("MainWindow", "hm", None))         #hm #        = 100000
        self.comboBox.setItemText(2, _translate("MainWindow", "dam", None))        #dam#        = 10000
        self.comboBox.setItemText(3, _translate("MainWindow", "m", None))          #m  #        = 1000
        self.comboBox.setItemText(4, _translate("MainWindow", "dm", None))         #dm #        = 100
        self.comboBox.setItemText(5, _translate("MainWindow", "cm", None))         #cm #        = 10
        self.comboBox.setItemText(6, _translate("MainWindow", "mm", None))         #mm #        = 1        #####
        self.comboBox.setItemText(7, _translate("MainWindow", "µm", None))         #µm # micro  = 0.001
        self.comboBox.setItemText(8, _translate("MainWindow", "nm", None))         #nm # nano   = 0.000001
        self.comboBox.setItemText(9, _translate("MainWindow", "inch", None))       #in # inch  pouce    = 25.400
        self.comboBox.setItemText(10, _translate("MainWindow", "link", None))      #lk # link  chainon  = 201.168
        self.comboBox.setItemText(11, _translate("MainWindow", "foot", None))      #ft # foot  pied     = 304.800
        self.comboBox.setItemText(12, _translate("MainWindow", "yard", None))      #yd # yard  verge    = 914.400
        self.comboBox.setItemText(13, _translate("MainWindow", "perch", None))     #rd # rod ou perch   perche   = 5029.200
        self.comboBox.setItemText(14, _translate("MainWindow", "chain", None))     #ch # chain chaine   = 20116.800
        self.comboBox.setItemText(15, _translate("MainWindow", "furlong", None))   #fur# furlong        = 201168
        self.comboBox.setItemText(16, _translate("MainWindow", "mile", None))      #mi # mile           = 1609344
        self.comboBox.setItemText(17, _translate("MainWindow", "league", None))    #lea# league lieue   = 4828032
        self.comboBox.setItemText(18, _translate("MainWindow", "nautique", None))  #nmi# mile nautique  = 1852000

        self.groupBox_3.setTitle(_translate("MainWindow", "Scale free", None))
        self.label_5.setText(_translate("MainWindow", "Scale X", None))
        self.label_6.setText(_translate("MainWindow", "Scale Y", None))
        self.label_7.setText(_translate("MainWindow", "Scale Z", None))

        self.pushButton.setToolTip(_translate("MainWindow", "Reset the values", None))
        self.pushButton.setText(_translate("MainWindow", "Reset", None))
        self.pushButton_1.setToolTip(_translate("MainWindow", "Ok for Convert Copy or Compount", None))
        self.pushButton_1.setText(_translate("MainWindow", "Ok", None))
        self.pushButton_2.setToolTip(_translate("MainWindow", "Quit the macro", None))
        self.pushButton_2.setText(_translate("MainWindow", "Quit", None))

        self.pushButton_6.setToolTip(_translate("MainWindow", "Give the valueAt() the subObject selected Face, Wire, Line ...\n"+
                                                "This option is useful in case a compound Placement information [0,0,0]\n"+
                                                "and its real location is away from the base coordinates 0,0,0\n"+
                                                "(gives no provide information about the tilt of the object)", None))
        self.pushButton_6.setText(_translate("MainWindow", "ValueAt()", None))

        self.groupBox_4.setTitle(_translate("MainWindow", "Rotation", None))
        self.label_8.setText(_translate("MainWindow", "Yaw ( Z )", None))
        self.label_9.setText(_translate("MainWindow", "Pitch ( Y )", None))
        self.label_10.setText(_translate("MainWindow", "Roll ( X )", None))
        self.doubleSpinBox_7.setSuffix(_translate("MainWindow", " Deg", None))
        self.doubleSpinBox_8.setSuffix(_translate("MainWindow", " Deg", None))
        self.doubleSpinBox_9.setSuffix(_translate("MainWindow", " Deg", None))

    def SIGNAL_comboBox_Changed(self,text):
        global uniteM_X
        global uniteM_Y
        global uniteM_Z
        global uniteM
        global uniteMs
 
        try:
            text = unicode(text, 'ISO-8859-1').encode('UTF-8')  # PyQt4
        except Exception:
            text = text.encode('utf-8')                         # PySide
 
        if text == "km":        #        = 1000000
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1000000.0
            uniteMs= "km"
        elif text == "hm":      #        = 100000
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 100000.0
            uniteMs= "hm"
        elif text == "dam":     #        = 10000
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 10000.0
            uniteMs= "dam"
        elif text == "m":       #        = 1000
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1000.0
            uniteMs= "m"
        elif text == "dm":      #        = 100
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 100.0
            uniteMs= "dm"
        elif text == "cm":      #        = 10
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 10.0
            uniteMs= "cm"
        elif text == "mm":      #        = 1  ###############################
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1.0
            uniteMs= "mm"
        elif text == "µm":      #        = 1000
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1.0/1000.0
            uniteMs= u"µm"
        elif text == "nm":      #        = 1000000
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1.0/1000000.0
            uniteMs= u"nm"
        elif text == "inch":    # inch   = 25.400
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 25.400
            uniteMs= "in"
        elif text == "link":    # link   = 201.168
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 201.168
            uniteMs= "lk"
        elif text == "foot":    # foot   = 304.800
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 304.800
            uniteMs= "ft"
        elif text == "yard":    # yard   = 914.400
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 914.400
            uniteMs= "yd"
        elif text == "perch":   #rd # rod   perche    = 5029.200
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 5029.200
            uniteMs= "rd"
        elif text == "chain":   # chain  = 20116.800
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 20116.800
            uniteMs= "ch"
        elif text == "furlong": # furlong= 201168
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 201168
            uniteMs= "fur"
        elif text == "mile":     # mile   = 1609344
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1609344
            uniteMs= "mi"
        elif text == "league":   # league = 4828032
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 4828032
            uniteMs= "lea"
        elif text == "nautique": # nautique = 1852000
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1852000
            uniteMs= "nmi"
        else:                    # mm = 1
            uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1.0 
            uniteMs= "mm"
 
        self.doubleSpinBox_4.setProperty("value", uniteM_X)
        self.doubleSpinBox_5.setProperty("value", uniteM_Y)
        self.doubleSpinBox_6.setProperty("value", uniteM_Z)
 
    def on_radioButton_clicked(self):                    # if checked then mode clone
        global cloneCopy
        cloneCopy = 1

    def on_radioButton_2_clicked(self):                  # if checked then mode copy
        global cloneCopy
        cloneCopy = 0

    def on_radioButton_3_clicked(self):                  # if checked then mode compount
        global cloneCopy
        cloneCopy = 2
 
    def on_doubleSpinBox_valueChanged(self,value):       # doubleSpinbox X
        global placement_X
        placement_X = value
 
    def on_doubleSpinBox_2_valueChanged(self,value):     # doubleSpinbox Y 
        global placement_Y
        placement_Y = value
 
    def on_doubleSpinBox_3_valueChanged(self,value):     #  doubleSpinbox Z
        global placement_Z
        placement_Z = value
 
    def on_doubleSpinBox_4_valueChanged(self,value):     # doubleSpinbox free X
        global uniteM_X
        uniteM_X = value
        if uniteM_X == 0:
            uniteM_X = 1
 
    def on_doubleSpinBox_5_valueChanged(self,value):     # doubleSpinbox free Y 
        global uniteM_Y
        uniteM_Y = value
        if uniteM_Y == 0:
            uniteM_Y = 1
 
    def on_doubleSpinBox_6_valueChanged(self,value):     #  doubleSpinbox free Z
        global uniteM_Z
        uniteM_Z = value
        if uniteM_Z == 0:
            uniteM_Z = 1
 
    def on_doubleSpinBox_7_valueChanged(self,value):     # doubleSpinBox_7  Yaw ( Z )
        global Yaw_Z
        Yaw_Z = value

    def on_doubleSpinBox_8_valueChanged(self,value):     # doubleSpinBox_8 Pitch ( Y )
        global Pitch_Y
        Pitch_Y = value

    def on_doubleSpinBox_9_valueChanged(self,value):     # doubleSpinBox_9 Roll ( X )
        global Roll_X
        Roll_X = value

    def on_pushButton_5_clicked(self):                   # Bouton ... (align) placement
        global placement_X
        global placement_Y
        global placement_Z
        global switchP

        if switchP == 0:
            placement_Y = placement_Z = placement_X
            switchP = 1
        else:
            placement_Y = placement_Z = placement_X = 0.0
            switchP = 0

        self.doubleSpinBox.setProperty("value", placement_X)
        self.doubleSpinBox_2.setProperty("value", placement_Y)
        self.doubleSpinBox_3.setProperty("value", placement_Z)

    def on_pushButton_6_clicked(self):                    # valueAt() placement detected
        try:
            sel = FreeCADGui.Selection.getSelection()
            App.Console.PrintMessage(str(sel[0].Placement) +"\r\n")
            selectionObjects = FreeCADGui.Selection.getSelectionEx()   # Select an object or sub object getSelectionEx
            edge = selectionObjects[0].SubObjects[0]
            try:
                self.lineEdit.setText(str(edge.valueAt(0,0))) # face
                self.pushButton_6.setText(_translate("MainWindow", "ValueAt(0,0)", None))
                App.Console.PrintMessage(str(edge.valueAt(0,0)) +"\r\n")
            except Exception:
                self.lineEdit.setText(str(edge.valueAt(0)))   # fil
                self.pushButton_6.setText(_translate("MainWindow", "ValueAt(0)", None))
                App.Console.PrintMessage(str(edge.valueAt(0)) +"\r\n")
        except Exception:
            self.pushButton_6.setText(_translate("MainWindow", "ValueAt()", None))
            App.Console.PrintError("Select one subObject, Face, Wire, Line ..."+"\r\n")
        App.Console.PrintMessage("____________________________________"+"\r\n")
        
    def on_pushButton_4_clicked(self):                   # Bouton ... (align) rotation
        global Yaw_Z
        global Pitch_Y
        global Roll_X
        global switchA

        if switchA == 0:
            Pitch_Y = Roll_X = Yaw_Z
            switchA = 1
        else:
            Pitch_Y = Roll_X = Yaw_Z = 0.0
            switchA = 0

        self.doubleSpinBox_7.setProperty("value", Yaw_Z)
        self.doubleSpinBox_8.setProperty("value", Pitch_Y)
        self.doubleSpinBox_9.setProperty("value", Roll_X)

    def on_pushButton03_clicked(self):                   # Bouton ... (align) uniteM
        global uniteM_X
        global uniteM_Y
        global uniteM_Z
        global switchS
        global uniteM
        global uniteMs

        if switchS == 0:
            uniteM_Y = uniteM_Z = uniteM_X
            switchS = 1
        else:
            uniteM_Y = uniteM_Z = uniteM_X = 1.0
            switchS = 0

        self.doubleSpinBox_4.setProperty("value", uniteM_X)
        self.doubleSpinBox_5.setProperty("value", uniteM_Y)
        self.doubleSpinBox_6.setProperty("value", uniteM_Z)
 
    def on_pushButton00_clicked(self):                   # Bouton Reset
        global sel
        global uniteM_X
        global uniteM_Y
        global uniteM_Z
        global uniteM
        global uniteMs
        global placement_X
        global placement_Y
        global placement_Z
        global cloneCopy
        global Yaw_Z
        global Pitch_Y
        global Roll_X
 
        sel         = ""
 
        self.pushButton_1.setToolTip(_translate("MainWindow", "Ok for Convert or copy", None))
        self.pushButton_1.setStyleSheet("background-color: Base")
 
        self.radioButton.setChecked(True)
        cloneCopy = 1
 
        self.comboBox.setCurrentIndex(6)
        self.doubleSpinBox.setProperty("value",   0.0) # coordinates
        self.doubleSpinBox_2.setProperty("value", 0.0)
        self.doubleSpinBox_3.setProperty("value", 0.0)
        self.checkBox.setChecked(True)

        placement_X = placement_Y = placement_Z = 0.0
 
        self.doubleSpinBox_4.setProperty("value", 1.0) # scale
        self.doubleSpinBox_5.setProperty("value", 1.0)
        self.doubleSpinBox_6.setProperty("value", 1.0)
 
        self.doubleSpinBox_7.setProperty("value", 0.0) # angles
        self.doubleSpinBox_8.setProperty("value", 0.0)
        self.doubleSpinBox_9.setProperty("value", 0.0)
 
        uniteM = uniteM_X = uniteM_Y = uniteM_Z = 1.0
        uniteMs= "mm"
        uniteM = 1
        self.lineEdit.setText("")
 
    def on_pushButton01_clicked(self):                   # Bouton OK
        global sel
        global surface
        global volume_
        global boundBox
        global boundBoxLX
        global boundBoxLY
        global boundBoxLZ
        global boundBox_S
        global uniteM_X
        global uniteM_Y
        global uniteM_Z
        global uniteM
        global uniteMs
        global placement_X
        global placement_Y
        global placement_Z
        global sel
        global Yaw_Z
        global Pitch_Y
        global Roll_X
 
        #### Chrono begin ######################################################################### chrono begin
        import time                                                                            #### chrono begin
        depart = time.clock()                                                                  #### chrono begin
        #### Chrono begin ######################################################################### chrono begin

        sel = FreeCADGui.Selection.getSelection()   
 
        if len(sel) != 0:
 
            self.pushButton_1.setToolTip(_translate("MainWindow", "Ok for Convert or copy", None))
            self.pushButton_1.setStyleSheet("background-color: Base")
 
             # boundinbox (dimensions hors tout)
            try:
                boundBox_ = sel[0].Shape.BoundBox # pour 1 seul objet, (le premier)
                boundBoxLX = boundBox_.XLength
                boundBoxLY = boundBox_.YLength
                boundBoxLZ = boundBox_.ZLength
            except:
                boundBox_  = 0.0
                boundBoxLX = 0.0
                boundBoxLY = 0.0
                boundBoxLZ = 0.0
                boundBox_S = ""
 
             # volume de tous les objets
            volume_ = 0.0
            try:
                for i in range(len(sel)):
                    volume_ += sel[i].Shape.Volume
            except:
                volume_ = 0.0
 
             # surface de tous les objets
            surface = 0.0
            try:
                for i in range(len(sel)):
                    surface += sel[i].Shape.Area
            except:
                surface = 0.0
 
            boundBox_S = "[X: "+str(boundBoxLX)+" mm] x [Y: "+str(boundBoxLY)+" mm] x [Z:"+str(boundBoxLZ)+" mm]"
            App.Console.PrintMessage("Original boundBox : "+boundBox_S+"\r\n")
            App.Console.PrintMessage("Original volume_  : "+str(volume_)+" mm3 ("+str(len(sel))+" element(s))"+"\r\n")
            App.Console.PrintMessage("Original surface  : "+str(surface)+" mm2 ("+str(len(sel))+" element(s))"+"\r\n")
            App.Console.PrintMessage("- - - - - - - - - -"+"\r\n")
 
            try:
                obj = ""
                if cloneCopy == 1:       # clone ok
                    import Draft
                    mess = "Clone"
                    obj=Draft.clone(sel)
                    obj.Scale = (uniteM_X, uniteM_Y, uniteM_Z)
                    if self.checkBox.isChecked(): # if checkbox is checked then .... increment
                        obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0)).multiply(App.activeDocument().getObject(obj.Name).Placement) # increment
                    else:
                        obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
                
                if cloneCopy == 0:     # copy ok
                    import Draft
                    mess = "Copy "
                    for i in range(len(sel)):
                        obj = Draft.scale(sel[i],delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0),copy=True,legacy=True)
                        if self.checkBox.isChecked(): # if checkbox is checked then .... increment
                            obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0)).multiply(App.activeDocument().getObject(obj.Name).Placement) # increment
                        else:
                            obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
                    obj.Label = "Copy of " + obj.Label
    
                if cloneCopy == 2:     # compound ok
                    import Draft
                    mess = "Compount "
                    liste = []
                     ########################################################################################################################
#                    objori = Draft.makeBlock(Gui.Selection.getSelection())                             # create Block other method compound
#                    obj = Draft.scale([objori],delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0))
#                    App.activeDocument().removeObject(objori.Name)
                     ########################################################################################################################

                    #######################################################################################################################
                    objori = App.activeDocument().addObject("Part::Compound","Compound")                # create method compound
                    for i in range(len(sel)):
                        objori.Links += App.activeDocument().getObject(sel[i].Name),
                        liste.append(sel[i].Name)
                    obj = Draft.scale([objori],delta=App.Vector(uniteM_X, uniteM_Y, uniteM_Z),center=App.Vector(0,0,0))
                    #######################################################################################################################

#                    try:                                                    # optional delette the original objects 
#                        App.activeDocument().removeObject(objori.Name)
#                        for i in liste:
#                            App.activeDocument().removeObject(i)
#                    except:
#                        None

                    if self.checkBox.isChecked():                           # if checkbox is checked then .... increment
                        obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0)).multiply(App.activeDocument().getObject(obj.Name).Placement) # increment
                    else:
                        obj.Placement=App.Placement(App.Vector(placement_X,placement_Y,placement_Z), App.Rotation(Yaw_Z,Pitch_Y,Roll_X), App.Vector(0,0,0))
                    obj.Label = "Compount of " + obj.Label
                    try:
                        objori.Label = "Ori " + obj.Label                    # renamme the original object
                    except Exception:
                        None

                FreeCAD.ActiveDocument.recompute()
    
#                print "[ ",placement_X," ",placement_Y," ",placement_Z," ]  [ ",Yaw_Z," ",Pitch_Y," ",Roll_X," ]"
                 # boundinbox (dimensions hors tout)
                try:
                    boundBox_ = obj.Shape.BoundBox
                    boundBoxLX = boundBox_.XLength
                    boundBoxLY = boundBox_.YLength
                    boundBoxLZ = boundBox_.ZLength
                except:
                    boundBox_  = 0.0
                    boundBoxLX = 0.0
                    boundBoxLY = 0.0
                    boundBoxLZ = 0.0
     
                 # volume
                volume_ = 0.0
                try:
                    volume_ = obj.Shape.Volume
                except:
                    for i in range(len(obj)):
                        volume_ += obj[i].Shape.Volume
     
                 # surface
                surface = 0.0
                try:
                    surface = obj.Shape.Area
                except:
                    for i in range(len(obj)):
                        surface += obj[i].Shape.Area
     
                App.Console.PrintMessage(obj.Label+"\r\n")
                App.Console.PrintMessage("Convert mm in ' "+uniteMs+" ' (1 "+uniteMs+" = "+str(uniteM)+" mm)"+"\r\n")
                App.Console.PrintMessage(mess + " boundBox_X  : "+str(boundBoxLX)+" mm"+"\r\n")
                App.Console.PrintMessage(mess + " boundBox_Y  : "+str(boundBoxLY)+" mm"+"\r\n")
                App.Console.PrintMessage(mess + " boundBox_Z  : "+str(boundBoxLZ)+" mm"+"\r\n")
                App.Console.PrintMessage(mess + " volume      : "+str(volume_)+" mm3 ("+str(len(sel))+" element(s))"+"\r\n")#
                App.Console.PrintMessage(mess + " surface     : "+str(surface)+" mm2 ("+str(len(sel))+" element(s))"+"\r\n")#
                #### Chrono end ########################################################################### chrono end
                arrivee = time.clock()                                                                 #### chrono end
                App.Console.PrintMessage("Time : "+str("%.2f" % ((arrivee - depart)/60))+" min"+"\r\n")#### chrono end
                #### Chrono end ########################################################################### chrono end
                App.Console.PrintMessage("___________________"+"\r\n")
                self.pushButton_1.setStyleSheet("background-color: green")

            except Exception:
                FreeCAD.Console.PrintError("Error interne"+"\r\n")
        else:
            self.pushButton_1.setStyleSheet("background-color: red")#red
            self.pushButton_1.setToolTip(_translate("MainWindow", "Not object selected for Convert or copy", None))

            FreeCAD.Console.PrintError("Select an object"+"\r\n")   #App.Console.PrintMessage
            sel = ""

    def on_pushButton02_clicked(self):                   # Bouton Quitter
        App.Console.PrintMessage("End CloneConvert\r\n")
        self.window.hide()
 
sel = FreeCADGui.Selection.getSelection()   
 
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow(MainWindow)

MainWindow.show()

Revision

30/01/2016 ver 0.7 rewriting code with Placement and Increment and adding buttons Compound, Increment, ValueAt(),

26/01/2016 ver 0.6 correction placement with many objets Copy

26/07/2015 ver 0.5 correction rotate many objects Function Copy

25/07/2015 ver 0.4 = adding rotation

11/08/2014 replace "AttributeError" to "Exception"

02/07/2014 ver. 0.3 = modified to operate PyQt4 and PySide

09/05/2014 ver. 0.2 = adding function "Copy"

Other languages: