FreeCAD-Doc/localwiki/Macro_Rotate_To_Point-fr.html
2018-07-19 18:47:02 -05:00

984 lines
50 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><title>Macro Rotate To Point/fr</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Rotate To Point/fr</h1></div>
<div id="mw-content-text" lang="fr" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
<tr>
<td class="ctTitle">
<h3><span class="mw-headline" id="Macro_Rotate_To_Point"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Rotate_To_Point.png" class="image"><img alt="Macro Rotate To Point.png" src="32px-Macro_Rotate_To_Point.png" width="32" height="30" srcset="Macro_Rotate_To_Point.png 1.5x" /></a> Macro Rotate To Point</span></h3>
</td></tr>
<tr>
<th class="ctOdd">Description
</th></tr>
<tr>
<td class="ctEven left">Macro pour effectuer une rotation d'un objet sur un point
</td></tr>
<tr>
<th class="ctOdd">Auteur
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Mario52" title="User:Mario52">Mario52</a>
</td></tr>
<tr>
<th class="ctOdd">Liens
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/fr" title="Macros recipes/fr">Recettes macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/fr" title="How to install macros/fr">Comment installer une macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/fr" title="Customize Toolbars/fr">Comment ajouter une barre d'outils</a>
</td></tr>
<tr>
<th class="ctOdd">Version
</th></tr>
<tr>
<td class="ctEven macro-version">00.03
</td></tr>
<tr>
<th class="ctOdd">Date dernière modification
</th></tr>
<tr>
<td class="ctEven macro-date">2018-03-29
</td></tr>
<tr>
<th class="ctOdd">
</th></tr>
<tr>
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#Macro_Rotate_To_Point"><span class="tocnumber">1</span> <span class="toctext">Macro Rotate To Point</span></a></li>
<li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">2</span> <span class="toctext">Description</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Utilisation"><span class="tocnumber">3</span> <span class="toctext">Utilisation</span></a></li>
<li class="toclevel-1 tocsection-3"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a></li>
<li class="toclevel-1 tocsection-4"><a href="#Exemple"><span class="tocnumber">5</span> <span class="toctext">Exemple</span></a></li>
<li class="toclevel-1 tocsection-5"><a href="#Liens"><span class="tocnumber">6</span> <span class="toctext">Liens</span></a></li>
<li class="toclevel-1 tocsection-6"><a href="#Version"><span class="tocnumber">7</span> <span class="toctext">Version</span></a></li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p>
<h2><span class="mw-headline" id="Description">Description</span></h2>
<p>Macro qui permet de faire une rotation d'un objet sur lui même avec pour axe de rotation le boundBox center, le centre massique ou le dernier point cliqué.
</p>
<h2><span class="mw-headline" id="Utilisation">Utilisation</span></h2>
<p>Lancez la macro sélectionnez un objet et choisissez votre option:
</p><p><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Rotate_To_Point_00.png" class="image" title="Interface Rotate to point"><img alt="Interface Rotate to point" src="Macro_Rotate_To_Point_00.png" width="333" height="364" /></a>
</p>
<div style="clear:both"></div>
<ul><li>Point Rotation
<ul><li>Bounbox Center&#160;: Sélection du boundBox center comme axe de rotation</li>
<li>Center of Mass&#160;: Sélection du Center Massique comme axe de rotation</li>
<li>Point Clicked&#160;: Sélection du dernier point de souris comme axe de rotation 1: sélectionnez votre objet 2: utilisez <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">CTRL</span> pour sélectionner un point qui n'est pas sur l'objet courant</li></ul></li>
<li>Axis Rotation
<ul><li>Rotation(Z) Yaw&#160;: axe Yaw</li>
<li>Rotation(Y) Pitch&#160;: axe Pitch</li>
<li>Rotation(X) Roll&#160;: axe Roll</li>
<li>DoubleSpinBox&#160;: Coordonnées X au point cliqué par la souris (modifiable uniquement avec le mode "Point Clicked")</li>
<li>DoubleSpinBox&#160;: Coordonnées Y au point cliqué par la souris (modifiable uniquement avec le mode "Point Clicked")</li>
<li>DoubleSpinBox&#160;: Coordonnées Z au point cliqué par la souris (modifiable uniquement avec le mode "Point Clicked")</li></ul></li>
<li>Position&#160;: Si cette case à cocher est sélectionné la rotation est désactivée, l'objet sera déplacé le long de l'axe sélectionné</li>
<li>Point&#160;: Si cette case à cocher est activée un point est créé pour visualiser le point de rotation de l'objet, axe&#160;: rouge X, vert Y, bleu Z</li>
<li>Line Edit&#160;: Affiche les coordonnées originales de l'objet sélectionné sur l'axe choisi + les données entrées dans le spinBox</li>
<li>Free&#160;: Si cette case à cocher est activée le bouton <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Apply</span> est cour circuité et la modification est exécutée et validée en temps réel</li>
<li>DoubleSpinBox&#160;: Entrée des modifications</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Apply</span>&#160;: Applque la modification de l'objet</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Quit</span>&#160;: Quitte la macro</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Original</span>&#160;: Après avoir fait une modification ce bouton remet l'objet à sa place originale (si vous n'avez pas désélectionné l'objet)</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;"> 0,0,0 </span>&#160;: Cette option place l'objet automatiquement aux coordonnéés de base 0, 0, 0</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Reset</span>&#160;: Reset les données dans la macro (même résultat que cliquer la souris dans la vue 3D)</li></ul>
<h2><span class="mw-headline" id="Script">Script</span></h2>
<p>Licône pour votre barre d'outils PNG <a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Rotate_To_Point.png" class="image"><img alt="Macro Rotate To Point.png" src="Macro_Rotate_To_Point.png" width="39" height="36" /></a> SVG <a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Rotate_To_Point.svg" class="image"><img alt="Macro Rotate To Point.svg" src="Macro_Rotate_To_Point.svg" width="51" height="51" /></a>
</p><p><b>Macro Rotate To Point.FCMacro</b>
</p>
<pre># -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2017 &lt;mario52&gt; *
* *
* This file is a supplement to the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this macro; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************
* WARNING! All changes in this file will be lost and *
* may cause malfunction of the program *
***************************************************************************
"""
#
#
#OS: Windows 10 #OS: Windows 10
#Word size of OS: 64-bit #Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit #Word size of FreeCAD: 64-bit
#Version: 0.16.6706 (Git) #Version: 0.17.13387 (Git)
#Build type: Release #Build type: Release
#Branch: releases/FreeCAD-0-16 #Branch: master
#Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0 #Hash: c5f4079252b11e3c54cd603be7d3697fa9f9d922
#Python version: 2.7.8 #Python version: 2.7.14
#Qt version: 4.8.7 #Qt version: 4.8.7
#Coin version: 4.0.0a #Coin version: 4.0.0a
#OCC version: 6.8.0.oce-0.17 #OCC version: 7.1.0
#
#
__title__ = "Macro_Rotate_To_Point"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__Wiki__ = "https://www.freecadweb.org/wiki/Macro_Rotate_To_Point"
__version__ = "00.03"
__date__ = "29/03/2018"
#
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
import Draft, Part, PartGui, FreeCADGui, FreeCAD
from FreeCAD import Base
import DraftVecUtils
import time
Gui = FreeCADGui
App = FreeCAD
global ui &#160;; ui = ""
global sourisPass &#160;; sourisPass = 0
global positionMouse&#160;; positionMouse = ""
global originalObject; originalObject = ""
global myObject &#160;; myObject = ""
global originalPlacement; originalPlacement = ""
global valeur &#160;; valeur = 0.0
global axisX &#160;; axisX = 0.0
global axisY &#160;; axisY = 0.0
global axisZ &#160;; axisZ = 0.0
global posX &#160;; posX = 0.0
global posY &#160;; posY = 0.0
global posZ &#160;; posZ = 0.0
global rotAngleX &#160;; rotAngleX = 0.0
global rotAngleY &#160;; rotAngleY = 0.0
global rotAngleZ &#160;; rotAngleZ = 0.0
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)
def errorDialog(msg):
diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg )
diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide # cette fonction met la fenetre en avant
diag.exec_()
class Ui_MainWindow(object):
def __init__(self ):
self.window = MainWindow
################################################
#self.path = FreeCAD.ConfigGet("AppHomePath")
#self.path = FreeCAD.ConfigGet("UserAppData")
#self.path = "your path"
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path
self.path = param.GetString("MacroPath","") + "/" # macro path
self.path = self.path.replace("\\","/")
print "Path for the icons&#160;: " , self.path
################################################
self.vueActive = FreeCADGui.ActiveDocument.ActiveView
self.click = self.vueActive.addEventCallback("SoMouseButtonEvent",self.souris)
def souris(self,info):
global sourisPass
if (info["Button"] == "BUTTON1") and (info["State"] == "DOWN"):
time.sleep(0.02)
sourisPass = 0
#print "ok"
def setupUi(self, MainWindow):
self.window = MainWindow
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(330, 330)
MainWindow.setMinimumSize(QtCore.QSize(330, 10))
MainWindow.setMaximumSize(QtCore.QSize(330, 330))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.fontGlobal_08 = QtGui.QFont() # pour compatibilite
self.fontGlobal_08.setFamily("Arial") # pour compatibilite
self.fontGlobal_08.setPointSize(8.0) # pour compatibilite
####
self.groupBox_Rotation = QtGui.QGroupBox(self.centralwidget)
self.groupBox_Rotation.setGeometry(QtCore.QRect(20, 20, 121, 91))
self.groupBox_Rotation.setFont(self.fontGlobal_08) #
self.groupBox_Rotation.setEnabled(False)
self.groupBox_Rotation.setObjectName(_fromUtf8("groupBox_Rotation"))
self.RB_Bond_Box_Center = QtGui.QRadioButton(self.groupBox_Rotation)
self.RB_Bond_Box_Center.setGeometry(QtCore.QRect(10, 20, 111, 17))
self.RB_Bond_Box_Center.setFont(self.fontGlobal_08) #
self.RB_Bond_Box_Center.setChecked(True)
self.RB_Bond_Box_Center.setObjectName(_fromUtf8("RB_Bond_Box_Center"))
self.RB_Bond_Box_Center.setToolTip("Point rotation on BoundBox Center")
self.RB_Bond_Box_Center.clicked.connect(self.on_RB_CenterRot)
self.RB_Center_Mass = QtGui.QRadioButton(self.groupBox_Rotation)
self.RB_Center_Mass.setGeometry(QtCore.QRect(10, 40, 111, 17))
self.RB_Center_Mass.setFont(self.fontGlobal_08) #
self.RB_Center_Mass.setObjectName(_fromUtf8("RB_Center_Mass"))
self.RB_Center_Mass.setToolTip("Point rotation on Center Mass")
self.RB_Center_Mass.clicked.connect(self.on_RB_CenterRot)
self.RB_Point_Clicked = QtGui.QRadioButton(self.groupBox_Rotation)
self.RB_Point_Clicked.setGeometry(QtCore.QRect(10, 60, 111, 17))
self.RB_Point_Clicked.setFont(self.fontGlobal_08) #
self.RB_Point_Clicked.setObjectName(_fromUtf8("RB_Point_Clicked"))
self.RB_Point_Clicked.setToolTip("Point rotation on Point Mouse clicked on the object"+"\n"
"If twoo points are clicked, the second point is used for axis rotation"+"\n"
"The point axis rotation Can be changed during the work as long as the object is selected"+"\n"
"For this press the CTRL KEY and click the new point rotation")
self.RB_Point_Clicked.clicked.connect(self.on_RB_CenterRot)
####
self.groupBox_Axis = QtGui.QGroupBox(self.centralwidget)
self.groupBox_Axis.setGeometry(QtCore.QRect(150, 20, 161, 91))
self.groupBox_Axis.setFont(self.fontGlobal_08) #
self.groupBox_Axis.setEnabled(False)
self.groupBox_Axis.setObjectName(_fromUtf8("groupBox_Axis"))
self.RB_Rotation_0 = QtGui.QRadioButton(self.groupBox_Axis)
self.RB_Rotation_0.setGeometry(QtCore.QRect(10, 60, 111, 17))
self.RB_Rotation_0.setFont(self.fontGlobal_08) #
self.RB_Rotation_0.setObjectName(_fromUtf8("RB_Rotation_0"))
self.RB_Rotation_0.setVisible(False)
# self.RB_Rotation_0.clicked.connect(self.on_RB_Rotation_0)
self.RB_Rotation_X = QtGui.QRadioButton(self.groupBox_Axis)
self.RB_Rotation_X.setGeometry(QtCore.QRect(10, 20, 111, 17))
self.RB_Rotation_X.setFont(self.fontGlobal_08) #
self.RB_Rotation_X.setChecked(True)
self.RB_Rotation_X.setObjectName(_fromUtf8("RB_Rotation_X"))
self.RB_Rotation_X.setToolTip("Rotation on Axis Yaw (Z)")
self.RB_Rotation_X.clicked.connect(self.on_RB_Rotation_X)
self.RB_Rotation_Y = QtGui.QRadioButton(self.groupBox_Axis)
self.RB_Rotation_Y.setGeometry(QtCore.QRect(10, 40, 111, 17))
self.RB_Rotation_Y.setFont(self.fontGlobal_08) #
self.RB_Rotation_Y.setObjectName(_fromUtf8("RB_Rotation_Y"))
self.RB_Rotation_Y.setToolTip("Rotation on Axis Pitch (Y)")
self.RB_Rotation_Y.clicked.connect(self.on_RB_Rotation_Y)
self.RB_Rotation_Z = QtGui.QRadioButton(self.groupBox_Axis)
self.RB_Rotation_Z.setGeometry(QtCore.QRect(10, 60, 111, 17))
self.RB_Rotation_Z.setFont(self.fontGlobal_08) #
self.RB_Rotation_Z.setObjectName(_fromUtf8("RB_Rotation_Z"))
self.RB_Rotation_Z.setToolTip("Rotation on Axis Roll (X)")
self.RB_Rotation_Z.clicked.connect(self.on_RB_Rotation_Z)
####
self.groupBox_Pos_Mouse = QtGui.QGroupBox(self.centralwidget)
self.groupBox_Pos_Mouse.setGeometry(QtCore.QRect(20, 120, 291, 51))
self.groupBox_Pos_Mouse.setFont(self.fontGlobal_08) #
self.groupBox_Pos_Mouse.setEnabled(False)
self.groupBox_Pos_Mouse.setObjectName(_fromUtf8("groupBox_Pos_Mouse"))
self.groupBox_Pos_Mouse.setToolTip("Position click mouse modification possible only with mode Point clicked")
self.DS_Pos_Mouse_X = QtGui.QDoubleSpinBox(self.groupBox_Pos_Mouse)
self.DS_Pos_Mouse_X.setGeometry(QtCore.QRect(10,20,82,22))
self.DS_Pos_Mouse_X.setFont(self.fontGlobal_08) #
self.DS_Pos_Mouse_X.setDecimals(6)
self.DS_Pos_Mouse_X.setSuffix(" X")
self.DS_Pos_Mouse_X.setObjectName(_fromUtf8("DS_Pos_Mouse_X"))
self.DS_Pos_Mouse_X.setToolTip("Position click mouse X" + "\n" +
"modification only with mode Point clicked")
self.DS_Pos_Mouse_X.valueChanged.connect(self.on_DS_Pos_Mouse_X)
self.DS_Pos_Mouse_Y = QtGui.QDoubleSpinBox(self.groupBox_Pos_Mouse)
self.DS_Pos_Mouse_Y.setGeometry(QtCore.QRect(105,20,91,22))
self.DS_Pos_Mouse_Y.setFont(self.fontGlobal_08) #
self.DS_Pos_Mouse_Y.setDecimals(6)
self.DS_Pos_Mouse_Y.setSuffix(" Y")
self.DS_Pos_Mouse_Y.setObjectName(_fromUtf8("DS_Pos_Mouse_Y"))
self.DS_Pos_Mouse_Y.setToolTip("Position click mouse Y" + "\n" +
"modification only with mode Point clicked")
self.DS_Pos_Mouse_Y.valueChanged.connect(self.on_DS_Pos_Mouse_Y)
self.DS_Pos_Mouse_Z = QtGui.QDoubleSpinBox(self.groupBox_Pos_Mouse)
self.DS_Pos_Mouse_Z.setGeometry(QtCore.QRect(200,20,82,22))
self.DS_Pos_Mouse_Z.setFont(self.fontGlobal_08) #
self.DS_Pos_Mouse_Z.setDecimals(6)
self.DS_Pos_Mouse_Z.setSuffix(" Z")
self.DS_Pos_Mouse_Z.setObjectName(_fromUtf8("DS_Pos_Mouse_Z"))
self.DS_Pos_Mouse_Z.setToolTip("Position click mouse Z" + "\n" +
"modification only with mode Point clicked")
self.DS_Pos_Mouse_Z.valueChanged.connect(self.on_DS_Pos_Mouse_Z)
####
self.SC_Slider_Bar = QtGui.QSlider(self.centralwidget)
self.SC_Slider_Bar.setGeometry(QtCore.QRect(20, 240, 291, 22))
self.SC_Slider_Bar.setFont(self.fontGlobal_08) #
self.SC_Slider_Bar.setMinimum(-360.0)
self.SC_Slider_Bar.setMaximum(360.0)
self.SC_Slider_Bar.setValue(0.0)
self.SC_Slider_Bar.setSliderPosition(0)
self.SC_Slider_Bar.setOrientation(QtCore.Qt.Horizontal)
self.SC_Slider_Bar.setObjectName(_fromUtf8("SC_Slider_Bar"))
self.SC_Slider_Bar.valueChanged.connect(self.on_SC_Slider_Bar)
self.LE_Increment = QtGui.QLineEdit(self.centralwidget)
self.LE_Increment.setGeometry(QtCore.QRect(20,210,121,22))
self.LE_Increment.setFont(self.fontGlobal_08) #
self.LE_Increment.setObjectName(_fromUtf8("LE_Increment"))
self.LE_Increment.setToolTip("Display the original Data + the modification")
self.LE_Increment.setReadOnly(True)
self.LE_Increment.setText(str(0.0))
#self.LE_Increment.returnPressed.connect(self.on_LE_Increment_Pressed)
self.LE_Increment.textChanged.connect(self.on_LE_Increment_Pressed)
self.DS_Scroll_Bar = QtGui.QDoubleSpinBox(self.centralwidget)
self.DS_Scroll_Bar.setGeometry(QtCore.QRect(150,210,91,22))
self.DS_Scroll_Bar.setFont(self.fontGlobal_08) #
self.DS_Scroll_Bar.setMinimum(-360.0)
self.DS_Scroll_Bar.setMaximum(360.0)
self.DS_Scroll_Bar.setDecimals(4)
self.DS_Scroll_Bar.setObjectName(_fromUtf8("DS_Scroll_Bar"))
self.DS_Scroll_Bar.setToolTip("Enter the modification")
self.DS_Scroll_Bar.valueChanged.connect(self.on_DS_Scroll_Bar)
self.PB_Apply = QtGui.QPushButton(self.centralwidget)
self.PB_Apply.setGeometry(QtCore.QRect(250, 210, 61, 23))
self.PB_Apply.setFont(self.fontGlobal_08) #
self.PB_Apply.setObjectName(_fromUtf8("PB_Apply"))
self.PB_Apply.setToolTip("Apply the modification")
self.PB_Apply.clicked.connect(self.on_PB_Apply_clicked)
self.CB_Position = QtGui.QCheckBox(self.centralwidget)
self.CB_Position.setGeometry(QtCore.QRect(20, 180, 71, 17))
self.CB_Position.setFont(self.fontGlobal_08) #
self.CB_Position.setEnabled(False)
self.CB_Position.setObjectName(_fromUtf8("CB_Position"))
self.CB_Position.setToolTip("Move the object to axis choice X, Y or Z")
self.CB_Position.clicked.connect(self.on_CB_Position)
self.CB_Point = QtGui.QCheckBox(self.centralwidget)
self.CB_Point.setGeometry(QtCore.QRect(150, 180, 51, 17))
self.CB_Point.setFont(self.fontGlobal_08) #
self.CB_Point.setEnabled(False)
self.CB_Point.setObjectName(_fromUtf8("CB_Point"))
self.CB_Point.setToolTip("If checked, create one point to visualise the point rotation")
self.CB_Point.clicked.connect(self.on_CB_Point)
self.CB_Free = QtGui.QCheckBox(self.centralwidget)
self.CB_Free.setGeometry(QtCore.QRect(270, 180, 71, 17))
self.CB_Free.setFont(self.fontGlobal_08) #
self.CB_Free.setEnabled(False)
self.CB_Free.setObjectName(_fromUtf8("CB_Free"))
self.CB_Free.setToolTip("This checkBox switch the Application button")
# self.CB_Free.clicked.connect(self.on_CB_Free)
self.label_00 = QtGui.QLabel(self.centralwidget)
self.label_00.setGeometry(QtCore.QRect(22, 261, 291, 16))
self.label_00.setFont(self.fontGlobal_08) #
self.label_00.setStyleSheet("color&#160;: #ffffff; background-color: red; font: bold 10px;") # white red bold
#self.label_00.setToolTip("Display the modification Axis and Rotation or Position")
self.label_00.setObjectName(_fromUtf8("label_00"))
self.PB_Quit = QtGui.QPushButton(self.centralwidget)
self.PB_Quit.setGeometry(QtCore.QRect(20, 280, 65, 23))
self.PB_Quit.setFont(self.fontGlobal_08) #
self.PB_Quit.setObjectName(_fromUtf8("PB_Quit"))
self.PB_Quit.setToolTip("Quite the macro")
self.PB_Quit.clicked.connect(self.on_PB_Quit_clicked)
self.PB_Original = QtGui.QPushButton(self.centralwidget)
self.PB_Original.setGeometry(QtCore.QRect(95, 280, 65, 23))
self.PB_Original.setFont(self.fontGlobal_08) #
self.PB_Original.setObjectName(_fromUtf8("PB_Original"))
self.PB_Original.setToolTip("Move the object to the original position")
self.PB_Original.clicked.connect(self.on_PB_Original_clicked)
self.PB_Zero = QtGui.QPushButton(self.centralwidget)
self.PB_Zero.setGeometry(QtCore.QRect(171, 280, 65, 23))
self.PB_Zero.setFont(self.fontGlobal_08) #
self.PB_Zero.setObjectName(_fromUtf8("PB_Zero"))
self.PB_Zero.setToolTip("Move the object to the base coordinates 0, 0, 0")
self.PB_Zero.clicked.connect(self.on_PB_Zero_clicked)
self.PB_Reset = QtGui.QPushButton(self.centralwidget)
self.PB_Reset.setGeometry(QtCore.QRect(247, 280, 65, 23))
self.PB_Reset.setFont(self.fontGlobal_08) #
self.PB_Reset.setObjectName(_fromUtf8("PB_Reset"))
self.PB_Reset.setToolTip("Reset the complete data macro")
self.PB_Reset.clicked.connect(self.on_PB_Reset_clicked)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # this function turns the front window (stay to hint)
MainWindow.setWindowTitle("Macro_Rotate_To_Point")
self.groupBox_Axis.setTitle("Axis Rotation")
self.RB_Rotation_Z.setText("Rotation(X) Roll")
self.RB_Rotation_Y.setText("Rotation(Y) Pitch")
self.RB_Rotation_X.setText("Rotation(Z) Yaw")
self.groupBox_Rotation.setTitle("Point Rotation")
self.groupBox_Pos_Mouse.setTitle("Coordinates Point clicked")
self.RB_Center_Mass.setText("Center of Mass")
self.RB_Point_Clicked.setText("Point clicked")
self.RB_Bond_Box_Center.setText("Bounbox Center")
self.CB_Position.setText("Position")
self.CB_Point.setText("Point")
self.CB_Free.setText("Free")
self.PB_Apply.setText("Apply")
self.PB_Original.setText("Original")
self.PB_Reset.setText("Reset")
self.PB_Quit.setText("Quit")
self.PB_Zero.setText("0,0,0")
self.label_00.setText(" Select one Object")
def on_DS_Pos_Mouse_X(self,val):
global positionMouse
global axisX
positionMouse = [val, positionMouse[1], positionMouse[2]]
axisX = positionMouse[0]
# print "on_DS_Pos_Mouse_X ", val
def on_DS_Pos_Mouse_Y(self,val):
global positionMouse
global axisY
positionMouse = [positionMouse[0], val, positionMouse[2]]
axisY = positionMouse[1]
# print "on_DS_Pos_Mouse_Y ", val
def on_DS_Pos_Mouse_Z(self,val):
global positionMouse
global axisZ
positionMouse = [positionMouse[0], positionMouse[1], val]
axisZ = positionMouse[2]
# print "on_DS_Pos_Mouse_Z ", val
def on_SC_Slider_Bar(self,val):
global ui
global valeur
global myObject
if myObject&#160;!= "":
valeur = val
self.DS_Scroll_Bar.setValue(valeur)
self.SC_Slider_Bar.setValue(valeur)
if self.CB_Free.isChecked():
ff = ui
ff.on_PB_Apply_clicked()
else:
self.DS_Scroll_Bar.setValue(0.0)
self.SC_Slider_Bar.setValue(0.0)
# print "on_SC_Scroll_Bar ", valeur
def on_DS_Scroll_Bar(self,val):
global valeur
global myObject
global axisX, axisY, axisZ
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
if myObject == "":
self.DS_Scroll_Bar.setValue(0.0)
self.SC_Slider_Bar.setValue(0.0)
None
else:
valeur = val
self.SC_Slider_Bar.setValue(valeur)
if self.CB_Position.isChecked(): # translate
if self.RB_Rotation_X.isChecked():
posX = valeur
posY = posZ = 0.0
self.LE_Increment.setText(str(round(myObject.Placement.Base[0],4) + valeur))
elif self.RB_Rotation_Y.isChecked():
posY = valeur
posX = posZ = 0.0
self.LE_Increment.setText(str(round(myObject.Placement.Base[1],4) + valeur))
elif self.RB_Rotation_Z.isChecked():
posZ = valeur
posX = posY = 0.0
self.LE_Increment.setText(str(round(myObject.Placement.Base[2],4) + valeur))
self.label_00.setText("[Pos=(" + str(round(myObject.Placement.Base[0],2))+" , " +
str(round(myObject.Placement.Base[1],2))+" , " +
str(round(myObject.Placement.Base[2],2))+")] " +
"[Axis=("+ str(round(axisX,2)) + " , " + str(round(axisY,2)) + " , " + str(round(axisZ,2)) + ")]")
else: # rotation
if self.RB_Rotation_X.isChecked():
rotAngleX = valeur
rotAngleY = rotAngleZ = 0.0
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[0],4) + valeur))
elif self.RB_Rotation_Y.isChecked():
rotAngleY = valeur
rotAngleZ = rotAngleX = 0.0
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[1],4) + valeur))
elif self.RB_Rotation_Z.isChecked():
rotAngleZ = valeur
rotAngleX = rotAngleY = 0.0
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[2],4) + valeur))
# self.label_00.setText("[Rot=(" + str(round(rotAngleX,2)) + " , " + str(round(rotAngleY,2)) + " , " + str(round(rotAngleZ,2)) + ")] " +
# "[Axis=("+ str(round(axisX,2)) + " , " + str(round(axisY,2)) + " , " + str(round(axisZ,2)) + ")]")
# print "on_DS_Scroll_Bar ", valeur
def on_LE_Increment_Pressed(self,text):
None
# print "on_lineEdit_1_Pressed"
def on_PB_Apply_clicked(self):
global valeur
global myObject
global positionMouse
global originalPlacement
global originalObject
global axisX, axisY, axisZ
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
if (myObject == "")&#160;:
self.label_00.setStyleSheet("color&#160;: #ffffff; background-color: red; font: bold 10px;") # white red bold
self.label_00.setText(" Select one Object")
FreeCAD.Console.PrintError("Select one Object" + "\n")
else:
if self.CB_Position.isChecked(): # translate
myObject.Placement = App.Placement(App.Vector(posX, posY, posZ), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)).multiply(App.ActiveDocument.getObject(myObject.Name).Placement)
if self.RB_Rotation_X.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[0],4)))
elif self.RB_Rotation_Y.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[1],4)))
elif self.RB_Rotation_Z.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[2],4)))
self.label_00.setText("[Pos=(" + str(round(myObject.Placement.Base[0],2))+" , " +
str(round(myObject.Placement.Base[1],2))+" , " +
str(round(myObject.Placement.Base[2],2))+")] " +
"[Axis=("+ str(round(axisX,2)) + " , " + str(round(axisY,2)) + " , " + str(round(axisZ,2)) + ")]")
else: # rotation
myObject.Placement = App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(rotAngleX, rotAngleY, rotAngleZ), App.Vector(axisX, axisY, axisZ)).multiply(App.ActiveDocument.getObject(myObject.Name).Placement)
if self.RB_Rotation_X.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[0],4)))
elif self.RB_Rotation_Y.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[1],4)))
elif self.RB_Rotation_Z.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[2],4)))
self.label_00.setText("[Rot=(" + str(round(myObject.Placement.Rotation.toEuler()[0],2)) + " , " +
str(round(myObject.Placement.Rotation.toEuler()[1],2)) + " , " +
str(round(myObject.Placement.Rotation.toEuler()[2],2)) + ")] " +
"[Axis=("+ str(round(axisX,2))+" , "+ str(round(axisY,2))+" , "+ str(round(axisZ,2))+")]")
# FreeCAD.ActiveDocument.recompute()
# print "on_PB_Apply_clicked"
def on_RB_Rotation_0(self):
None
# print "on_RB_Rotation_0"
def on_RB_Rotation_X(self):
global myObject
if self.CB_Position.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[0],4))) # pos X
else:
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[0],4))) # yaw = Z
self.DS_Scroll_Bar.setValue(0.0)
# print "on_RB_Rotation_X"
def on_RB_Rotation_Y(self):
global myObject
if self.CB_Position.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[1],4))) # pos Y
else:
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[1],4))) # pitch= Y
self.DS_Scroll_Bar.setValue(0.0)
# print "on_RB_Rotation_Y"
def on_RB_Rotation_Z(self):
global myObject
if self.CB_Position.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[2],4))) # pos Z
else:
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[2],4))) # roll = X
self.DS_Scroll_Bar.setValue(0.0)
# print "on_RB_Rotation_Z"
def on_RB_CenterRot(self): # zero
global myObject
global positionMouse
global axisX, axisY, axisZ
try:
self.groupBox_Pos_Mouse.setEnabled(False)
if self.RB_Bond_Box_Center.isChecked(): # axis
axisX = myObject.Shape.BoundBox.Center.x
axisY = myObject.Shape.BoundBox.Center.y
axisZ = myObject.Shape.BoundBox.Center.z
if self.CB_Point.isChecked():
point = Draft.makePoint(myObject.Shape.BoundBox.Center.x, myObject.Shape.BoundBox.Center.y, myObject.Shape.BoundBox.Center.z)
point.ViewObject.PointColor = (1.0,0.0,0.0)
point.Label = "Point_BoundBox_Center"
elif self.RB_Center_Mass.isChecked():
axisX = myObject.Shape.CenterOfMass.x
axisY = myObject.Shape.CenterOfMass.y
axisZ = myObject.Shape.CenterOfMass.z
if self.CB_Point.isChecked():
point = Draft.makePoint(myObject.Shape.CenterOfMass.x, myObject.Shape.CenterOfMass.y, myObject.Shape.CenterOfMass.z)
point.ViewObject.PointColor = (0.0,1.0,0.0)
point.Label = "Point_CenterOfMass"
elif self.RB_Point_Clicked.isChecked():
axisX = positionMouse[0]
axisY = positionMouse[1]
axisZ = positionMouse[2]
self.groupBox_Pos_Mouse.setEnabled(True)
if self.CB_Point.isChecked():
point = Draft.makePoint(positionMouse[0], positionMouse[1], positionMouse[2])
point.ViewObject.PointColor = (0.0,0.0,1.0)
point.Label = "Point_positionMouse"
except Exception:
self.label_00.setText("Error CenterRot_0")
FreeCAD.Console.PrintError("Error CenterRot_0" + "\n" + "or Bad selection" + "\n")
# print "on_RB_CenterRot"
def on_CB_Position(self):
global myObject
global posX, posY, posZ
global axisX, axisY, axisZ
if self.CB_Position.isChecked():
self.groupBox_Rotation.setEnabled(False)
self.RB_Bond_Box_Center.setChecked(True)
self.SC_Slider_Bar.setMinimum(-1000)
self.SC_Slider_Bar.setMaximum(1000)
self.DS_Scroll_Bar.setMinimum(-1000)
self.DS_Scroll_Bar.setMaximum(1000)
self.groupBox_Axis.setTitle("Axis Direction")
self.RB_Rotation_Z.setText("Direction Z ") # translate
self.RB_Rotation_Y.setText("Direction Y ")
self.RB_Rotation_X.setText("Direction X ")
try:
self.label_00.setText("[Pos=(" + str(round(myObject.Placement.Base[0],2)) + " , " +
str(round(myObject.Placement.Base[1],2)) + " , " +
str(round(myObject.Placement.Base[2],2)) + ")] " +
"[Axis=("+ str(round(axisX,2)) + " , " + str(round(axisY,2)) + " , " + str(round(axisZ,2)) + ")]")
if self.RB_Rotation_X.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[0],4)))
elif self.RB_Rotation_Y.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[1],4)))
elif self.RB_Rotation_Z.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Base[2],4)))
except Exception:
self.label_00.setText("Error Position_0")
FreeCAD.Console.PrintError("Error Position_0" + "\n" + "or Bad selection" + "\n")
else:
self.groupBox_Rotation.setEnabled(True)
self.SC_Slider_Bar.setMinimum(-360)
self.SC_Slider_Bar.setMaximum(360)
self.DS_Scroll_Bar.setMinimum(-360)
self.DS_Scroll_Bar.setMaximum(360)
self.groupBox_Axis.setTitle("Axis Rotation")
self.RB_Rotation_Z.setText("Rotation(X) Roll") # rotation
self.RB_Rotation_Y.setText("Rotation(Y) Pitch")
self.RB_Rotation_X.setText("Rotation(Z) Yaw")
try:
self.label_00.setText("[Rot=(" + str(round(myObject.Placement.Rotation.toEuler()[0],2)) + " , " +
str(round(myObject.Placement.Rotation.toEuler()[1],2)) + " , " +
str(round(myObject.Placement.Rotation.toEuler()[2],2)) + ")] " +
"[Axis=("+str(round(axisX,2))+" , "+ str(round(axisY,2))+" , "+ str(round(axisZ,2))+")]")
if self.RB_Rotation_X.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[0],4)))
elif self.RB_Rotation_Y.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[1],4)))
elif self.RB_Rotation_Z.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[2],4)))
except Exception:
self.label_00.setText("Error Position_1")
FreeCAD.Console.PrintError("Error Position_0" + "\n" + "or Bad selection" + "\n")
self.DS_Scroll_Bar.setValue(0.0)
# print "on_CB_Position"
def on_CB_Point(self):
global ui
ff = ui
ff.on_RB_CenterRot()
# print "on_CB_Point"
def on_PB_Zero_clicked(self):
global myObject
if (myObject&#160;!= ""):
try:
# pl = App.Placement(App.Vector(10.0,10.0,10.0), App.Rotation(0.0, 0.0, 0.0), App.Vector(0.0, 0.0, 0.0))
pl = App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(0.0, 0.0, 0.0), App.Vector(0.0, 0.0, 0.0))
myObject.Placement = pl
# FreeCAD.ActiveDocument.recompute()
if self.RB_Rotation_X.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[0],4)))
elif self.RB_Rotation_Y.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[1],4)))
elif self.RB_Rotation_Z.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[2],4)))
self.label_00.setText("[Rot=(" +str(round(myObject.Placement.Rotation.toEuler()[0],2))+" , "+str(round(myObject.Placement.Rotation.toEuler()[1],2))+" , "+ str(round(myObject.Placement.Rotation.toEuler()[2],2))+")] "+
"[Axis=("+str(round(myObject.Placement.Base.x,2))+" , "+ str(round(myObject.Placement.Base.y,2))+" , "+ str(round(myObject.Placement.Base.z,2))+")]")
self.DS_Scroll_Bar.setValue(0.0)
self.LE_Increment.setText(str(0.0))
# FreeCAD.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewTop()
Gui.SendMsgToActiveView("ViewFit")
except Exception:
self.label_00.setText("Error Zero_0")
FreeCAD.Console.PrintError("Error Zero_0" + "\n" + "or Bad selection" + "\n")
else:
self.label_00.setStyleSheet("color&#160;: #ffffff; background-color: red; font: bold 10px;") # white red bold
self.label_00.setText(" Select one Object")
FreeCAD.Console.PrintError("Select one Object" + "\n")
# print "on_PB_Zero_clicked"
def on_PB_Original_clicked(self):
global ui
global myObject
global originalPlacement
global axisX, axisY, axisZ
global rotAngleX, rotAngleY, rotAngleZ
if (myObject&#160;!= ""):
try:
rotAngleX = rotAngleY = rotAngleZ = 0.0
myObject.Placement = originalPlacement
self.DS_Scroll_Bar.setValue(0.0)
if self.RB_Rotation_X.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[0],4))) # yaw Z
elif self.RB_Rotation_Y.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[1],4))) # pitch Y
elif self.RB_Rotation_Z.isChecked():
self.LE_Increment.setText(str(round(myObject.Placement.Rotation.toEuler()[2],4))) # roll Z
ff = ui
ff.on_RB_CenterRot()
self.label_00.setText("[Rot=(" +str(round(myObject.Placement.Rotation.toEuler()[0],2))+" , "+str(round(myObject.Placement.Rotation.toEuler()[1],2))+" , "+ str(round(myObject.Placement.Rotation.toEuler()[2],2))+")] "+
"[Axis=("+str(round(axisX,2))+" , "+ str(round(axisY,2))+" , "+ str(round(axisZ,2))+")]")
# FreeCAD.ActiveDocument.recompute()
except Exception:
self.label_00.setText("Error Original_0")
FreeCAD.Console.PrintError("Error Original_0" + "\n" + "or Bad selection" + "\n")
else:
self.label_00.setStyleSheet("color&#160;: #ffffff; background-color: red; font: bold 10px;") # white red bold
self.label_00.setText(" Select one Object")
FreeCAD.Console.PrintError("Select one Object" + "\n")
# print "on_PB_Original_clicked"
def on_PB_Reset_clicked(self):
global originalObject
global myObject
global valeur
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
global axisX, axisY, axisZ
try:
for obj in FreeCAD.ActiveDocument.Objects: # deslectionne
FreeCADGui.Selection.removeSelection(obj)
except Exception:
None
originalObject = myObject = ""
posX = posY = posZ = rotAngleX = rotAngleY = rotAngleZ = 0.0
axisX = axisY = axisZ = 0.0
valeur = 0.0
self.DS_Scroll_Bar.setValue(0.0)
self.LE_Increment.setText(str(0.0))
self.groupBox_Axis.setTitle("Axis Rotation")
self.RB_Rotation_Z.setText("Rotation(X) Roll")
self.RB_Rotation_Y.setText("Rotation(Y) Pitch")
self.RB_Rotation_X.setText("Rotation(Z) Yaw")
self.groupBox_Rotation.setEnabled(False)
self.groupBox_Axis.setEnabled(False)
self.groupBox_Pos_Mouse.setEnabled(False)
self.DS_Pos_Mouse_X.setValue(0.0)
self.DS_Pos_Mouse_Y.setValue(0.0)
self.DS_Pos_Mouse_Z.setValue(0.0)
self.CB_Position.setEnabled(False)
self.CB_Position.setChecked(False)
self.CB_Point.setEnabled(False)
self.CB_Point.setChecked(False)
self.CB_Free.setEnabled(False)
self.CB_Free.setChecked(False)
self.label_00.setStyleSheet("color&#160;: #ffffff; background-color: red; font: bold 10px;") # white red bold
self.label_00.setText(" Select one Object")
FreeCAD.Console.PrintError("Select one Object" + "\n")
FreeCAD.Console.PrintMessage("Reset" + "\n")
def on_PB_Quit_clicked(self):
self.vueActive.removeEventCallback("SoMouseButtonEvent",self.click) # desinstalle la fonction souris
FreeCADGui.Selection.removeObserver(s) # desinstalle la fonction residente
self.window.hide() # hide the window and close the macro
FreeCAD.Console.PrintMessage("Quit Rotate_To_Point" + "\n")
###################################################################################################
class SelObserver:
def addSelection(self, document, object, element, position): # Selection
global ui
global sourisPass
global positionMouse
global originalObject
global myObject
global originalPlacement
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
global axisX, axisY, axisZ
if sourisPass == 0: # pour un seul passage
sourisPass == 1
sel = FreeCADGui.Selection.getSelection()[0] # select object with getSelection()
positionMouse = position
originalObject = myObject = sel
originalPlacement = sel.Shape.Placement
#longueur = (myObject.Shape.BoundBox.XLength * 0.5) # pour Axis
positionBase = originalObject.Shape.Placement.Base # Placement Vector XYZ
posX = positionBase.x
posY = positionBase.y
posZ = positionBase.z
Yaw = originalObject.Shape.Placement.Rotation.toEuler()[0] # decode angle Euler Yaw
Pitch = originalObject.Shape.Placement.Rotation.toEuler()[1] # decode angle Euler Pitch
Roll = originalObject.Shape.Placement.Rotation.toEuler()[2] # decode angle Euler Roll
rotAngleX = Yaw
rotAngleY = Pitch
rotAngleZ = Roll
axisX = axisY = axisZ = 0.0
ff = ui
ff.DS_Pos_Mouse_X.setValue(positionMouse[0])
ff.DS_Pos_Mouse_Y.setValue(positionMouse[1])
ff.DS_Pos_Mouse_Z.setValue(positionMouse[2])
ff.on_RB_CenterRot()
ff.groupBox_Rotation.setEnabled(True)
ff.groupBox_Axis.setEnabled(True)
#ff.groupBox_Pos_Mouse.setEnabled(True)
ff.CB_Position.setEnabled(True)
ff.CB_Point.setEnabled(True)
ff.CB_Free.setEnabled(True)
ff.label_00.setStyleSheet("Base") # origin system
ff.label_00.setText("[Rot =(" + str(round(rotAngleX,2))+ " , " + str(round(rotAngleY,2)) + " , " + str(round(rotAngleZ,2)) + ")] " +
"[Axis=("+ str(round(axisX,2)) + " , " + str(round(axisY,2)) + " , " + str(round(axisZ,2)) + ")]")
def clearSelection(self,doc): # Si clic sur l'ecran, effacer la selection
global ui
ff = ui
ff.on_PB_Reset_clicked()
###################################################################################################
doc = FreeCAD.ActiveDocument
if doc == None:
doc = FreeCAD.newDocument()
try:
for obj in FreeCAD.ActiveDocument.Objects: # deslectionne
FreeCADGui.Selection.removeSelection(obj)
except Exception:
None
s=SelObserver()
FreeCADGui.Selection.addObserver(s) # installe la fonction en mode resident
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show() </pre>
<h2><span class="mw-headline" id="Exemple">Exemple</span></h2>
<p><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Rotate_To_Point_01.gif" class="image"><img alt="Macro Rotate To Point 01.gif" src="Macro_Rotate_To_Point_01.gif" width="649" height="292" /></a>
</p>
<h2><span class="mw-headline" id="Liens">Liens</span></h2>
<p>The forum <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/viewtopic.php?f=8&amp;t=20925">feature req: placement - rotate part around its midpoint</a>
Mes macro sur Gist <a rel="nofollow" class="external text" href="https://gist.github.com/mario52a">mario52a </a>
</p>
<h2><span class="mw-headline" id="Version">Version</span></h2>
<p>29/03/2018 ver 00.03&#160;: commenter les lignes "FreeCAD.ActiveDocument.recompute()" le changement de valeur est trop lente dans FreeCAD 0.17.... voir <a rel="nofollow" class="external text" href="https://www.forum.freecadweb.org/viewtopic.php?f=10&amp;t=27732&amp;p=224195#p224195">FC0.17 recompute strange behaviour (regression)</a>
</p><p>27/03/2017 ver 00.02&#160;: modification du spinbox "Pos" maintenant accepte les valeurs négatives
</p><p>05/03/2017 ver 00.01&#160;: ajout de 3 boîtes de dialogue pour afficher les coordonnées X Y Z au clic de souris
</p><p>04/03/2017 ver 00.00
</p>
</div>
</div>
</div><div class="printfooter">
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Rotate_To_Point/fr&amp;oldid=270939">http://www.freecadweb.org/wiki/index.php?title=Macro_Rotate_To_Point/fr&amp;oldid=270939</a>"</div>
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
</body></html>