Skip to content

Instantly share code, notes, and snippets.

@mario52a
Last active October 17, 2022 18:52
Show Gist options
  • Save mario52a/2fc48333deca5a31e6232c29a9db5e4c to your computer and use it in GitHub Desktop.
Save mario52a/2fc48333deca5a31e6232c29a9db5e4c to your computer and use it in GitHub Desktop.
Macro for rotate on object on itself with the axis of rotation the boundbox center, center of mass or last point clicked and save the coordinate in a complete macro file for simulate the animation
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2017 2018 2019 2020 2021 2022 <mario52> *
* *
* 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. *
** **
* Use at your own risk. The author assumes no liability for data loss. *
* It is advised to backup your data frequently. *
* If you do not trust the software do not use it. *
** **
* *
* 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 Version 2009
#Word size of FreeCAD: 64-bit
#Version: 0.21.30492 (Git)
#Build type: Release
#Branch: master
#Hash: b4578fb3eae842eb510a1bc055d07d369a67ce94
#Python 3.8.13, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
#Locale: French/Mars (fr_Ma)
#
#
__title__ = "Rotate_To_Point"
__author__ = "Mario52"
__url__ = "https://www.freecadweb.org/"
__Wiki__ = "https://www.freecadweb.org/wiki/Macro_Rotate_To_Point"
__version__ = "00.11"
__date__ = "2022/10/17" #YYYY/MM/DD
#
#
import PySide2
from PySide2 import (QtWidgets, QtCore, QtGui)
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import QComboBox
#from PySide2.QtWidgets import (QWidget, QApplication, QSlider, QGraphicsView, QGraphicsScene, QVBoxLayout, QStyle, QListWidget)
#from PySide2.QtCore import QDate
#from PySide2.QtGui import (QPainter, QColor, QIcon, QBrush, QPalette)
from PySide2.QtSvg import *
import unicodedata
import re
import operator
from operator import itemgetter, attrgetter, methodcaller # pour sort
import Draft, Part, PartGui, FreeCADGui, FreeCAD
from FreeCAD import Base
import DraftVecUtils
import time, os
Gui = FreeCADGui
App = FreeCAD
global ui ; ui = ""
global sourisPass ; sourisPass = 0
global positionMouse ; positionMouse = ""
global selM ; selM = ""
global originalObject; originalObject = ""
global myObject ; myObject = ""
global myObjectName ; myObjectName = ""
global myObjectLabel ; myObjectLabel = ""
global originalPlacement; originalPlacement = ""
global valeur ; valeur = 0.0
global posX ; posX = 0.0
global posY ; posY = 0.0
global posZ ; posZ = 0.0
global rotAngleX ; rotAngleX = 0.0
global rotAngleY ; rotAngleY = 0.0
global rotAngleZ ; rotAngleZ = 0.0
global axisX ; axisX = 0.0
global axisY ; axisY = 0.0
global axisZ ; axisZ = 0.0
global posFollow ; posFollow = []
global compPosFollow ; compPosFollow = 0
global saveOnDisk ; saveOnDisk = []
global saveListView ; saveListView = ""
global memorySelected; memorySelected = []
global countMemory ; countMemory = 0
global duplicate_Memory ;duplicate_Memory = []
global duplicate_View; duplicate_View = []
global s ; s = ""
##path###########################################################################
global path, path2 #
#path = FreeCAD.ConfigGet("AppHomePath") # path FreeCAD installation
#path = FreeCAD.ConfigGet("UserAppData") # path FreeCAD User data
#path = "your path" # your directory path
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path
path = param.GetString("MacroPath","") + "/" # macro path
path = path.replace("\\","/") # convert the "\" to "/"
#print( "Path for the icons : " , path ) #
#################################################################################
global pathFile
#### Configuration begin ##############################################################
pathFile = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__ ).GetString("setLastPath")
if pathFile == "":
pathFile = path
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("setLastPath",pathFile)
####
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("Version",__version__ + " (" + __date__ + ")")
global switchZoomOnCilck
switchZoomOnCilck = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switchZoomOnCilck")
if switchZoomOnCilck == 0:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchZoomOnCilck", switchZoomOnCilck)
#### Configuration end ##############################################################
#### wiki help page ####
import WebGui
#def on_PB_Help(self): #
# WebGui.openBrowser("http://www.freecadweb.org/wiki/index.php?title=xxxx")
# App.Console.PrintMessage("http://www.freecadweb.org/wiki/index.php?title=xxxx" + "\n")
#### wiki help page ####
#### Detect version macro ###########################################
global switchVersionMacroSearch#; switchVersionMacroSearch = False
try:
def versionSearch():
import urllib
import requests
contentPage = requests.get("https://wiki.freecadweb.org/Macro_" + __title__).text
for i in contentPage.split("\n"): # list page to line
if "ctEven macro-version" in i:
versionDetect = (i.split(">")[1])
if "ctEven macro-date" in i:
dateDetect = (i.split(">")[1])
try:
if (len(versionDetect) != 0) and (len(dateDetect) != 0):
break
except Exception:
None
try:
if (versionDetect == __version__) and (dateDetect == __date__):
None
else:
msg = ("New version availlable : " + "\n" +
str(versionDetect) + " : " + str(dateDetect) + "\n" +
"You can install with AddonManager")
FreeCAD.Console.PrintMessage("your actual version : " + str(__version__) + " : " + str(__date__) + "\n")
FreeCAD.Console.PrintMessage("new version availlable : " + str(versionDetect) + " : " + str(dateDetect) + "\n")
diag = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Information, 'New Version', msg)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()
except Exception:
None
return versionDetect, dateDetect
except Exception:
FreeCAD.Console.PrintMessage("Failed to establish a connection" + "\n")
#### Detect version macro ###########################################
switchVersionMacroSearch = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switchVersionMacroSearch")
if switchVersionMacroSearch == 0:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchVersionMacroSearch", switchVersionMacroSearch)
if switchVersionMacroSearch == True:
versionSearch()
#### Detect version macro ###########################################
Quit_Icon = [
"24 24 3 1",
" c None",
". c #FFFFFF",
"+ c #CC0000",
" .... ",
"++++++++++....++++++++++",
"+.......++....++.......+",
"+.......++....++.......+",
"+.......++....++.......+",
"+...++++++....++++++...+",
"+...++++++....++++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+......................+",
"+......................+",
"+......................+",
"++++++++++++++++++++++++"
]
boundBox_Center_Icon = [
"24 24 8 1",
" c None",
". c #284871",
"+ c #234C86",
"@ c #314B64",
"# c #EF2929",
"$ c #4A74A4",
"% c #4478AD",
"& c #4E9A06",
" ",
" # ",
" # ",
" # ",
" &&&&&# ",
" & #&&&&&&& ",
" & +#.. && ",
" &&&&&+%#%%. & & ",
" & ++&&&&&&& & ",
" & +$$$$$$&+@ & ",
" & +%$$$$$$&+@ & ",
"####&###$$$$$+&+####### ",
" & +%$$$$++&+@ & ",
" & +%$$$+++&+@ & ",
" & +$$++++&@ & ",
" & ++++++&@ & ",
" & @@@@@& & ",
" & # & & ",
" &&&&& # &&& ",
" &&&&&& ",
" # ",
" # ",
" # ",
" "
]
centerMass_Icon = [
"24 24 9 1",
" c None",
". c #000100",
"+ c #CD0000",
"@ c #6B6014",
"# c #B0A22C",
"$ c #D5B716",
"% c #E9D235",
"& c #F7E66C",
"* c #FBF4BC",
" ",
" ",
" ",
" ",
" ...... ",
" ..#%%%%#.. ",
" .@&&&%%%%%@. ",
" .@&**&%%%%%%@. ",
" .&***&%%%%%%%. ",
" .#&**&%%+%%%%%#. ",
" .%&&&%%++%%%$$%. ",
" .%%%%+++++$$$$$. ",
" .%%%%%+++++$$$$. ",
" .%%%%$$++$$$$$$. ",
" .#%$$$$+$$$$$$#. ",
" .%$$$$$$$$$$%. ",
" .@%$$$$$$$$$@. ",
" .@%$$$$$$%@. ",
" ..#$$$$#.. ",
" ...... ",
" ",
" ",
" ",
" "
]
point_Clicked_Icon = [
"24 24 7 1",
" c None",
". c #730000",
"+ c #9F0000",
"@ c #E90000",
"# c #C39F03",
"$ c #ECD309",
"% c #FBE851",
" ",
" ##### ",
" #%%%%%# ",
" #%%%%%%$# ",
" #%%%%%$$$$# ",
" #%%%%$$$$$# ",
" #%%%+.$$$$# ",
" #%%%++.$$$# ",
" #%%+@+.$# ",
" #%%+@@+.# ",
" ##+@@@+. ",
" +@@@@+. ",
" +@@@@@+. ",
" +@@@@@@+. ",
" +@@@@@@@.. ",
" +@@@@@@@@.. ",
" +@@@@@@@@@.. ",
" +@@@@@@+.... ",
" +@@@@@+ ",
" +@@++@@. ",
" +@+. .@@. ",
" ++. .@. ",
" .+.. ",
" .. "
]
axis_X_Icon = [
"24 24 6 1",
" c None",
". c #000000",
"+ c #A40000",
"@ c #EE2A2A",
"# c #729FCF",
"$ c #B9BCB5",
" $$ $$$$ ",
" $$$$ $ $ ",
" $$$$$$ $ ",
" $$$$$$ $ ",
" $$$$$$$$ $$$ ",
" $$$$ ",
" $$$$ ",
" $$$$ ",
" $$$$ ",
" $$$$ $$ $$",
" $$##$$ $$ $$",
" . . $####$ $$$ ",
" ... +####$ $$ ",
" .. +@####$$ $ ",
" . ... +@@@+$$$$$ $$ ",
" +@@@+ $$$$$ ",
" +@@@+ $$$$$ ",
" +++@@@+ $$$$$$$ ",
" +@@@@+ $$$$$$ ",
" +@@@+ $$$$$ ",
" +++++ $$$$$ ",
" ",
" ",
" "
]
axis_Y_Icon = [
"24 24 7 1",
" c None",
". c #030303",
"+ c #4E9A06",
"@ c #729FCF",
"# c #B9BCB5",
"$ c #BABDB6",
"% c #8AE134",
" $$ #### ",
" $$$$ # # ",
" $$$$$$ # ",
" $$$$$$ # ",
" $$$$$$$$ ### ",
" $$$$ ",
" $$$$ ",
" $$$$ ",
" $$$$ ",
" $$$$ .. ..",
" $$@@$$ .. ..",
" # # $@@@@$ ... ",
" ### $@@@@+ .. ",
" ## $$@@@@%+ . ",
" # ### $$$$$+%%%+ .. ",
" $$$$$ +%%%+ ",
" $$$$$ +%%%+ ",
" $$$$$$$ +%%%+++ ",
" $$$$$$ +%%%%+ ",
" $$$$$ +%%%+ ",
" $$$$$ +++++ ",
" ",
" ",
" "
]
axis_Z_Icon = [
"24 24 6 1",
" c None",
". c #000000",
"+ c #204A87",
"@ c #1D89B6",
"# c #729FCF",
"$ c #B9BCB5",
" ++ ... ",
" +@@+ . ",
" +@@@@+ . ",
" +@@@@+ . ",
" +++@@+++ ... ",
" +@@+ ",
" +@@+ ",
" +@@+ ",
" +@@+ ",
" +@@+ $$ $$",
" ++##++ $$ $$",
" $ $ +####+ $$$ ",
" $$$ $####$ $$ ",
" $$ $$####$$ $ ",
" $ $$$ $$$$$$$$$$ $$ ",
" $$$$$ $$$$$ ",
" $$$$$ $$$$$ ",
" $$$$$$$ $$$$$$$ ",
" $$$$$$ $$$$$$ ",
" $$$$$ $$$$$ ",
" $$$$$ $$$$$ ",
" ",
" ",
" "
]
direction_Icon = [
"24 24 6 1",
" c None",
". c #000000",
"+ c #A40000",
"@ c #EE2A2A",
"# c #565854",
"$ c #729FCF",
" ",
" ",
" +++++ ",
" +@@+ ",
" +@@@+ ",
" +@@@++ ",
" +@@@+ + ",
" +@@@+ ",
" +@@@+ ",
" +@@@+ ",
" +@@@+ ",
" +@@@+ ",
" +@@@+ ",
" +@@@+ ",
" +@@@+ ",
" +@@@+ ",
" + +@@@+ ",
" ++@@@+ ",
" +@@@+ ",
" +@@+ ",
" +++++ ",
" ",
" ",
" "
]
follow_Icon = [
"24 24 3 1",
" c None",
". c #A40000",
"+ c #EE2A2A",
" ",
" ",
" . ",
" .. ",
" .++. ",
" .+++. ",
" . .+++++. ",
" ..+++..+. ",
" .+++. .++. ",
" .++. .+. ",
" ..... .++. ",
" .+. ..... ",
" .++. .++. ",
" .+. .+++. ",
" .++. .+++.. ",
" .+. .+++. . ",
" .++..+++. ",
" .+.+++. ",
" .++++. ",
" .++. ",
" ... ",
" . ",
" ",
" "
]
point_Icon = [
"24 24 8 1",
" c None",
". c #000100",
"+ c #B0A22C",
"@ c #E9D235",
"# c #6B6014",
"$ c #F7E66C",
"% c #FBF4BC",
"& c #D5B716",
" ",
" ",
" ",
" ",
" ...... ",
" ..+@@@@+.. ",
" .#$$$@@@@@#. ",
" .#$%%$@@@@@@#. ",
" .$%%%$@@@@@@@. ",
" .+$%%$@@@@@@@@+. ",
" .@$$$@@@@@&&&&&. ",
" .@@@@@@@&&&&&&&. ",
" .@@@@@&&&&&&&&&. ",
" .@@@@&&&&&&&&&&. ",
" .+@@&&&&&&&&&&+. ",
" .@&&&&&&&&&&&. ",
" .#&&&&&&&&&&#. ",
" .#&&&&&&&&#. ",
" ..+&&&&+.. ",
" ...... ",
" ",
" ",
" ",
" "
]
apply_Icon = [
"24 24 3 1",
" c None",
". c #4E9A06",
"+ c #FFFFFF",
" ",
" ",
" ",
" . ",
" .+. ",
" .+.+. ",
" .+...+. ",
" .+.....+. ",
" . .+.......+.",
" .+. .+.......+. ",
" .+.+. .+.......+. ",
" .+...+. .+.......+. ",
" .+.....+.+.......+. ",
".+.......+.......+. ",
" .+.............+. ",
" .+...........+. ",
" .+.........+. ",
" .+.......+. ",
" .+.....+. ",
" .+...+. ",
" .+.+. ",
" .+. ",
" . ",
" "
]
quit_Icon = [
"24 24 3 1",
" c None",
". c #FFFFFF",
"+ c #CC0000",
" .... ",
"++++++++++....++++++++++",
"+.......++....++.......+",
"+.......++....++.......+",
"+.......++....++.......+",
"+...++++++....++++++...+",
"+...++++++....++++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...+++++......+++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+...++++++++++++++++...+",
"+......................+",
"+......................+",
"+......................+",
"++++++++++++++++++++++++"
]
save_Icon = [
"24 24 9 1",
" c None",
". c #A30500",
"+ c #5D5F5C",
"@ c #3967A0",
"# c #4B9A00",
"$ c #7E9BBD",
"% c #A9ABA8",
"& c #C7C9C6",
"* c #DCDEDB",
" ",
" @@@@@ ",
" @@$$$$$@ ",
" @$$$$$$$@ ",
" @@@@@@$@$$@ ",
" @$@@@ ",
" +%&&&@$@@@@&%%% ",
" +*@@@$@@@@@@@@&% ",
" +%*@@@@@@@@@@@@*&+ ",
" +***@@@@@@@@@@***+ ",
" +%***&@@@@@@@@&****+ ",
" +****&&@@@@@@&&****+ ",
" +***&&&&@@@@&&&&***+ ",
" +%***&&&&&@@&&&&&****+ ",
" +***&&&&&&&&&&&&&&***+ ",
" %********************+ ",
" %********************+ ",
" %&&&&&&&&&&&&&&&&&&&&+ ",
" %&%%%%%%%%%%%%%%%%%%%+ ",
" %&%%%%%%%%%%%%%%%%%%%+ ",
" %&%&&&%%%%%%%@%%#%%.%+ ",
" %%%%%%%%%%%%%%%%%%%%%+ ",
" ++++++++++++++++++++++ ",
" "
]
clear_Icon = [
"24 24 9 1",
" c None",
". c #000200",
"+ c #8B0606",
"@ c #875209",
"# c #E3383A",
"$ c #C19916",
"% c #C4A163",
"& c #E2C928",
"* c #E4D05A",
" @@@ ",
" @%%%@ ",
" @%*@@ ",
" @%@*%@ ",
" @%$$%@ ",
" @%%$%%@ ",
" @%$$$*@ ",
" @$**+++ ",
" @*%+##+. ",
" ++##+*$ ",
" +#++****$ ",
" ++****&**$ ",
" &**&*&&&*$ ",
" &*&&&*&$&*$ ",
" $*&*&$&&$$*$ ",
" $*&$&*$*&*$*$ ",
" *&$$&&$&&&&*$ ",
" $*&$&**$$**@ ",
" $*&$&****&$ ",
" $*$***$$@ ",
" $***$@ @ ",
" $@$@ ",
" @ ",
" "
]
delete_Icon = [
"24 24 3 1",
" c None",
". c #A40000",
"+ c #EE2A2A",
" ",
" ",
" . . ",
" .+. .+. ",
" .+++. .+++. ",
" .+++++. .+++++. ",
" .+++++++. .+++++++. ",
" .+++++++.+++++++. ",
" .+++++++++++++. ",
" .+++++++++++. ",
" .+++++++++. ",
" .+++++++. ",
" .+++++++++. ",
" .+++++++++++. ",
" .+++++++++++++. ",
" .+++++++.+++++++. ",
" .+++++++. .+++++++. ",
" .+++++. .+++++. ",
" .+++. .+++. ",
" .+. .+. ",
" . . ",
" ",
" ",
" "
]
memo_Allume_Icon = [
"24 24 9 1",
" c None",
". c #4F514E",
"+ c #635D41",
"@ c #676966",
"# c #848784",
"$ c #888A87",
"% c #E9D312",
"& c #FEEE4D",
"* c #FDFFFC",
" ",
" ",
" ",
" ",
" %%%%%% ",
" %%&&&&%% ",
" %%&&&&&&%% ",
" %%&&&**&&&%% ",
" %%&&&****&&&%% ",
" %&&&******&&&% ",
" %&&&******&&&% ",
" %&&&******&&&% ",
" %%&&&****&&&%% ",
" %%&&&**&&&%% ",
" %%&&&&&&%% ",
" %%%&&%%% ",
" .%%%%+ ",
" @..... ",
" ..#$$@ ",
" @@.... ",
" ..$$$@ ",
" @@.... ",
" $$$$ ",
" "
]
memo_Eteint_Icon = [
"24 24 9 1",
" c None",
". c #000000",
"+ c #204A87",
"@ c #555753",
"# c #4F514E",
"$ c #635D41",
"% c #676966",
"& c #848784",
"* c #888A87",
" ",
" ",
" ",
" ",
" ...... ",
" ........ ",
" .......... ",
" ............ ",
" ....+.+.+.+... ",
" ...+.+.+.++... ",
" ...@......@... ",
" ...@......@... ",
" ....@....@.... ",
" ....@..@.... ",
" ...@..@... ",
" ..@..@.. ",
" #@..@$ ",
" %##### ",
" ##&**% ",
" %%#### ",
" ##***% ",
" %%#### ",
" **** ",
" "
]
origin_Icon = [
"24 24 14 1",
" c None",
". c #EF2929",
"+ c #A40000",
"@ c #DDDFDC",
"# c #888A85",
"$ c #DDDEDB",
"% c #DCDEDB",
"& c #DCDEDC",
"* c #DBDDDA",
"= c #BABDB6",
"- c #555753",
"; c #729FCF",
"> c #3465A4",
", c #8191AA",
" ",
" ",
" .+ ",
" ..++ ",
" ....++ ",
" .....+++ ",
" ....@#++++ ",
" ....@@@#++++ ",
" ....@@@@@#++++ ",
" ....@@@@$@@#++++ ",
" ....@@@$@@%@@#++++ ",
" ....@@@@@@@@%@@#++++ ",
" ...@@@%%%%&%%*@@#+++ ",
" ..@@@@@@@@@@@@@@@#++ ",
" #@@=#---@@=====@# ",
" #@@=#---@@;>>>;@# ",
" #@@,#---@@;>>>;@# ",
" #@@,#---@@;>>>;@# ",
" #@@=#---@@-----@# ",
" #@@=#---@@@@@@@@# ",
" #@@=##--@@@@@@@@# ",
" ################# ",
" ",
" "
]
zero_Icon = [
"24 24 6 1",
" c None",
". c #CC0000",
"+ c #000000",
"@ c #BABDB6",
"# c #4E9A06",
"$ c #204A87",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" ++@ ..@ ++@ ",
" ++++@ +..+@ ++++@ ",
" ++@ ++@ ++..++@ ++@ ++@",
" +@ +@ +@.. +@ +@ +@",
"######+@###$$#+@######+@",
"######+@###$$#+@######+@",
" ++@ ++@ ++..++@ ++@ ++@",
" ++++ + ++++ + ++++ ",
" ++ ++ ++ ++ ++ ",
" + .. + ",
" ++ ..++ ",
" ++ ..+ ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. "
]
reset_Icon = [
"24 24 3 1",
" c None",
". c #3465A4",
"+ c #888A85",
" ",
" ........ ",
" .++++++++. ",
" .++..+....+. ..... ",
" .+.. .+....+. .+++. ",
" .+. .+....+..+.+. ",
" ... .+....+.+.+. ",
" .+....+..+. ",
" .+......+. ",
" .+.....+. ",
" .+....+. ",
" ...... .+...+. ",
" .++++. .++++. ",
" .+...+. ...... ",
" .+....+. ",
" .+.....+. ",
" .+......+. ",
" .+..+....+. ",
" .+.+.+....+. ... ",
" .+.+..+....+. .+. ",
" .+++. .+....+. ..+. ",
" ..... .+....+..++. ",
" .++++++++. ",
" ........ "
]
code_Python_Icon = [
"24 24 3 1",
" c None",
". c #3B7AAC",
"+ c #EDD400",
" ",
" ++++++++++++++++++++. ",
" + . ",
" + . ",
" + ..... . ",
" + . ..... . ",
" + ....... + . ",
" + ... +++ . ",
" + ........ ++++ . ",
" + ......... +++++ . ",
" + ......... ++++++ . ",
" + ....... +++++++ . ",
" + ...... +++++++++ . ",
" + ..... +++++++++ . ",
" + .... ++++++++ . ",
" + ... +++ . ",
" + . +++++++ . ",
" + +++++ + . ",
" + +++++ . ",
" + . ",
" + . ",
" + . ",
" +.................... ",
" "
]
code_FC_Icon = [
"24 24 5 1",
" c None",
". c #000000",
"+ c #CB0208",
"@ c #204A86",
"# c #BABDB6",
" ",
" ",
" ",
" ",
" ",
"@@@ @@@ @@@ @@@",
"@ @ @ @",
"@ ++# @ @ ++# @",
"@ ++++# @ @ ++++# @",
"@ ++# ++#@ @ ++# ++#@",
"@ +# +#@ @ +# +#@",
"@ +# +#@ @ +# +#@",
"@ +# +#@ @ +# +#@",
"@ ++# ++#@ @ ++# ++#@",
"@ ++++ @ @ ++++ @",
"@ ++ @ @ ++ @",
"@ @ @ @",
"@ @ @ @",
"@@@ @@@ . @@@ @@@",
" .. ",
" . ",
" .. ",
" .. ",
" "
]
rotate_Icon = [
"24 24 4 1",
" c None",
". c #000100",
"+ c #000201",
"@ c #6695BF",
" ",
" ++++++++ ",
" +@@@@@@@@+ ",
" +@@......@@++ ",
" +@@.@@@@@@.@@@+ ++ ",
" +@@.@@++++@@.@@@+@+ ",
" +@@.@@+ +@@.@@@@+ ",
" +@@.@@+ +@@.@@@+ ",
" +@.@@+ +@@.@@@+ ",
" +@.@+ ++@@@@@@@+ ",
" +@.@+ ++@@@@@@+ ",
" +@.@+ +++@@@+ ",
" +@.@+ +++++ ",
" +@.@+ ",
" +@.@@+ ",
" +@@.@@+ +++ ",
" +@@.@@+ +@+ ",
" +@@.@@+++++@@+ ",
" +@@.@@@@@@@@+ ",
" +@@.....@@+ ",
" +@@@@@@@++ ",
" +++++++ ",
" ",
" "
]
translate_Icon = [
"24 24 9 1",
" c None",
". c #000100",
"+ c #000407",
"@ c #6694BF",
"# c #6D92BE",
"$ c #6A93C5",
"% c #6795C0",
"& c #6F93C0",
"* c #6896C1",
" ",
" ",
" .. ",
" .@. ",
" .@@.. ",
" .@@@@. ",
" .@@@@@. ",
" ..........@@@@@@. ",
" +**&%%&@&@@@@@@@. ",
" .............+@@@$.. ",
" +@@@@@@@@@@@@@@@@@@. ",
" ..........+@@@@@@@@@@. ",
" +@@@@@@@@@@@@@@@@@@+ ",
" ........+@@@@@@@@@++ ",
" +@@@@@@@@@@@@@@@. ",
" ..........@@@@@@. ",
" .@@@@@. ",
" .@@@@. ",
" .@@.. ",
" .@. ",
" .. ",
" ",
" ",
" "
]
OnClickApply_Icon = [
"24 24 9 1",
" c None",
". c #910000",
"+ c #F20001",
"@ c #54595E",
"# c #4B9A00",
"$ c #8A8C89",
"% c #B0B2AE",
"& c #FED758",
"* c #DFE1DC",
" ",
" .. ",
" ....... ",
" ....++ ",
" .+.+++ ",
" ....+++++ ",
" $.+++++++%%%% ",
" **$.++++++***&& ",
" %***$.+++++&*&&& ",
" *****$.++++&&&&* ",
" %******$.+++&&&**% ",
" *******&$.++&&&&** ",
" ***&&&&&&$.+&&&&&&& ",
" %*******&&&$.&&&&**% ",
" *********&&&$&&&**** ",
" ********&&&&&&&&&***% ",
" %*******&&&*&&&*&&&**% ",
" %%%%%%%%&&%%%&%%%&&%%$ ",
" %%%$%%%%%%%%%&%@%#%+%$ ",
" %%%$$%%%%%%%%&%%%%%%%$ ",
" %%%%%%%%%%%%%&%%%%%%%$ ",
" $%%%%%%%%%%%%%%%%%%%%$ ",
" @@@@@@@@@@@@@@@@@@@@@ ",
" "
]
normalWork_Icon = [
"24 24 9 1",
" c None",
". c #565854",
"+ c #555753",
"@ c #2E3436",
"# c #FFFFFF",
"$ c #FCE94F",
"% c #FEFEFE",
"& c #EDD400",
"* c #BABDB6",
" ",
" ...................... ",
" . . ",
" . +++++ +++++ . ",
" . . ",
" . . ",
" . +++++ +++++ . ",
" . . ",
" . . ",
" . +++++ +++++ . ",
" . . ",
" . . ",
" ...................... ",
" ",
" ",
" @@@@@@@@@@@@@@@",
" @#$$#########%@",
" @#&&###@@@#@@%@",
" @%&&%########%@",
" @#**#########%@",
" @@@@@@@@@@@@@@@",
" ",
" ",
" "
]
PointCenter_Icon = [
"24 24 8 1",
" c None",
". c #CC0000",
"+ c #CB0007",
"@ c #363C3C",
"# c #666768",
"$ c #999E9D",
"% c #C2C4C0",
"& c #E3E5E1",
" ",
" @@@@@@@ ",
" . @@$%&&&%#@@ . ",
" . @%&&&%%%&&&%@ . ",
" .@&&$#@@@@@$%&&. ",
" @.%#@ @#.&@ ",
" @&&.@ .#&&@ ",
" @$&#@ @#&$@ ",
" @&%@ @%&@ ",
"@#&$ ++ ++ $&#@ ",
"@$&# ++++++ #&$@ ",
"@$&@ ++++ @&$@ ",
"@$&@ ++++ @&$@ ",
"@#&# ++++++ #&#@ ",
" @&$ ++ ++ $&@ ",
" @%& @&%@ ",
" @&@ @$&@ ",
" @%&. .#&%@ ",
" @.&@@ @@$.%@ ",
" .@%&&%@@@@@%&&%. ",
" . @#%&&&&&&&$#@ . ",
" . @@#$$$$$#@@ . ",
" @@@@@@@ ",
" "
]
positif_Icon = [
"24 24 9 1",
" c None",
". c #213B07",
"+ c #3B6212",
"@ c #487415",
"# c #5AA713",
"$ c #66BB14",
"% c #6FC31C",
"& c #7ACE23",
"* c #80D82B",
" ",
" ",
" ++++++ ",
" +****+ ",
" +****+ ",
" +****+ ",
" +****+ ",
" +****+ ",
" +****+ ",
" ++++++++****++++++++ ",
" +******************+ ",
" +******************+ ",
" +******************+ ",
" +******************+ ",
" ++++++++****++++++++ ",
" +****+ ",
" +****+ ",
" +****+ ",
" +****+ ",
" +****+ ",
" +****+ ",
" ++++++ ",
" ",
" "
]
negatif_Icon = [
"24 24 9 1",
" c None",
". c #000100",
"+ c #3C0406",
"@ c #680A0D",
"# c #7B0B13",
"$ c #B00206",
"% c #C40D0D",
"& c #D7171A",
"* c #EA2525",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" @@@@@@@@@@@@@@@@@@@@ ",
" @******************@ ",
" @******************@ ",
" @******************@ ",
" @******************@ ",
" @@@@@@@@@@@@@@@@@@@@ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
copy_Icon = [
"24 24 7 1",
" c None",
". c #2E3436",
"+ c #888A85",
"@ c #C5C8C4",
"# c #E8EAE7",
"$ c #EDF0ED",
"% c #F2F5F1",
" ",
" ................. ",
" .@@@@@@@@@@@@@@@. ",
" .@$$$$$$$$$$$$$%. ",
" .@$+++................ ",
" .@$$$#.@@@@@@@@@@@@@@. ",
" .@$+++.@$$$$$$$$$$$$$. ",
" .@$$$#.@$++++++++++$$. ",
" .@$+++.@$$$$$$$$$$$$$. ",
" .@$$$#.@#++++++++++$$. ",
" .@$+++.@$$$$$$$$$$$$$. ",
" .@$$$$.@#++++++++++$$. ",
" .@$$$$.@$$$$$$$$$$$$$. ",
" .@$+++.@#++++++++++$$. ",
" .@$$$$.@$$$$$$$$$$$$$. ",
" .@$+++.@$$$$$$$$$$$$$. ",
" .@$$$$.@$++++++++++$$. ",
" .@$$$$.@$$$$$$$$$$$$$. ",
" .@$$$$.@$++++++++++#$. ",
" .@@@@@.@$$$$$$$$$###$. ",
" .......@$$$$$$$%%###$. ",
" .@@@@@@@@@@@@@@. ",
" ................ ",
" "
]
zoom_View_Icon = [
"24 24 9 1",
" c None",
". c #303436",
"+ c #EF2B29",
"@ c #3066A6",
"# c #757774",
"$ c #6D9FD0",
"% c #A9ABA8",
"& c #DDDFDC",
"* c #FFFFFF",
" ",
" ",
" .................... ",
" .&&&&&&&&&&&&&&&&&&. ",
" .&@@@@@****@@@@@@@&. ",
" .&@@@@**$$**@@@@@@&. ",
" .&@@@**$$$$**@@@@@&. ",
" .&@@@*$$**$$*@@@@@&. ",
" .&@@@*$$**$$*@@@@@&. ",
" .&@@@*$$$$$$*@@@@@&. ",
" .&@@@**$$$$**@@@@@&. ",
" .&@@@@**$$**+@@@@@&. ",
" .&@@@@@****+++@@@@&. ",
" .&@@@@@@@@@@+++@@@&. ",
" .&@@@@@@@@@@@+++@@&. ",
" .&@@@@@@@@@@@@+++@&. ",
" .&&&&&&&&&&&&&&+++&. ",
" ................+++. ",
" &&######&& ++ ",
" &#%%####%%#& ",
" &##%%%%%%##& ",
" &########& ",
" &&&&&&&& ",
" "
]
global objectPlacementAngle ; objectPlacementAngle = ""
def objectRealPlacement3D(obj):
global objectPlacementAngle
try:
objectPlacement = obj.Shape.Placement
####
objectPlacementBase = FreeCAD.Vector(objectPlacement.Base)
####
objectWorkCenter = objectPlacementBase
####
objectPlacementAngle = objectPlacement.Rotation.toEuler()
if hasattr(obj, "getGlobalPlacement"):
globalPlacement = obj.getGlobalPlacement()
globalPlacementBase = FreeCAD.Vector(globalPlacement.Base)
objectRealPlacement3D = globalPlacementBase.add(objectWorkCenter).sub(objectPlacementBase)
objectPlacementAngle = globalPlacement.Rotation.toEuler()
else:
objectRealPlacement3D = objectWorkCenter
return objectRealPlacement3D
except Exception:
return FreeCAD.Vector(0.0, 0.0, 0.0)
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
class Ui_MainWindow(object):
def __init__(self ):
global path, path2
self.window = MainWindow
self.path = path
self.countOpenTransaction = 0
self.setFrameWindowSizeX = 400
self.setFrameWindowSizeY = 500
self.setMainWindowMoveX = 900
self.setMainWindowMoveY = 100
self.restore_Values = []
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"))
global saveListView
global switchZoomOnCilck
self.setFrameWindowSizeX = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetInt("setFrameWindowSizeX")
if self.setFrameWindowSizeX == 0:
self.setFrameWindowSizeX = 400
self.setFrameWindowSizeY = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetInt("setFrameWindowSizeY")
if self.setFrameWindowSizeY == 0:
self.setFrameWindowSizeY = 500
self.setMainWindowMoveX = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetInt("setMainWindowMoveX")
if self.setMainWindowMoveX == 0:
self.setMainWindowMoveX = 900
self.setMainWindowMoveY = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetInt("setMainWindowMoveY")
if self.setMainWindowMoveY == 0:
self.setMainWindowMoveY = 100
# MainWindow.setMinimumSize(QtCore.QSize(330, 10))
# MainWindow.setMaximumSize(QtCore.QSize(330, 330))
# MainWindow.setStyleSheet("background-color: rgb(50, 50, 50);")
MainWindow.resize(self.setFrameWindowSizeX, self.setFrameWindowSizeY)
MainWindow.move(self.setMainWindowMoveX, self.setMainWindowMoveY)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.groupBox_Cadre = QtWidgets.QGroupBox()
####scrollArea###############
grid = QtWidgets.QGridLayout()
self.centralwidget.setLayout(grid)
####
self.scrollArea = QtWidgets.QScrollArea(self.centralwidget) # cadre scrollarea contenant le widget GUI
self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.scrollArea.setWidgetResizable(True)
grid.addWidget(self.scrollArea, 0, 0)
self.vbox = QtWidgets.QVBoxLayout()
self.scrollArea.setLayout(self.vbox)
####
self.scrollAreaWidgetContents_2 = QtWidgets.QWidget() #widget contenant le GUI
self.vbox.addWidget(self.scrollAreaWidgetContents_2)
self.vbox = QtWidgets.QVBoxLayout()
self.scrollAreaWidgetContents_2.setLayout(self.vbox)
####scrollArea###############
####
self.groupBox_Position = QtWidgets.QGroupBox()
self.groupBox_Position.setEnabled(False)
self.CB_Position = QtWidgets.QCheckBox()
self.CB_Position.setIcon(QtGui.QIcon(QtGui.QPixmap(translate_Icon))) #icone dans une variable
self.CB_Position.clicked.connect(self.on_CB_Position)
####
self.label_Timer = QtWidgets.QLCDNumber()
self.label_Timer.setSegmentStyle(QLCDNumber.Outline) # Filled Flat
self.label_Timer.setDigitCount(12)
####
# self.label_Timer = QtWidgets.QLabel()
# self.label_Timer.setAlignment(Qt.AlignRight)
self.timeFn = time.perf_counter
self.startTime = self.timeFn()
## https://doc.qt.io/qtforpython-5/PySide2/QtCore/QTimer.html#detailed-description
self.timer = QTimer()
##self.timer.setInterval(1)
self.timer.timeout.connect(self.on_displayTime)
self.timer.start()
####
self.groupBox_Axis_Rotation = QtWidgets.QGroupBox()
self.groupBox_Axis = QtWidgets.QGroupBox()
self.groupBox_Axis.setEnabled(False)
self.RB_Bond_Box_Center = QtWidgets.QRadioButton()
self.RB_Bond_Box_Center.setChecked(True)
self.RB_Bond_Box_Center.setIcon(QtGui.QIcon(QtGui.QPixmap(boundBox_Center_Icon))) #icone dans une variable
self.RB_Bond_Box_Center.clicked.connect(self.on_RB_CenterRot)
self.RB_Center_Mass = QtWidgets.QRadioButton()
self.RB_Center_Mass.setIcon(QtGui.QIcon(QtGui.QPixmap(centerMass_Icon))) # icone dans une variable
self.RB_Center_Mass.clicked.connect(self.on_RB_CenterRot)
self.RB_Point_Clicked = QtWidgets.QRadioButton()
self.RB_Point_Clicked.setIcon(QtGui.QIcon(QtGui.QPixmap(point_Clicked_Icon))) # icone dans une variable
self.RB_Point_Clicked.clicked.connect(self.on_RB_CenterRot)
####
self.groupBox_Rotation = QtWidgets.QGroupBox()
self.groupBox_Rotation.setEnabled(False)
self.RB_Rotation_0 = QtWidgets.QRadioButton() # factice pour bouton invisible
self.RB_Rotation_0.setVisible(False)
# self.RB_Rotation_0.clicked.connect(self.on_RB_Rotation_0)
self.RB_Rotation_X = QtWidgets.QRadioButton()
self.RB_Rotation_X.setChecked(True)
self.RB_Rotation_X.setIcon(QtGui.QIcon(QtGui.QPixmap(axis_Z_Icon))) # icone dans une variable
self.RB_Rotation_X.clicked.connect(self.on_RB_Rotation_X)
self.RB_Rotation_Y = QtWidgets.QRadioButton()
self.RB_Rotation_Y.setIcon(QtGui.QIcon(QtGui.QPixmap(axis_Y_Icon))) # icone dans une variable
self.RB_Rotation_Y.clicked.connect(self.on_RB_Rotation_Y)
# self.RB_Angle_Y.setFont(QtGui.QFont(self.FontImpost,weight=QtGui.QFont.Bold)) # Bold
# self.RB_Angle_Y.setStyleSheet("color : #008700") # Color text
self.RB_Rotation_Z = QtWidgets.QRadioButton()
self.RB_Rotation_Z.setIcon(QtGui.QIcon(QtGui.QPixmap(axis_X_Icon))) # icone dans une variable
self.RB_Rotation_Z.clicked.connect(self.on_RB_Rotation_Z)
self.RB_Direction_D = QtWidgets.QRadioButton()
self.RB_Direction_D.setIcon(QtGui.QIcon(QtGui.QPixmap(direction_Icon))) # icone dans une variable
self.RB_Direction_D.clicked.connect(self.on_RB_Direction_D)
self.RB_Follow_The_Path_F = QtWidgets.QRadioButton()
self.RB_Follow_The_Path_F.setEnabled(False)
self.RB_Follow_The_Path_F.setIcon(QtGui.QIcon(QtGui.QPixmap(follow_Icon))) # icone dans une variable
self.RB_Follow_The_Path_F.clicked.connect(self.on_RB_Follow_The_Path_F)
####
self.groupBox_Pos_Mouse = QtWidgets.QGroupBox()
self.groupBox_Pos_Mouse.setEnabled(False)
self.DS_Pos_Mouse_X = QtWidgets.QDoubleSpinBox()
self.DS_Pos_Mouse_X.setMinimum(-999999.9)
self.DS_Pos_Mouse_X.setMaximum(99999999.9)
self.DS_Pos_Mouse_X.setDecimals(6)
self.DS_Pos_Mouse_X.setSuffix(" X")
self.DS_Pos_Mouse_X.valueChanged.connect(self.on_DS_Pos_Mouse_X)
self.DS_Pos_Mouse_Y = QtWidgets.QDoubleSpinBox()
self.DS_Pos_Mouse_Y.setMinimum(-999999.9)
self.DS_Pos_Mouse_Y.setMaximum(99999999.9)
self.DS_Pos_Mouse_Y.setDecimals(6)
self.DS_Pos_Mouse_Y.setSuffix(" Y")
self.DS_Pos_Mouse_Y.valueChanged.connect(self.on_DS_Pos_Mouse_Y)
self.DS_Pos_Mouse_Z = QtWidgets.QDoubleSpinBox()
self.DS_Pos_Mouse_Z.setMinimum(-999999.9)
self.DS_Pos_Mouse_Z.setMaximum(99999999.9)
self.DS_Pos_Mouse_Z.setDecimals(6)
self.DS_Pos_Mouse_Z.setSuffix(" Z")
self.DS_Pos_Mouse_Z.valueChanged.connect(self.on_DS_Pos_Mouse_Z)
####
self.groupBox_Work = QtWidgets.QGroupBox()
self.groupBox_Work.setEnabled(False)
# self.SC_Slider_Bar = QtWidgets.QSlider()
# self.SC_Slider_Bar.setMinimum(0.0)
# self.SC_Slider_Bar.setMaximum(359.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.valueChanged.connect(self.on_SC_Slider_Bar)
self.CB_View = QtWidgets.QCheckBox()
self.CB_View.setIcon(QtGui.QIcon(QtGui.QPixmap(zoom_View_Icon))) #icone dans une variable
self.CB_View.setChecked(switchZoomOnCilck)
self.CB_View.clicked.connect(self.on_CB_View)
self.PB_Point = QtWidgets.QPushButton()
self.PB_Point.setIcon(QtGui.QIcon(QtGui.QPixmap(point_Icon))) # icone dans une variable
self.PB_Point.clicked.connect(self.on_CB_Point)
self.PB_PointCenter = QtWidgets.QPushButton()
self.PB_PointCenter.setIcon(QtGui.QIcon(QtGui.QPixmap(PointCenter_Icon))) # icone dans une variable
self.PB_PointCenter.clicked.connect(self.on_PB_PointCenter)
self.CBox_View = QtWidgets.QComboBox()
#QtCore.QObject.connect(self.CBox_View, QtCore.SIGNAL("currentIndexChanged(QString)"), self.on_CBox_View)
QtCore.QObject.connect(self.CBox_View, QtCore.SIGNAL("activated(QString)"), self.on_CBox_View)
self.CBox_Impost = QtWidgets.QComboBox()
self.CBox_Impost.setCurrentIndex(5)
self.CBox_Impost.setMaxVisibleItems(17)
for i in range(17): # number item
self.CBox_Impost.addItem("")
QtCore.QObject.connect(self.CBox_Impost, QtCore.SIGNAL("currentIndexChanged(QString)"), self.on_CBox_Impost)
self.CBox_Memory = QtWidgets.QComboBox()
#self.CBox_Memory.addItem("")
self.CBox_Memory.setDuplicatesEnabled(True) #False
#QtCore.QObject.connect(self.CBox_Memory, QtCore.SIGNAL("currentIndexChanged(QString)"), self.on_CBox_Memory)
QtCore.QObject.connect(self.CBox_Memory, QtCore.SIGNAL("activated(QString)"), self.on_CBox_Memory)
self.PB_Negatif = QtWidgets.QPushButton()
self.PB_Negatif.setIcon(QtGui.QIcon(QtGui.QPixmap(negatif_Icon))) # icone dans une variable
self.PB_Negatif.clicked.connect(self.on_PB_Negatif_clicked)
self.DS_Value_Angle_Dimension = QtWidgets.QDoubleSpinBox()
self.DS_Value_Angle_Dimension.setMinimum(-360.0)
self.DS_Value_Angle_Dimension.setMaximum(360.0)
self.DS_Value_Angle_Dimension.setSuffix(" Degrees")
self.DS_Value_Angle_Dimension.setDecimals(5)
self.DS_Value_Angle_Dimension.valueChanged.connect(self.on_DS_Value_Angle_Dimension)
self.PB_Apply = QtWidgets.QPushButton()
self.PB_Apply.setAutoRepeat(True)
self.PB_Apply.setIcon(QtGui.QIcon(QtGui.QPixmap(apply_Icon))) # icone dans une variable
self.PB_Apply.clicked.connect(self.on_PB_Apply_clicked)
self.LE_Increment = QtWidgets.QLineEdit()
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.label_00 = QtWidgets.QLabel()
# self.label_00.setStyleSheet("color : #ffffff; background-color: red; font: bold 11px;") # white red bold
self.groupBox_Data = QtWidgets.QGroupBox()
self.groupBox_Data.setEnabled(False)
self.TE_Memorize = QtWidgets.QListView()
saveListView = QtGui.QStandardItemModel()
self.TE_Memorize.setModel(saveListView)
self.TE_Memorize.setSelectionRectVisible(True)#
self.TE_Memorize.setAlternatingRowColors(True)#
self.TE_Memorize.setStyleSheet("alternate-background-color:#fdeeee;")
self.TE_Memorize.clicked[QtCore.QModelIndex].connect(self.on_TE_Clicked)
self.PB_ClearMemo = QtWidgets.QPushButton()
self.PB_ClearMemo.setIcon(QtGui.QIcon(QtGui.QPixmap(clear_Icon))) # icone dans une variable
self.PB_ClearMemo.clicked.connect(self.on_PB_ClearMemo)
self.PB_Delete_Line_Memory = QtWidgets.QPushButton()
self.PB_Delete_Line_Memory.setIcon(QtGui.QIcon(QtGui.QPixmap(delete_Icon))) # icone dans une variable
self.PB_Delete_Line_Memory.clicked.connect(self.on_PB_Delete_Line_Memory)
self.CB_On_Click_Apply = QtWidgets.QCheckBox()
self.CB_On_Click_Apply.setIcon(QtGui.QIcon(QtGui.QPixmap(OnClickApply_Icon))) # icone dans une variable
self.CB_On_Click_Apply.clicked.connect(self.on_CB_On_Click_Apply)
self.PB_Memorize = QtWidgets.QPushButton()
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Eteint_Icon))) # icone dans une variable
self.PB_Memorize.clicked.connect(self.on_PB_Memorize)
self.PB_Save_Memorize = QtWidgets.QPushButton()
self.PB_Save_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(save_Icon))) # icone dans une variable
self.PB_Save_Memorize.clicked.connect(self.on_PB_Save_Memorize)
self.CB_DataInMacro = QtWidgets.QCheckBox()
self.CB_DataInMacro.setIcon(QtGui.QIcon(QtGui.QPixmap(code_Python_Icon))) # icone dans une variable
self.CB_DataInMacro.clicked.connect(self.On_CB_DataInMacro)
self.PB_Clip_Board = QtWidgets.QPushButton()
self.PB_Clip_Board.setIcon(QtGui.QIcon(QtGui.QPixmap(copy_Icon))) # icone dans une variable
self.PB_Clip_Board.clicked.connect(self.on_PB_Clip_Board)
####
self.groupBox_Command = QtWidgets.QGroupBox()
self.PB_Quit = QtWidgets.QPushButton()
self.PB_Quit.setIcon(QtGui.QIcon(QtGui.QPixmap(quit_Icon))) # icone dans une variable
self.PB_Quit.clicked.connect(self.on_PB_Quit_clicked)
self.PB_Original = QtWidgets.QPushButton()
self.PB_Original.setIcon(QtGui.QIcon(QtGui.QPixmap(origin_Icon))) # icone dans une variable
self.PB_Original.clicked.connect(self.on_PB_Original_clicked)
self.PB_Zero = QtWidgets.QPushButton()
self.PB_Zero.setIcon(QtGui.QIcon(QtGui.QPixmap(zero_Icon))) # icone dans une variable
self.PB_Zero.clicked.connect(self.on_PB_Zero_clicked)
self.PB_Reset = QtWidgets.QPushButton()
self.PB_Reset.setIcon(QtGui.QIcon(QtGui.QPixmap(reset_Icon))) # icone dans une variable
self.PB_Reset.clicked.connect(self.on_PB_Reset_clicked)
#### Gridlayout Header
self.gridLayout_00_00 = QtWidgets.QGridLayout() #self.centralwidget
self.gridLayout_00_00.setContentsMargins(10, 10, 10, 10)#Gauche Haut Droit Bas
#### Gridlayout Header
#### Gridlayout BEGIN
####
self.grid_00_00_00 = QtWidgets.QGridLayout(self.groupBox_Position)
self.grid_00_00_00.setContentsMargins(10, 10, 10, 10)
self.grid_00_00_00.addWidget(self.CB_Position, 0, 0, 1, 1)
self.grid_00_00_00.addWidget(self.label_Timer, 0, 1, 1, 1)
self.vbox.addWidget(self.groupBox_Position) # scrollArea
####
self.grid_00_00_AR = QtWidgets.QGridLayout(self.groupBox_Axis_Rotation) # groupe axis+rotation
self.grid_00_00_AR.setContentsMargins(10, 10, 10, 10)
#
self.grid_00_01_00 = QtWidgets.QGridLayout(self.groupBox_Rotation)
self.grid_00_01_00.setContentsMargins(10, 10, 10, 10)
self.grid_00_01_00.addWidget(self.RB_Bond_Box_Center, 0, 0, 1, 1)
self.grid_00_01_00.addWidget(self.RB_Center_Mass, 1, 0, 1, 1)
self.grid_00_01_00.addWidget(self.RB_Point_Clicked, 2, 0, 1, 1)
self.grid_00_00_AR.addWidget(self.groupBox_Rotation, 0, 0, 1, 1)
#
self.grid_00_02_00 = QtWidgets.QGridLayout(self.groupBox_Axis)
self.grid_00_02_00.setContentsMargins(10, 10, 10, 10)
self.grid_00_02_00.addWidget(self.RB_Rotation_X, 0, 0, 1, 1)
self.grid_00_02_00.addWidget(self.RB_Rotation_Y, 1, 0, 1, 1)
self.grid_00_02_00.addWidget(self.RB_Rotation_Z, 2, 0, 1, 1)
self.grid_00_02_00.addWidget(self.RB_Direction_D, 3, 0, 1, 1)
self.grid_00_02_00.addWidget(self.RB_Follow_The_Path_F, 4, 0, 1, 1)
self.grid_00_00_AR.addWidget(self.groupBox_Axis, 0, 1, 1, 1)
self.vbox.addWidget(self.groupBox_Axis_Rotation) # scrollArea
####
self.grid_00_03_00 = QtWidgets.QGridLayout(self.groupBox_Pos_Mouse)
self.grid_00_03_00.setContentsMargins(10, 10, 10, 10)
self.grid_00_03_00.addWidget(self.DS_Pos_Mouse_X, 0, 0, 1, 1)
self.grid_00_03_00.addWidget(self.DS_Pos_Mouse_Y, 0, 1, 1, 1)
self.grid_00_03_00.addWidget(self.DS_Pos_Mouse_Z, 0, 2, 1, 1)
self.vbox.addWidget(self.groupBox_Pos_Mouse) # scrollArea
####
self.grid_00_044_00 = QtWidgets.QGridLayout(self.groupBox_Work)
self.grid_00_044_00.setContentsMargins(10, 10, 10, 10)
self.grid_00_044_00.addWidget(self.CB_View, 0, 0, 1, 1)
self.grid_00_044_00.addWidget(self.PB_Point, 0, 1, 1, 1)
self.grid_00_044_00.addWidget(self.PB_PointCenter, 0, 2, 1, 1)
#
self.grid_00_044_00.addWidget(self.CBox_View, 1, 0, 1, 1)
self.grid_00_044_00.addWidget(self.CBox_Impost, 1, 1, 1, 1)
self.grid_00_044_00.addWidget(self.CBox_Memory, 1, 2, 1, 1)
#
self.grid_00_044_00.addWidget(self.PB_Negatif, 2, 0, 1, 1)
self.grid_00_044_00.addWidget(self.DS_Value_Angle_Dimension, 2, 1, 1, 1)
self.grid_00_044_00.addWidget(self.PB_Apply, 2, 2, 1, 1)
#
self.grid_00_044_00.addWidget(self.LE_Increment, 3, 0, 1, 3)
self.grid_00_044_00.addWidget(self.label_00, 4, 0, 1, 3)
self.vbox.addWidget(self.groupBox_Work) # scrollArea
####
self.grid_00_044b_00 = QtWidgets.QGridLayout(self.groupBox_Data)
self.grid_00_044b_00.setContentsMargins(10, 10, 10, 10)
self.grid_00_044b_00.addWidget(self.TE_Memorize, 0, 0, 1, 4)
self.grid_00_044b_00.addWidget(self.PB_ClearMemo, 1, 0, 1, 1)
self.grid_00_044b_00.addWidget(self.PB_Delete_Line_Memory, 1, 1, 1, 1)
self.grid_00_044b_00.addWidget(self.CB_On_Click_Apply, 1, 2, 1, 1)
self.grid_00_044b_00.addWidget(self.PB_Memorize, 1, 3, 1, 1)
self.grid_00_044b_00.addWidget(self.PB_Save_Memorize, 2, 0, 1, 1)
self.grid_00_044b_00.addWidget(self.CB_DataInMacro, 2, 1, 1, 1)
self.grid_00_044b_00.addWidget(self.PB_Clip_Board, 2, 3, 1, 1)
self.vbox.addWidget(self.groupBox_Data) # scrollArea
####
self.grid_00_08_00 = QtWidgets.QGridLayout(self.groupBox_Command)
self.grid_00_08_00.setContentsMargins(10, 10, 10, 10)
self.grid_00_08_00.addWidget(self.PB_Quit, 0, 0, 1, 1)
self.grid_00_08_00.addWidget(self.PB_Original, 0, 1, 1, 1)
self.grid_00_08_00.addWidget(self.PB_Zero, 0, 2, 1, 1)
self.grid_00_08_00.addWidget(self.PB_Reset, 0, 3, 1, 1)
grid.addWidget(self.groupBox_Command, 1, 0)
####
self.gridLayout_00_00.addLayout(self.vbox, 0, 0)
self.gridLayout_00_00.addLayout(self.grid_00_08_00, 1, 0)
###########################################################scrollArea
self.scrollArea.setWidget(self.scrollAreaWidgetContents_2)
###########################################################scrollArea
#### Gridlayout END
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
global path
global myObjectName
MainWindow.setWindowFlags(PySide2.QtCore.Qt.WindowStaysOnTopHint) # this function turns the front window (stay to hint)
MainWindow.setWindowIcon(QtGui.QIcon(self.path+u"Macro_Rotate_To_Point.png")) # change l'icone de la fenetre principale
MainWindow.setWindowTitle(__title__ + " (" + __version__ + " : " + __date__ + " (rmu))")
_translate = QtCore.QCoreApplication.translate
####
self.groupBox_Position.setTitle(_translate("MainWindow", "[ 1 ] Position or Rotation"))
self.groupBox_Position.setToolTip(_translate("MainWindow", "First choice Position or Rotation"))
self.CB_Position.setText(_translate("MainWindow", "Check for Translation"))
self.CB_Position.setToolTip(_translate("MainWindow", "Check for move the object to axis choice X, Y or Z"))
# self.label_Timer.setText(_translate("MainWindow", "Time"))
self.label_Timer.setToolTip(_translate("MainWindow", "Give the elapsed time"))
####
self.groupBox_Axis_Rotation.setTitle(_translate("MainWindow", "[ 2 ] Translation Rotation"))
self.groupBox_Axis_Rotation.setToolTip(_translate("MainWindow", "Second choice Axis, Translation or Rotation"+"\n"
"(All change mode Axis, reset the degrees value to 0.0)"))
self.groupBox_Rotation.setTitle(_translate("MainWindow", "Point Rotation"))
self.RB_Bond_Box_Center.setText(_translate("MainWindow", "Bounbox Center"))
self.RB_Bond_Box_Center.setToolTip(_translate("MainWindow", "Point rotation on BoundBox Center"))
self.RB_Center_Mass.setText(_translate("MainWindow", "Center of Mass"))
self.RB_Center_Mass.setToolTip(_translate("MainWindow", "Point rotation on Center Mass"+"\n"
"If the Center Mass is not availlable the spin is colored"))
self.RB_Point_Clicked.setText(_translate("MainWindow", "Point clicked"))
self.RB_Point_Clicked.setToolTip(_translate("MainWindow", "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.groupBox_Axis.setTitle(_translate("MainWindow", "Axis Rotation"))
self.RB_Rotation_X.setText(_translate("MainWindow", "Rotation(Z) Yaw"))
self.RB_Rotation_X.setToolTip(_translate("MainWindow", "Rotation on Axis Yaw (Z)"))
self.RB_Rotation_Y.setText(_translate("MainWindow", "Rotation(Y) Pitch"))
self.RB_Rotation_Y.setToolTip(_translate("MainWindow", "Rotation on Axis Pitch (Y)"))
self.RB_Rotation_Z.setText(_translate("MainWindow", "Rotation(X) Roll"))
self.RB_Rotation_Z.setToolTip(_translate("MainWindow", "Rotation on Axis Roll (X)"))
self.RB_Direction_D.setText(_translate("MainWindow", "Rotation(D) on Direction"))
self.RB_Direction_D.setToolTip(_translate("MainWindow", "Rotation or Translation on Direction" + "\n"
"For use the Direction option:" + "\n"
"Select First: the object to Rotate/Translate" + "\n"
"Second: the path: Line, Wire or Edge"))
self.RB_Follow_The_Path_F.setText(_translate("MainWindow", "Follow the path"))
self.RB_Follow_The_Path_F.setToolTip(_translate("MainWindow", "Translation on Follow the path" + "\n"
"For use the Follow option:" + "\n"
"Select First: the object to Follow check (Rotate/Translate)" + "\n"
"Second: the path: Line, Wire or Edge"))
####
self.groupBox_Work.setTitle(_translate("MainWindow", "[ 3 ] Work ()"))
self.groupBox_Work.setToolTip(_translate("MainWindow", "Third, good work"))
self.groupBox_Pos_Mouse.setTitle(_translate("MainWindow", "Coordinates on Point clicked"))
self.groupBox_Pos_Mouse.setToolTip(_translate("MainWindow", "Position click mouse modification possible only with mode Point clicked"))
self.DS_Pos_Mouse_X.setToolTip(_translate("MainWindow", "Position click mouse X" + "\n" +
"modification only with mode Point clicked"))
self.DS_Pos_Mouse_Y.setToolTip(_translate("MainWindow", "Position click mouse Y" + "\n" +
"modification only with mode Point clicked"))
self.DS_Pos_Mouse_Z.setToolTip(_translate("MainWindow", "Position click mouse Z" + "\n" +
"modification only with mode Point clicked"))
####
self.CB_View.setText(_translate("MainWindow", "View"))
self.CB_View.setToolTip(_translate("MainWindow", "If checked restitute the associated view on object selected"))
self.PB_Point.setText(_translate("MainWindow", "Point"))
self.PB_Point.setToolTip(_translate("MainWindow", "Create one point to visualise the point rotation"))
self.PB_PointCenter.setText(_translate("MainWindow", "Center"))
self.PB_PointCenter.setToolTip(_translate("MainWindow", "Create one point on center face, circle "))
self.LE_Increment.setToolTip(_translate("MainWindow", "Display the original Data + the modification"))
#
#self.CBox_View.setItemText(0,_translate("MainWindow", "0"))
self.CBox_View.setToolTip(_translate("MainWindow", "Memorize the view associate with the Object worked" + "\n"
"For automate the zoom on object clicked, see:" + "\n\n"
"User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__ + " > switchZoomOnCilck" + "\n"
"and check the 'switchZoomOnCilck' option on True and restart " + __title__ + "\n\n"
"If you choice the object with this box" + "\n"
"the latest configuration of the object is automatically returned"))
self.CBox_Impost.setCurrentIndex(6)
self.CBox_Impost.setMaxVisibleItems(17)
self.CBox_Impost.setItemText(0, "0.0001")
self.CBox_Impost.setItemText(1, "0.001")
self.CBox_Impost.setItemText(2, "0.01")
self.CBox_Impost.setItemText(3, "0.1")
self.CBox_Impost.setItemText(4, "0.5")
self.CBox_Impost.setItemText(5, "0")
self.CBox_Impost.setItemText(6, "1")
self.CBox_Impost.setItemText(7, "5")
self.CBox_Impost.setItemText(8, "10")
self.CBox_Impost.setItemText(9, "20")
self.CBox_Impost.setItemText(10, "30")
self.CBox_Impost.setItemText(11, "40")
self.CBox_Impost.setItemText(12, "45")
self.CBox_Impost.setItemText(13, "60")
self.CBox_Impost.setItemText(14, "90")
self.CBox_Impost.setItemText(15, "120")
self.CBox_Impost.setItemText(16, "180")
self.CBox_Impost.setToolTip(_translate("MainWindow", "Value standard imposted"))
#
self.CBox_Memory.setItemText(0,_translate("MainWindow", "0"))
self.CBox_Memory.setToolTip(_translate("MainWindow", "Value used memorized"))
#
self.DS_Value_Angle_Dimension.setToolTip(_translate("MainWindow", "Enter the modification"))
self.PB_Negatif.setText(_translate("MainWindow", "Invert"))
self.PB_Apply.setToolTip(_translate("MainWindow", "Apply the modification"))
self.PB_Apply.setText(_translate("MainWindow", "Apply"))
self.label_00.setText(_translate("MainWindow", " Select one Object or give one value Angle/Dimension"))
self.label_00.setStyleSheet("color : #ffffff; background-color: red; font: bold 11px;") # white red bold
#self.label_00.setToolTip("Display the modification Axis and Rotation or Position")
####
self.groupBox_Data.setTitle(_translate("MainWindow", "Data to save"))
self.PB_ClearMemo.setText(_translate("MainWindow", "Clear"))
self.PB_ClearMemo.setToolTip(_translate("MainWindow", "Clear the memo data" + "\n"
"The Reset button is not actif for this option"))
self.PB_Delete_Line_Memory.setText(_translate("MainWindow", "Delete"))
self.PB_Delete_Line_Memory.setToolTip(_translate("MainWindow", "Delete the line selected"))
self.CB_On_Click_Apply.setText(_translate("MainWindow", "Memo on click"))
self.CB_On_Click_Apply.setToolTip(_translate("MainWindow", "Memorize the coordinates on all Click Apply button"))
self.PB_Memorize.setText(_translate("MainWindow", "Memorize"))
self.PB_Memorize.setToolTip(_translate("MainWindow", "Memorize the placement displayed"))
self.PB_Save_Memorize.setText(_translate("MainWindow", "Save"))
self.PB_Save_Memorize.setToolTip(_translate("MainWindow", "Save the memorized placement" + "\n"
"Format to save : [Placement.Base], [Placement.Rotation.toEuler]" + "\n"
"Ex: ['Body001',(0.08,0.14,-1.5),(2.0,0.0,0.0)] with the extension: .CoorInfo" + "\n"
"If the file exist, the data is saved in Append (adding) mode" + "\n"
"If the CheckBox is checked for a Macro the file is saved in Write mode"))
self.CB_DataInMacro.setText(_translate("MainWindow", "Macro"))
self.CB_DataInMacro.setToolTip(_translate("MainWindow", "If checked, the coordinate is saved in Python code (complete macro) in your Macro directory" + "\n"
"Actual : " + path + "\n"
"Select the object and run the macro" + "\n"
"\t" + "The macro saved has various options :" + "\n"
"\t" + " (Q)uit, (D)ecrease, (I)ncrease, (P)ause, (S)tep, (M)emo" + "\n"
"If this is not checked, the data hare saved in coordinate mode" + "\n"
"\t" + "Ex: ['Body001',(0.08,0.14,-1.5),(2.0,0.0,0.0)] with the ext: .CoorInfo" + "\n"))
self.PB_Clip_Board.setText(_translate("MainWindow", "Copy"))
self.PB_Clip_Board.setToolTip(_translate("MainWindow", "Copy the data in the clip Board" + "\n"
"on Rotate_To_Point format" + "\n"
"['Body001',(0.08,0.14,-1.5),(2.0,0.0,0.0)]"))
####
self.groupBox_Command.setTitle(_translate("MainWindow", "Command"))
self.PB_Quit.setText(_translate("MainWindow", "Quit"))
self.PB_Quit.setToolTip(_translate("MainWindow", "Quite the macro"))
self.PB_Original.setText(_translate("MainWindow", "Original"))
self.PB_Original.setToolTip(_translate("MainWindow", "Move the object to the original position"))
self.PB_Reset.setText(_translate("MainWindow", "Reset"))
self.PB_Reset.setToolTip(_translate("MainWindow", "Reset the complete data macro"))
self.PB_Zero.setText(_translate("MainWindow", "0,0,0"))
self.PB_Zero.setToolTip(_translate("MainWindow", "Move the object to the base coordinates 0, 0, 0"))
def on_displayTime(self):
##https://forum.freecadweb.org/viewtopic.php?p=623962#p623962
##measure the time elapsed for a recompute
##chrisb
endTime = self.timeFn()
elapsed = (endTime - self.startTime)
self.elapsedComplete = str('{:02d}:{:02d}:{:06.3f}'.format(int(elapsed) // 3600, (int(elapsed) % 3600 // 60), elapsed % 60))
self.label_Timer.display(self.elapsedComplete)
def on_DS_Pos_Mouse_X(self,val):
global positionMouse
global axisX
positionMouse = [val, positionMouse[1], positionMouse[2]]
axisX = positionMouse[0]
self.DS_Pos_Mouse_X.setValue(axisX)
def on_DS_Pos_Mouse_Y(self,val):
global positionMouse
global axisY
positionMouse = [positionMouse[0], val, positionMouse[2]]
axisY = positionMouse[1]
self.DS_Pos_Mouse_Y.setValue(axisY)
def on_DS_Pos_Mouse_Z(self,val):
global positionMouse
global axisZ
positionMouse = [positionMouse[0], positionMouse[1], val]
axisZ = positionMouse[2]
self.DS_Pos_Mouse_Z.setValue(axisZ)
# def on_SC_Slider_Bar(self,val):
# global ui
# global valeur
# global myObject
#
# if (myObject != "") and (self.CB_On_Click_Apply.isChecked()):
# valeur = val
# self.DS_Value_Angle_Dimension.setValue(1)
# self.SC_Slider_Bar.setValue(valeur)
# ui.on_PB_Apply_clicked()
#
## if self.CB_On_Click_Apply.isChecked():
## ui.on_PB_Apply_clicked()
## else:
## self.DS_Value_Angle_Dimension.setValue(0.0)
## self.SC_Slider_Bar.setValue(0.0)
def on_PB_Delete_Line_Memory(self): #self.TE_Memorize #QListView
global countMemory
global saveOnDisk
self.model = model = QtGui.QStandardItemModel()
try:
self.PB_Delete_Line_Memory.setStyleSheet("Base")
lineSelected = self.TE_Memorize.selectionModel().selectedRows()[0].row()
#textLigne = self.TE_Memorize.selectionModel().currentIndex().data() # affiche la ligne selectionnee
self.TE_Memorize.model().removeRow(lineSelected)
del saveOnDisk[lineSelected]
countMemory -= 1
self.PB_Memorize.setText("Memo (" + str(countMemory) + ")")
except Exception:
self.PB_Delete_Line_Memory.setStyleSheet("background-color: rgb(255, 0, 0)")
def on_TE_Clicked(self, index): # click dans la fenetre des donnees
global saveOnDisk
global saveListView
global memorySelected
####ori colore la ligne######
# item = saveListView.itemFromIndex(index)
# item.setBackground(QtGui.QBrush(QtGui.QColor("#ef1919")))
# if (item.index().row()) in memorySelected:
## memorySelected.remove(item.index().row())
# baseBackground = self.TE_Memorize.palette().color(QPalette.Window)
# item.setBackground(QtGui.QBrush(QtGui.QColor(baseBackground)))
# else:
# memorySelected.append(item.index().row())
## print(memorySelected)
####ori colore la ligne######
item = saveListView.itemFromIndex(index)
memorySelected = []
memorySelected.append(item.index().row())
def on_PB_PointCenter(self):
global objectPlacementAngle
try:
sel = FreeCADGui.Selection.getSelection()
placementOrigine = objectRealPlacement3D(FreeCAD.ActiveDocument.getObject(sel[0].Name))# search the original Placement
Part.show(FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0].copy()) # create repro shape subObject
a = App.ActiveDocument.ActiveObject
a.Placement.Base = placementOrigine
a.Placement.Rotation = App.Rotation(objectPlacementAngle[0], objectPlacementAngle[1], objectPlacementAngle[2])
point = Draft.makePoint(a.Shape.BoundBox.Center)
App.ActiveDocument.ActiveObject.recompute()
#App.ActiveDocument.ActiveObject.touch()
App.ActiveDocument.ActiveObject.purgeTouched()
except Exception:
self.PB_PointCenter.setStyleSheet("background-color: red")
try:
App.ActiveDocument.removeObject(a.Name)
except Exception:
None
def on_PB_Memorize(self): # memorize the position
global myObject
global myObjectName
global saveOnDisk
global saveListView
global countMemory
global valeur
# if (valeur != 0):
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Allume_Icon))) # icone dans une variable
countMemory += 1
xPB = str(myObject.Placement.Base[0])
yPB = str(myObject.Placement.Base[1])
zPB = str(myObject.Placement.Base[2])
xPR = str(myObject.Placement.Rotation.toEuler()[0])
yPR = str(myObject.Placement.Rotation.toEuler()[1])
zPR = str(myObject.Placement.Rotation.toEuler()[2])
#####
# #myObjectName , [(3.7,0.0,41.8), (0.0,3.0,0.0)],
# #nomObjet , Placement.Base , Placement.Rotation.toEuler()
dummy = '["' + str(myObjectName) + '",' + "("+xPB+","+yPB+","+zPB+"),("+xPR+","+yPR+","+zPR+")],"
####
saveOnDisk.append(dummy)
self.PB_Memorize.setText("Memo (" + str(countMemory) + ")")
self.PB_Memorize.setStyleSheet("background-color: rgb(188, 245, 169)"); # bouton
self.PB_Delete_Line_Memory.setStyleSheet("Base")
item = QtGui.QStandardItem(dummy)
saveListView.appendRow(item)
# else:
# self.PB_Memorize.setStyleSheet("background-color: #ff0000;")
# self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Eteint_Icon))) # icone dans une variable
def on_PB_Save_Memorize(self): # Save_Memorize in macro file
global pathFile
global saveOnDisk
global countMemory
global path
if countMemory != 0:
if self.CB_DataInMacro.isChecked():
SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Save a file FCMacro", path, "FCMacro (*.FCMacro);;Python (*.py)") # PySide2
# nomMacro = FreeCAD.ActiveDocument.Name
# SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Save a file FCMacro", path + nomMacro, "(*.FCMacro);;Python (*.py)") # dans "FreeCAD/Macro/" PySide2
else:
SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Save a file CoorInfo", pathFile, "CoorInfo (*.CoorInfo);;Ascii (*.asc);;TXT (*.txt)") # PySide2
if SaveName == "": # if the name file are not selected then Abord process
App.Console.PrintMessage("Process aborted"+"\n")
else: # if the name file are selected or created then
####new2
pathFile = os.path.dirname(SaveName) + "/" #= C:/Provisoire400/
formatFichier = os.path.splitext(SaveName)[1] #= .png
SaveName = os.path.splitext(SaveName)[0] #= /home/kubuntu/.FreeCAD/Macro/Texture_007_H #= C:/Provisoire400/image3D
SaveNameformatFichier = SaveName + formatFichier #= C:/Provisoire400/image3D.png
####new2
######## sauve le dernier chemin utilise si n'est pas une macro########
if self.CB_DataInMacro.isChecked():
None
else:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("setLastPath",pathFile)
######## sauve le dernier chemin utilise si n'est pas une macro########
App.Console.PrintMessage("Registration of "+SaveNameformatFichier+"\n")
try:
if self.CB_DataInMacro.isChecked():
file = open(SaveNameformatFichier, 'w') #'w'write
else:
file = open(SaveNameformatFichier, 'a') #'a'append
try:
#### macro first section begin
if self.CB_DataInMacro.isChecked():
file.write("# -*- coding: utf-8 -*-" + "\n")
file.write("##" + "\n")
try:
nameAuthor = str(unicodedata.normalize('NFD', __author__).encode('ascii','ignore'))
except Exception: nameAuthor = "Sir X"
try:
file.write("##Animation ver 0.2 2022/09/15 #YYYY/MM/DD" + "\n")
file.write("##Created by : " + __title__ + " : " + __version__ + ":" + __date__ + " : " + nameAuthor + "\n")
file.write("##Document : " + FreeCAD.ActiveDocument.Name + "\n")
#file.write("##Date : " + str(QDate.currentDate().toString()) + "\n") # mer. mars 3 2021
file.write("##Date : " + str(QDate.currentDate().toString("yyyy/MM/dd")) + " # yyyy/MM/dd" + "\n")
file.write("##Object(First): " + str(FreeCADGui.Selection.getSelection()[0].Name) + "\n")
file.write("##Coordinates : " + str(countMemory) + "\n")
file.write("##" + "\n")
except Exception: None
file.write("import Draft, Part" + "\n")
file.write("import PySide2" + "\n")
file.write("from pivy import coin" + "\n")
file.write("import time, os" + "\n")
file.write("" + "\n")
file.write("import FreeCAD, FreeCADGui" + "\n")
file.write("App = FreeCAD" + "\n")
file.write("Gui = FreeCADGui" + "\n")
file.write("" + "\n")
file.write("global Document; Document = " + chr(34) + FreeCAD.ActiveDocument.Name + chr(34) + "\n")
file.write("global xxData ; xxData = [] " + "\n")
file.write("global xxKey ; xxKey = " + chr(34) + chr(34) + "\n")
file.write("global v, o, c" + "\n")
file.write("global vitesse ; vitesse = 0.02" + "\n")
file.write("" + "\n")
file.write("global animation ; animation = 0" + "\n")
file.write("global countImage; countImage = 0" + "\n")
file.write("global pathImage ; pathImage = " + chr(34) + chr(34) + "\n")
file.write("" + "\n")
file.write("global sizeX" + "\n")
file.write("global sizeY" + "\n")
file.write("global jumpingImage" + "\n")
file.write("global switchCountZero" + "\n")
file.write("global createPoint" + "\n")
file.write("global switchYoYo; switchYoYo = 0" + "\n")
file.write("" + "\n")
file.write("#### Config Begin ####" + "\n")
file.write("####" + "\n")
file.write("sizeX = 640 # size X of image 640 VGA" + "\n")
file.write("sizeY = 480 # size Y of image 480 VGA" + "\n")
file.write("jumpingImage = 1 # jump the image to ..." + "\n")
file.write("switchCountZero = 1 # if 0 and jumpingImage = 5 the counter follow the jump ex: image1 image6 image11 image16 ..." + "\n")
file.write(" # if 1 and jumpingImage = 5 the counter is incremented normally ex: image1 image2 image3 ..." + "\n")
file.write('createPoint = 0 # 0=not point 1=create point (on base) # used by "S" :Step to Step' + "\n")
file.write("####" + "\n")
file.write("#### Config End ####" + "\n")
file.write("" + "\n")
file.write('####path#########################################################################' + "\n")
file.write('global path ; path = "" #' + "\n")
file.write('param = FreeCAD.ParamGet(u"User parameter:BaseApp/Preferences/Macro")# macro path' + "\n")
file.write('path = param.GetString(u"MacroPath","") + "/" # macro path' + "\n")
file.write('#path = "your path" # your directory path' + "\n")
file.write('path = path.replace(u"' + chr(92) + chr(92) + '","/") # convert the "\" to "/"' + "\n")
file.write('#################################################################################' + "\n")
file.write("" + "\n")
file.write("def help():" + "\n")
file.write(" global xxData" + "\n")
file.write(" global Document" + "\n")
file.write(' App.Console.PrintMessage("__' + FreeCAD.ActiveDocument.Name + '__"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("__" + str(len(xxData)) + " Coordinates__"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key Q to Quit"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key A to Create serial image for create Animate GIF"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key D to Decrease speed"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key I to Increase speed"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key P to Pause/Continue or key RETURN or ESCAPE"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key S to Step by Step (key RETURN or ESCAPE to continue)"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key V to ReVerse"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key Y to YoYo"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("Type Key M for this message"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintError("For use this options click mouse in the 3D view and type the key desidered"+"' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("____________________________"+"' + chr(92) + 'n")' + "\n")
file.write('\n')
####
file.write('class ViewObserver:' + "\n")
file.write(' def logPosition(self, info):' + "\n")
file.write(' global xxKey' + "\n")
file.write(' global v, o, c' + "\n")
file.write(' global vitesse' + "\n")
file.write(' global animation' + "\n")
file.write(' global path' + "\n")
file.write(' global pathImage' + "\n")
file.write(' global Document' + "\n")
file.write(' global countImage' + "\n")
file.write(' global switchYoYo' + "\n")
file.write(' global xxData' + "\n")
file.write('' + "\n")
file.write(' xxKey = info["Key"].upper()' + "\n")
file.write(' if xxKey in "QVIDPSAYM" or xxKey == "RETURN" or xxKey == "PAD_ENTER" or xxKey == "ESCAPE":' + "\n")
file.write(' if (xxKey == "Q"): # Quit' + "\n")
file.write(' v.removeEventCallback("SoKeyboardEvent",c)' + "\n")
file.write(' FreeCAD.Console.PrintMessage("End " + Document + "' + chr(92) + 'n")' + "\n")
file.write('' + "\n")
file.write(' if (xxKey == "ESCAPE"): # Reset' + "\n")
file.write(' vitesse = 0.02' + "\n")
file.write(' switchYoYo = 0' + "\n")
file.write('' + "\n")
file.write(' if (xxKey == "I"): # Increase' + "\n")
file.write(' vitesse -= 0.01' + "\n")
file.write(' if vitesse <= 0:' + "\n")
file.write(' vitesse = 0' + "\n")
file.write(' App.Console.PrintMessage("Speed maximum"+"' + chr(92) + 'n")' + "\n")
file.write(' else:' + "\n")
file.write(' App.Console.PrintMessage(str(vitesse)+"' + chr(92) + 'n")' + "\n")
file.write('' + "\n")
file.write(' if (xxKey == "D"): # Decrease' + "\n")
file.write(' vitesse += 0.01' + "\n")
file.write(' App.Console.PrintMessage(str(vitesse)+"' + chr(92) + 'n")' + "\n")
file.write('' + "\n")
file.write(' if (xxKey == "V"): # ReVerse' + "\n")
file.write(' xxData.reverse()' + "\n")
file.write('' + "\n")
file.write(' if (xxKey == "A"): # Animation' + "\n")
file.write(' animation = 1' + "\n")
file.write(' if not os.path.exists(path + Document + "_Image"):' + "\n")
file.write(' #os.makedirs(path + Document + "_Image")' + "\n")
file.write(' pathImage = os.mkdir(path + Document + "_Image")' + "\n")
file.write(' else:' + "\n")
file.write(' pathImage = path + Document + "_Image" + "/"' + "\n")
file.write(' countImage = 0' + "\n")
file.write(' App.Console.PrintMessage("Animation image (i wait the first image to begin)" + "' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("(Type Escape to abord)" + "' + chr(92) + 'n")' + "\n")
file.write('' + "\n")
file.write(' if (xxKey == "Y"): # Animation' + "\n")
file.write(' switchYoYo = 1' + "\n")
file.write('' + "\n")
file.write(' if (xxKey == "M"): # Help memo' + "\n")
file.write(' help()' + "\n")
file.write('' + "\n")
file.write('##Begin of data file' + "\n")
file.write('xxData = [' + "\n")
#### macro first section end
#### section save data
for i in saveOnDisk:
file.write(i + "\n")
#### section save data
#### macro second section begin
if self.CB_DataInMacro.isChecked():
file.write(']' + "\n")
file.write('##End of data file' + "\n")
file.write('' + "\n")
file.write('try:' + "\n")
file.write(' v = Gui.activeDocument().activeView()' + "\n")
file.write(' o = ViewObserver()' + "\n")
file.write(' c = v.addEventCallback("SoKeyboardEvent",o.logPosition)' + "\n")
file.write('' + "\n")
file.write(' help() #help message' + "\n")
file.write(' switchImage = 0' + "\n")
file.write('' + "\n")
file.write(' ##Loop' + "\n")
file.write(' while xxKey != "Q":' + "\n")
file.write(' comptCoordinate = -1 # coordinte 0 to ...x' + "\n")
file.write(' if (switchYoYo != 0):' + "\n")
file.write(' xxData.reverse()' + "\n")
file.write(' switchImage = 0' + "\n")
file.write('' + "\n")
file.write(' for p in xxData:' + "\n")
file.write(' #if (xxKey == "Q"): break # Quit the loop after finish the complete loop (commented by default: if used quit the loop as is)' + "\n")
file.write(' comptCoordinate += 1' + "\n")
file.write(' ## p[1]=Coordinate x,y,z; p[2]=Rotation angle x (Roll), y (Pitch), z (Yaw)' + "\n")
file.write(' px = float(p[1][0]); rx = float(p[2][0])' + "\n")
file.write(' py = float(p[1][1]); ry = float(p[2][1])' + "\n")
file.write(' pz = float(p[1][2]); rz = float(p[2][2])' + "\n")
file.write(' App.ActiveDocument.getObject(p[0]).Placement=App.Placement(App.Vector(px,py,pz), App.Rotation(rx,ry,rz), App.Vector(0,0,0))' + "\n")
file.write(' Gui.updateGui() # rafraichi l''ecran' + "\n")
file.write(' time.sleep(vitesse)' + "\n")
file.write('' + "\n")
file.write(' if xxKey == "P": # Pause' + "\n")
file.write(' xxKey = ""' + "\n")
file.write(' comptLoop = 0' + "\n")
file.write(' while xxKey != "P":' + "\n")
file.write(' if xxKey == "RETURN" or xxKey == "PAD_ENTER" or xxKey == "ESCAPE": break' + "\n")
file.write(' comptLoop += 1' + "\n")
file.write(' if comptLoop > 50000:' + "\n")
file.write(' comptLoop = 0' + "\n")
file.write(' App.Console.PrintError("You is in mode Pause : Type P or RETURN or ESCAPE to continue" + "' + chr(92) + 'n")' + "\n")
file.write(' Gui.updateGui() # rafraichi l''ecran' + "\n")
file.write(' xxKey = ""' + "\n")
file.write('' + "\n")
file.write(' if xxKey == "S": # Step by Step' + "\n")
file.write(' App.Console.PrintMessage(str(App.ActiveDocument.getObject(p[0]).Placement) + " #(" + str(comptCoordinate) + ")" + "' + chr(92) + 'n")' + "\n")
file.write(' ####' + "\n")
file.write(' if createPoint == 1:' + "\n")
file.write(' point = Draft.makePoint(App.ActiveDocument.getObject(p[0]).Placement.Base) # create point to Placement.Base' + "\n")
file.write(' Draft.autogroup(point) #' + "\n")
file.write(' FreeCAD.ActiveDocument.recompute() #' + "\n")
file.write(' ####' + "\n")
file.write(' xxKey = ""' + "\n")
file.write(' while xxKey != "S":' + "\n")
file.write(' if xxKey == "RETURN" or xxKey == "PAD_ENTER" or xxKey == "ESCAPE": break' + "\n")
file.write(' xxKey = ""' + "\n")
file.write(' Gui.updateGui() # rafraichi l''ecran' + "\n")
file.write('' + "\n")
file.write(' #### Save image begin' + "\n")
file.write(' if (comptCoordinate <= len(xxData)) and (animation == 1): # section save image' + "\n")
file.write(' if comptCoordinate == 0:' + "\n")
file.write(' switchImage += 1' + "\n")
file.write(' if (switchImage > 1) or (xxKey == "ESCAPE") or (switchYoYo != 0 and (countImage >= ((len(xxData)*2)-1)/jumpingImage)):' + "\n")
file.write(' animation = 0; switchImage = 0' + "\n")
file.write(' App.Console.PrintMessage("Image Format : [" + str(sizeX) + "px x " + str(sizeY) + "px]" + "' + chr(92) + 'n")' + "\n")
file.write(' App.Console.PrintMessage("saved in " + pathImage + "' + chr(92) + 'n" + "' + chr(92) + 'n")' + "\n")
file.write(' if (xxKey == "ESCAPE"): # Escape' + "\n")
file.write(' App.Console.PrintMessage("Save image Aborded with : " + str(countImage) + " images saved" + "' + chr(92) + 'n")' + "\n")
file.write(' countImage = 0' + "\n")
file.write(' xxKey = ""' + "\n")
file.write(' if (switchImage == 1) and (comptCoordinate % jumpingImage == 0):' + "\n")
file.write(' countImage += 1' + "\n")
file.write(' if switchCountZero == 0:' + "\n")
file.write(' Gui.activeDocument().activeView().saveImage(pathImage + Document + str(comptCoordinate + 1)+".png",sizeX, sizeY,"Current")' + "\n")
file.write(' App.Console.PrintMessage(str(comptCoordinate + 1) + " of " + str(len(xxData)) + "' + chr(92) + 'n")' + "\n")
file.write(' else:' + "\n")
file.write(' Gui.activeDocument().activeView().saveImage(pathImage + Document + str(countImage)+".png",sizeX, sizeY,"Current")' + "\n")
file.write(' App.Console.PrintMessage(str(countImage) + " of " + str(int(len(xxData) / jumpingImage)) + "(*)" + "' + chr(92) + 'n")' + "\n")
file.write(' #### Save image end' + "\n")
file.write('' + "\n")
file.write('except Exception:' + "\n")
file.write(' FreeCAD.Console.PrintError("' + chr(92) + 'n"+"Not document open, or not object selected" + "' + chr(92) + 'n")' + "\n")
file.write(' try:' + "\n")
file.write(' v.removeEventCallback("SoKeyboardEvent",c)' + "\n")
file.write(' except Exception:' + "\n")
file.write(' None' + "\n")
file.write('' + "\n")
#### macro second section end
except Exception:
self.label_00.setStyleSheet("color : #ffffff; background-color: red; font: bold 11px;") # white red bold
self.label_00.setText(" Error write file")
# App.Console.PrintError("Error write file "+"\n")
finally:
file.close()
except Exception:
self.label_00.setStyleSheet("color : #ffffff; background-color: red; font: bold 11px;") # white red bold
self.label_00.setText(" Error Write file " + SaveName)
# App.Console.PrintError("Error Write file " + SaveName+"\n")
#### save macro end
def on_PB_ClearMemo(self):
global saveOnDisk
global saveListView
global countMemory
global memorySelected
try:
model = saveListView = QtGui.QStandardItemModel()
self.TE_Memorize.model().removeRows(0, countMemory)# model.rowCount()
saveOnDisk = []
self.TE_Memorize.setModel(saveListView)
countMemory = 0
memorySelected = []
self.PB_Memorize.setText("Memo")
self.PB_Memorize.setStyleSheet("Base")
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Eteint_Icon))) # icone dans une variable
except Exception:
None
def on_CB_On_Click_Apply(self):
if self.CB_On_Click_Apply.isChecked():
self.CB_On_Click_Apply.setIcon(QtGui.QIcon(QtGui.QPixmap(normalWork_Icon))) # icone dans une variable
self.CB_On_Click_Apply.setText(u"Memo on demand")
self.CB_On_Click_Apply.setToolTip(u"Memorize the coordinates on demand")
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Allume_Icon))) # icone dans une variable
self.groupBox_Data.setEnabled(True)
else:
self.CB_On_Click_Apply.setIcon(QtGui.QIcon(QtGui.QPixmap(OnClickApply_Icon))) # icone dans une variable
self.CB_On_Click_Apply.setText(u"Memo on click")
self.CB_On_Click_Apply.setToolTip(u"Memorize the coordinates on all Click Apply button")
def On_CB_DataInMacro(self):
if self.CB_DataInMacro.isChecked():
self.CB_DataInMacro.setIcon(QtGui.QIcon(QtGui.QPixmap(code_FC_Icon))) # icone dans une variable
self.CB_DataInMacro.setText(u"Coordinate")
self.PB_Save_Memorize.setText("Save (wr)")
self.PB_Save_Memorize.setToolTip("The file is open in mode Write" + "\n"
"If the file exist, the file is crushed" + "\n"
"")
else:
self.CB_DataInMacro.setIcon(QtGui.QIcon(QtGui.QPixmap(code_Python_Icon))) # icone dans une variable
self.CB_DataInMacro.setText(u"Macro")
self.PB_Save_Memorize.setText("Save (ap)")
self.PB_Save_Memorize.setToolTip("The file is open in mode Append" + "\n"
"If the file exist, the the data hare adding in the file" + "\n"
"")
def on_PB_Clip_Board(self):
global saveOnDisk
memo = QtWidgets.QApplication.clipboard()
memo.clear(mode=memo.Clipboard )
txt = ""
for i in range(len(saveOnDisk)):
txt += saveOnDisk[i] + "\n"
memo.setText(txt, mode = memo.Clipboard)
txt = ""
def on_DS_Value_Angle_Dimension(self,val):
global valeur
global myObject
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
global axisX, axisY, axisZ
global posFollow
valeur = val
if (myObject == "") or (valeur == 0):
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Eteint_Icon))) # icone dans une variable
self.DS_Value_Angle_Dimension.setValue(0.0)
self.DS_Value_Angle_Dimension.setStyleSheet("background-color: rgb(250, 88, 88)")
# self.SC_Slider_Bar.setValue(0.0)
None
else:
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Allume_Icon))) # icone dans une variable
self.DS_Value_Angle_Dimension.setStyleSheet("Base")
self.PB_Memorize.setStyleSheet("Base")
# 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))
elif (self.RB_Direction_D.isChecked()) or (self.RB_Follow_The_Path_F.isChecked()):
posZ = valeur
posX = posY = 0.0
xD = str(round(myObject.Placement.Base[0],4))
yD = str(round(myObject.Placement.Base[1],4))
zD = str(round(myObject.Placement.Base[2],4))
self.LE_Increment.setText("(" + xD + ", " + yD + ", " + zD + ")")
if self.RB_Follow_The_Path_F.isChecked():
selectedEdge = FreeCADGui.Selection.getSelectionEx() # Select an object or sub object getSelectionEx
try:
posFollow = selectedEdge[1].SubObjects[0].discretize(Distance=abs(valeur)) # 1 object, 1 object ou subObject
except Exception:
try:
posFollow = selectedEdge[0].SubObjects[1].discretize(Distance=abs(valeur)) # 1 object avec son subobject
except Exception:
print("stop")
xD = str(round(myObject.Placement.Base[0],4))
yD = str(round(myObject.Placement.Base[1],4))
zD = str(round(myObject.Placement.Base[2],4))
self.LE_Increment.setText("(" + xD + ", " + yD + ", " + zD + ")")
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)) + ")]")
self.label_00.setStyleSheet("font: 11px;")
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))
elif self.RB_Direction_D.isChecked():
rotAngleZ = valeur
rotAngleX = rotAngleY = 0.0
xD = str(round(myObject.Placement.Rotation.toEuler()[0],4))
yD = str(round(myObject.Placement.Rotation.toEuler()[1],4))
zD = str(round(myObject.Placement.Rotation.toEuler()[2],4))
self.LE_Increment.setText("(" + xD + ", " + yD + ", " + zD + ")")
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)) + ")]")
self.label_00.setStyleSheet("font: 11px;")
if valeur < 0:
self.PB_Negatif.setIcon(QtGui.QIcon(QtGui.QPixmap(positif_Icon))) # icone dans une variable
else:
self.PB_Negatif.setIcon(QtGui.QIcon(QtGui.QPixmap(negatif_Icon))) # icone dans une variable
def on_PB_Negatif_clicked(self):
global valeur
if valeur < 0:
self.PB_Negatif.setIcon(QtGui.QIcon(QtGui.QPixmap(negatif_Icon))) # icone dans une variable
else:
self.PB_Negatif.setIcon(QtGui.QIcon(QtGui.QPixmap(positif_Icon))) # icone dans une variable
self.DS_Value_Angle_Dimension.setValue(-valeur) # !?
def restitue_Values(self, switch): #, switch 0 = read configuration, 1 = write configuration
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
global axisX, axisY, axisZ
if switch == 0:
a = self.CB_Position.isChecked()
b = self.RB_Bond_Box_Center.isChecked()
c = self.RB_Center_Mass.isChecked()
d = self.RB_Point_Clicked.isChecked()
e = self.RB_Rotation_X.isChecked()
f = self.RB_Rotation_Y.isChecked()
g = self.RB_Rotation_Z.isChecked()
h = self.RB_Direction_D.isChecked()
i = self.RB_Follow_The_Path_F.isChecked()
j = self.DS_Value_Angle_Dimension.value()
return [a, b, c, d, e, f, g, h, i, j, posX, posY, posZ, rotAngleX, rotAngleY, rotAngleZ, axisX, axisY, axisZ]
def on_CBox_View(self, text): # memory view on object worked
global ui
global duplicate_View
global sourisPass
global myObjectName
global myObjectLabel
global switchZoomOnCilck
global originalObject
global myObject
global sel
global selM
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
global axisX, axisY, axisZ
if text == "Empty":
#duplicate_View = sorted(list(set(duplicate_View))) # trie et tire les doublons
duplicate_View = sorted(duplicate_View, key=itemgetter(0)) # sort
try: # supprime les doublons apres avoir ete trie (sorted)
doublon = 1
while doublon < len(duplicate_View):
if (duplicate_View[doublon][0] == duplicate_View[doublon-1][0]):
del duplicate_View[doublon-1]
doublon -= 1
doublon += 1
except Exception:
None
self.CBox_View.blockSignals(True)
self.CBox_View.clear()
for i in range(len(duplicate_View)): # copie les noms tries dans ComboBox_View
self.CBox_View.addItem(duplicate_View[i][0])
self.CBox_View.blockSignals(False)
duplicate_View[i] = duplicate_View[i] + self.restitue_Values(0) # copy options used
else:
for i in range(len(duplicate_View)):
if text == duplicate_View[i][0]:
sourisPass = 1
Gui.Selection.clearSelection()
originalObject = myObject = sel = selM = ""
Gui.Selection.addSelection(App.ActiveDocument.getObject(duplicate_View[i][0]))
originalObject = myObject = sel = selM = App.ActiveDocument.getObject(duplicate_View[i][0])
myObjectLabel = sel.Label
if switchZoomOnCilck == 1:
Gui.ActiveDocument.ActiveView.setCamera(duplicate_View[i][1]) #restore previously stored camera settings
myObjectName = duplicate_View[i][0]
self.groupBox_Work.setTitle(u"Work (" + myObjectName + " : " + myObjectLabel +")")
####
self.CB_Position.setChecked(duplicate_View[i][2]) #restore previously stored options settings
self.RB_Bond_Box_Center.setChecked(duplicate_View[i][3])
self.RB_Center_Mass.setChecked(duplicate_View[i][4])
self.RB_Point_Clicked.setChecked(duplicate_View[i][5])
self.RB_Rotation_X.setChecked(duplicate_View[i][6])
self.RB_Rotation_Y.setChecked(duplicate_View[i][7])
self.RB_Rotation_Z.setChecked(duplicate_View[i][8])
self.RB_Direction_D.setChecked(duplicate_View[i][9])
self.RB_Follow_The_Path_F.setChecked(duplicate_View[i][10])
self.DS_Value_Angle_Dimension.setValue(duplicate_View[i][11])
##
posX = duplicate_View[i][12]
posY = duplicate_View[i][13]
posZ = duplicate_View[i][14]
rotAngleX = duplicate_View[i][15]
rotAngleY = duplicate_View[i][16]
rotAngleZ = duplicate_View[i][17]
axisX = duplicate_View[i][18]
axisY = duplicate_View[i][19]
axisZ = duplicate_View[i][20]
####
def on_CBox_Impost(self,text): # value length and degrees
if self.CB_Position.isChecked():
self.CBox_Impost.setCurrentIndex(5)
self.CBox_Impost.setItemText(0, "0.0001")
self.CBox_Impost.setItemText(1, "0.001")
self.CBox_Impost.setItemText(2, "0.01")
self.CBox_Impost.setItemText(3, "0.1")
self.CBox_Impost.setItemText(4, "0.5")
self.CBox_Impost.setItemText(5, "0")
self.CBox_Impost.setItemText(6, "1")
self.CBox_Impost.setItemText(7, "5")
self.CBox_Impost.setItemText(8, "10")
self.CBox_Impost.setItemText(9, "25")
self.CBox_Impost.setItemText(10, "50")
self.CBox_Impost.setItemText(11, "100")
self.CBox_Impost.setItemText(12, "250")
self.CBox_Impost.setItemText(13, "500")
self.CBox_Impost.setItemText(14, "1000")
self.CBox_Impost.setItemText(15, "5000")
self.CBox_Impost.setItemText(16, "10000")
else:
self.CBox_Impost.setCurrentIndex(5)
self.CBox_Impost.setItemText(0, "0.0001")
self.CBox_Impost.setItemText(1, "0.001")
self.CBox_Impost.setItemText(2, "0.01")
self.CBox_Impost.setItemText(3, "0.1")
self.CBox_Impost.setItemText(4, "0.5")
self.CBox_Impost.setItemText(5, "0")
self.CBox_Impost.setItemText(6, "1")
self.CBox_Impost.setItemText(7, "5")
self.CBox_Impost.setItemText(8, "10")
self.CBox_Impost.setItemText(9, "20")
self.CBox_Impost.setItemText(10, "30")
self.CBox_Impost.setItemText(11, "40")
self.CBox_Impost.setItemText(12, "45")
self.CBox_Impost.setItemText(13, "60")
self.CBox_Impost.setItemText(14, "90")
self.CBox_Impost.setItemText(15, "120")
self.CBox_Impost.setItemText(16, "180")
self.DS_Value_Angle_Dimension.setProperty("value", text)
def on_CBox_Memory(self,text): # memory the value sort and delete duplicate
global duplicate_Memory
self.DS_Value_Angle_Dimension.setValue(float(text))
duplicate_Memory.append(float(text))
duplicate_Memory = sorted(list(set(duplicate_Memory))) # sort
self.CBox_Memory.blockSignals(True)
self.CBox_Memory.clear()
for i in range(len(duplicate_Memory)):
self.CBox_Memory.addItem(str(duplicate_Memory[i]))
self.CBox_Memory.blockSignals(False)
def on_LE_Increment_Pressed(self,text):
None
def on_PB_Apply_clicked(self):
global ui
global valeur
global selM
global myObject
global myObjectName
global myObjectLabel
global duplicate_View
global posX, posY, posZ
global rotAngleX, rotAngleY, rotAngleZ
global axisX, axisY, axisZ
global posFollow
global compPosFollow
if (myObject == "") or (valeur == 0):
self.label_00.setStyleSheet("color : #ffffff; background-color: red; font: bold 11px;") # white red bold
self.label_00.setText(" Select one Object or give one value Angle/Dimension")
# FreeCAD.Console.PrintError("Select one Object or give one value Angle/Dimension" + "\n")
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Eteint_Icon))) # icone dans une variable
if valeur == 0:
self.DS_Value_Angle_Dimension.setStyleSheet("background-color: rgb(250, 88, 88)")
else:
self.PB_Memorize.setIcon(QtGui.QIcon(QtGui.QPixmap(memo_Allume_Icon))) # icone dans une variable
#Gui.ActiveDocument.ActiveView.setCamera(camera) #restore previously stored camera settings
camera = Gui.ActiveDocument.ActiveView.getCamera() #store camera settings to 'cam'
duplicate_View.append([myObjectName, camera])
self.on_CBox_View("Empty")
self.on_CBox_Memory(self.DS_Value_Angle_Dimension.value())
if self.CB_Position.isChecked(): # section translate
try:
self.countOpenTransaction += 1
FreeCAD.ActiveDocument.openTransaction("RTP T (" + str(self.countOpenTransaction) + ") : " + myObjectName + " : " + myObjectLabel + " (" + str(valeur) +" mm)") # memorise les actions (avec annuler restore)
if (self.RB_Direction_D.isChecked()) or (self.RB_Follow_The_Path_F.isChecked()): # direction
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[1] # select one element and axis same object (2 selections)
except Exception:
None
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] # select one element and axis same object (1 selection)
except Exception:
None
pointsTrajet = []
####
pointsTrajet = selectedEdge.discretize(Distance = 1.0) # discretize the element for calculate the direction
direction = pointsTrajet[1].sub(pointsTrajet[0]) # search the direction line or sub
####
if self.RB_Follow_The_Path_F.isChecked(): # Path
if valeur > 0:
compPosFollow += 1
if compPosFollow > len(posFollow)-1:
compPosFollow = 0
else:
compPosFollow -= 1
if compPosFollow < 0:
compPosFollow = len(posFollow)-1
selM.Placement.Base=App.Vector(posFollow[compPosFollow][0], posFollow[compPosFollow][1], posFollow[compPosFollow][2])
else:
selM.Placement.Base = myObject.Placement.Base + App.Vector(direction).scale(valeur, valeur, valeur)
else:
selM.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(myObjectName).Placement)
myObject = selM
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)))
elif (self.RB_Direction_D.isChecked()) or (self.RB_Follow_The_Path_F.isChecked()):
xD = str(round(myObject.Placement.Base[0],4))
yD = str(round(myObject.Placement.Base[1],4))
zD = str(round(myObject.Placement.Base[2],4))
self.LE_Increment.setText("(" + xD + ", " + yD + ", " + zD + ")")
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)) + ")]")
except Exception:
self.label_00.setStyleSheet("color : #ffffff; background-color: red; font: bold 11px;") # white red bold
self.label_00.setText(" Select 2 elements 1:object, 2:the direction or path")
else: # section rotation
if self.RB_Direction_D.isChecked(): # direction
self.countOpenTransaction += 1
FreeCAD.ActiveDocument.openTransaction("RTP D (" + str(self.countOpenTransaction) + ") : " + myObjectName + " : " + myObjectLabel + " (" + str(valeur) +" mm)") # memorise les actions (avec annuler restore)
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[1] # select one element and axis same object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] # select one element and axis same object (1 selection)
except Exception:
None
try:
direction = selectedEdge.Vertexes[1].Point.sub(selectedEdge.Vertexes[0].Point)# search the direction line or sub
except Exception:
try:
direction = objectRotation.Vertexes[0].Point
except Exception:
direction = App.Vector(0.0,0.0,0.0)
selM.Placement = App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(App.Vector(direction), valeur), App.Vector(axisX, axisY, axisZ)).multiply(App.ActiveDocument.getObject(myObjectName).Placement)
else:
self.countOpenTransaction += 1
FreeCAD.ActiveDocument.openTransaction("RTP R (" + str(self.countOpenTransaction) + ") : " + myObjectName + " : " + myObjectLabel + " (" + str(valeur) +" deg)") # memorise les actions (avec annuler restore)
selM.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(myObjectName).Placement) # other method
myObject = selM
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)))
elif self.RB_Direction_D.isChecked():
xD = str(round(myObject.Placement.Rotation.toEuler()[0],4))
yD = str(round(myObject.Placement.Rotation.toEuler()[1],4))
zD = str(round(myObject.Placement.Rotation.toEuler()[2],4))
self.LE_Increment.setText("(" + xD + ", " + yD + ", " + zD + ")")
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.CB_On_Click_Apply.isChecked():
self.on_PB_Memorize()
# FreeCAD.ActiveDocument.recompute()
def on_RB_Rotation_0(self):
None
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_Value_Angle_Dimension.setValue(0.0)
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_Value_Angle_Dimension.setValue(0.0)
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_Value_Angle_Dimension.setValue(0.0)
def on_RB_Direction_D(self):
global myObject
if self.CB_Position.isChecked():
xD = str(round(myObject.Placement.Base[0],4))
yD = str(round(myObject.Placement.Base[1],4))
zD = str(round(myObject.Placement.Base[2],4))
else:
xD = str(round(myObject.Placement.Rotation.toEuler()[0],4))
yD = str(round(myObject.Placement.Rotation.toEuler()[1],4))