diff --git a/Scripts/Modeling/Edit/ModIt/Class/Collapsible.py b/Scripts/Modeling/Edit/ModIt/Class/Collapsible.py new file mode 100644 index 0000000..9b993ae --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Class/Collapsible.py @@ -0,0 +1,125 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +from .. import ModIt_Global + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath + +WIN_DISPLAY_SIZE =(json.load(open(PreferencePath + 'WinSize.json',"r"))['VALUE']) + + + + +class CollapsibleHeader(QtWidgets.QWidget): + COLLAPSED_PIXMAP = QtGui.QPixmap(IconPath + "Arrow_Collapse") + EXPANDED_PIXMAP = QtGui.QPixmap(IconPath + "Arrow_Down") + + clicked = QtCore.Signal() + + def __init__(self, text, parent=None): + super(CollapsibleHeader, self).__init__(parent) + + self.setAutoFillBackground(True) + self.set_background_color(True) + + self.icon_label = QtWidgets.QLabel() + self.icon_label.setFixedWidth(self.COLLAPSED_PIXMAP.width()) + + self.text_label = QtWidgets.QLabel() + self.text_label.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) + + self.main_layout = QtWidgets.QHBoxLayout(self) + self.main_layout.setContentsMargins(4, 4, 4, 0) + self.main_layout.setSpacing(12) # DISTANCE du TITRE de la FLECHE + self.main_layout.addWidget(self.icon_label) + self.main_layout.addWidget(self.text_label) + + self.set_text(text) + self.set_expanded(False) + + def set_text(self, text): + self.text_label.setText("{0}".format(text)) + if WIN_DISPLAY_SIZE == 1: #150% + self.text_label.setFont(QtGui.QFont('Candara', 6)) + + def set_background_color(self, color): + if not color: + color = QtWidgets.QPushButton().palette().color(QtGui.QPalette.Button) + + palette = self.palette() + palette.setColor(QtGui.QPalette.Window, color) + self.setPalette(palette) + + def is_expanded(self): + return self._expanded + + def set_expanded(self, expanded): + self._expanded = expanded + + if (self._expanded): + self.icon_label.setPixmap(self.EXPANDED_PIXMAP) + else: + self.icon_label.setPixmap(self.COLLAPSED_PIXMAP) + + def mousePressEvent(self, event): + self.clicked.emit() # pylint: disable=E1101 + + +class CollapsibleWidget(QtWidgets.QWidget): + collapsed_signal = QtCore.Signal(bool) + + def __init__(self, text, parent=None): + super(CollapsibleWidget, self).__init__(parent) + + self.header_wdg = CollapsibleHeader(text) + self.header_wdg.clicked.connect(self.on_header_clicked) # pylint: disable=E1101 + + self.Body_wdg = QtWidgets.QWidget() + self.Body_wdg.setContentsMargins(0, 0, 0, 0) + + self.MAIN_lyt = QtWidgets.QVBoxLayout(self.Body_wdg) + self.MAIN_lyt.setContentsMargins(0, 0, 0, 0) + + + self.main_layout = QtWidgets.QVBoxLayout(self) + self.main_layout.setContentsMargins(0, 0, 0, 0) + self.main_layout.addWidget(self.header_wdg) + self.main_layout.addWidget(self.Body_wdg) + + + self.set_expanded(False) + + def add_widget(self, widget): + self.MAIN_lyt.addWidget(widget) + + def add_layout(self, layout): + self.MAIN_lyt.addLayout(layout) + + def set_expanded(self, expanded): + self.header_wdg.set_expanded(expanded) + self.Body_wdg.setVisible(expanded) + self.collapsed_signal.emit(expanded) + + def set_header_background_color(self, color): + self.header_wdg.set_background_color(color) + + def on_header_clicked(self): + self.set_expanded(not self.header_wdg.is_expanded()) + # TestDialog.btnAction(self) diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/2Bevel.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/2Bevel.png new file mode 100644 index 0000000..7940004 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/2Bevel.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ARROW.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ARROW.psd new file mode 100644 index 0000000..df4a43e Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ARROW.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AddEdgeFlow.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AddEdgeFlow.png new file mode 100644 index 0000000..5a56443 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AddEdgeFlow.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignFace.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignFace.png new file mode 100644 index 0000000..47d6b87 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignFace.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignFace2.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignFace2.png new file mode 100644 index 0000000..71e6af1 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignFace2.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignPivot.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignPivot.png new file mode 100644 index 0000000..0f42b43 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AlignPivot.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Apply.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Apply.png new file mode 100644 index 0000000..4190acf Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Apply.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Collapse.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Collapse.png new file mode 100644 index 0000000..f9eb97c Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Collapse.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Collapse2.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Collapse2.png new file mode 100644 index 0000000..ffa2be1 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Collapse2.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Down.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Down.png new file mode 100644 index 0000000..f2a80d9 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Down.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Down2.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Down2.png new file mode 100644 index 0000000..dbf7008 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Down2.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_SetChoice.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_SetChoice.png new file mode 100644 index 0000000..bf084cf Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_SetChoice.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_SetChoice2.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_SetChoice2.png new file mode 100644 index 0000000..a2fecbf Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_SetChoice2.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Up2.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Up2.png new file mode 100644 index 0000000..22c32e6 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Arrow_Up2.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AssetIt_Presa_Img.jpg b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AssetIt_Presa_Img.jpg new file mode 100644 index 0000000..472a567 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/AssetIt_Presa_Img.jpg differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/BatchProcess.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/BatchProcess.png new file mode 100644 index 0000000..c454bdc Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/BatchProcess.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/BevAdd.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/BevAdd.png new file mode 100644 index 0000000..02ec2e5 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/BevAdd.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/COLORS.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/COLORS.psd new file mode 100644 index 0000000..1d30dcd Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/COLORS.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/CenterPivt.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/CenterPivt.png new file mode 100644 index 0000000..2f1487a Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/CenterPivt.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorBlack.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorBlack.png new file mode 100644 index 0000000..914b28c Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorBlack.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorBlue.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorBlue.png new file mode 100644 index 0000000..5ed5436 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorBlue.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorCyan.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorCyan.png new file mode 100644 index 0000000..ad9dae5 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorCyan.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorGreen.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorGreen.png new file mode 100644 index 0000000..5771697 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorGreen.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorLambert.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorLambert.png new file mode 100644 index 0000000..c7c6d94 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorLambert.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorOrange.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorOrange.png new file mode 100644 index 0000000..e233f88 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorOrange.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorRed.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorRed.png new file mode 100644 index 0000000..7bff675 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorRed.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorYellow.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorYellow.png new file mode 100644 index 0000000..b975ead Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ColorYellow.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Color_Default_Icon.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Color_Default_Icon.png new file mode 100644 index 0000000..c7c6d94 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Color_Default_Icon.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Combine.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Combine.png new file mode 100644 index 0000000..6a43034 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Combine.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ComboBox_Arrow.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ComboBox_Arrow.png new file mode 100644 index 0000000..5aa070f Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ComboBox_Arrow.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ContinusEdge.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ContinusEdge.png new file mode 100644 index 0000000..bfb5069 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ContinusEdge.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ContinusEdge.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ContinusEdge.psd new file mode 100644 index 0000000..e341607 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ContinusEdge.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/DISPLAY.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/DISPLAY.psd new file mode 100644 index 0000000..0e0c421 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/DISPLAY.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/DUP.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/DUP.psd new file mode 100644 index 0000000..374fdc5 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/DUP.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Deform_Bend.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Deform_Bend.png new file mode 100644 index 0000000..5fe5248 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Deform_Bend.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Deform_Lattice.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Deform_Lattice.png new file mode 100644 index 0000000..67c62fb Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Deform_Lattice.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Delete.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Delete.png new file mode 100644 index 0000000..7b69343 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Delete.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Discord_ico.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Discord_ico.png new file mode 100644 index 0000000..88fb728 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Discord_ico.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Display_Hide.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Display_Hide.png new file mode 100644 index 0000000..2d8427d Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Display_Hide.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Display_Show.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Display_Show.png new file mode 100644 index 0000000..85261d3 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Display_Show.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Curve.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Curve.png new file mode 100644 index 0000000..fed1550 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Curve.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Linear.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Linear.png new file mode 100644 index 0000000..fc13db4 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Linear.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Offset.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Offset.png new file mode 100644 index 0000000..0ba9bd7 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Offset.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Radial.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Radial.png new file mode 100644 index 0000000..ede7131 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Dup_Radial.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FaceDupli.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FaceDupli.png new file mode 100644 index 0000000..cb2ae50 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FaceDupli.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FaceExtract.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FaceExtract.png new file mode 100644 index 0000000..c3be35e Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FaceExtract.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FullScreen_Off.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FullScreen_Off.png new file mode 100644 index 0000000..180bc5b Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FullScreen_Off.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FullScreen_On.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FullScreen_On.png new file mode 100644 index 0000000..0a8ecc0 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/FullScreen_On.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Get.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Get.png new file mode 100644 index 0000000..d2e0759 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Get.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/HardEdge.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/HardEdge.png new file mode 100644 index 0000000..d1efe4f Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/HardEdge.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/LightRig_btn.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/LightRig_btn.png new file mode 100644 index 0000000..f47a45b Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/LightRig_btn.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_cible.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_cible.png new file mode 100644 index 0000000..3651e3a Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_cible.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_cible_setting.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_cible_setting.png new file mode 100644 index 0000000..19edff7 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_cible_setting.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_orign.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_orign.png new file mode 100644 index 0000000..296a77f Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Locator_orign.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MESH.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MESH.psd new file mode 100644 index 0000000..0236bc8 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MESH.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING.psd new file mode 100644 index 0000000..edfdf47 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING_OFF.png new file mode 100644 index 0000000..e6541a2 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING_ON.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING_ON.png new file mode 100644 index 0000000..6c3e7ed Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/MODELING_ON.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ModIt_Window_Ico.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ModIt_Window_Ico.png new file mode 100644 index 0000000..d6cf325 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ModIt_Window_Ico.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Moins.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Moins.png new file mode 100644 index 0000000..56526c7 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Moins.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PLACEMENT_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PLACEMENT_OFF.png new file mode 100644 index 0000000..528f072 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PLACEMENT_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PLACEMENT_ON.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PLACEMENT_ON.png new file mode 100644 index 0000000..bdf7d42 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PLACEMENT_ON.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PlaceOnTopOf.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PlaceOnTopOf.png new file mode 100644 index 0000000..97a0ab1 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/PlaceOnTopOf.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Drag.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Drag.png new file mode 100644 index 0000000..85f5ec8 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Drag.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Drag_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Drag_OFF.png new file mode 100644 index 0000000..c5b72a3 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Drag_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Orign.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Orign.png new file mode 100644 index 0000000..39c0c1e Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Orign.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Orign_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Orign_OFF.png new file mode 100644 index 0000000..85bcb5a Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Orign_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Selection.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Selection.png new file mode 100644 index 0000000..332c4bb Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Selection.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Selection_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Selection_OFF.png new file mode 100644 index 0000000..2499759 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Placement_Selection_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Plus.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Plus.png new file mode 100644 index 0000000..df65b51 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Plus.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_CUBE.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_CUBE.png new file mode 100644 index 0000000..baabcd5 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_CUBE.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_CYLINDRE.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_CYLINDRE.png new file mode 100644 index 0000000..db6e49b Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_CYLINDRE.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_OnTopOf.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_OnTopOf.png new file mode 100644 index 0000000..e75e1f5 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_OnTopOf.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_PLANE.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_PLANE.png new file mode 100644 index 0000000..9c35553 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_PLANE.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_SPHERE.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_SPHERE.png new file mode 100644 index 0000000..b6a5616 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Prim_SPHERE.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Replace.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Replace.png new file mode 100644 index 0000000..4fe8348 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Replace.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING.psd new file mode 100644 index 0000000..eaa8404 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING_OFF.png new file mode 100644 index 0000000..13ba078 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING_ON.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING_ON.png new file mode 100644 index 0000000..7a82af8 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SETTING_ON.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SET_Icons.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SET_Icons.psd new file mode 100644 index 0000000..6981649 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SET_Icons.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SHADING.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SHADING.psd new file mode 100644 index 0000000..efb9451 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SHADING.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SHADING_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SHADING_OFF.png new file mode 100644 index 0000000..afffa62 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SHADING_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco1.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco1.png new file mode 100644 index 0000000..a50d0f3 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco1.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco1b.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco1b.png new file mode 100644 index 0000000..0ce3581 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco1b.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco2.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco2.png new file mode 100644 index 0000000..9c133f4 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco2.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco3.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco3.png new file mode 100644 index 0000000..0636292 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco3.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco4.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco4.png new file mode 100644 index 0000000..fa19beb Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SelIco4.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Separate.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Separate.png new file mode 100644 index 0000000..9b34500 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Separate.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Separator2Btn.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Separator2Btn.png new file mode 100644 index 0000000..2b2b7d4 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Separator2Btn.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorBlackBtn.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorBlackBtn.png new file mode 100644 index 0000000..cbeaf0e Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorBlackBtn.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorBtn.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorBtn.png new file mode 100644 index 0000000..811ecf7 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorBtn.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorPointBtn.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorPointBtn.png new file mode 100644 index 0000000..3175414 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SeparatorPointBtn.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ShaderAttributs.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ShaderAttributs.png new file mode 100644 index 0000000..99d2c02 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/ShaderAttributs.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Shading_ON.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Shading_ON.png new file mode 100644 index 0000000..13f93e0 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Shading_ON.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Sym.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Sym.psd new file mode 100644 index 0000000..8884b50 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Sym.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymBakeInstance.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymBakeInstance.png new file mode 100644 index 0000000..4a4cec2 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymBakeInstance.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymFlip.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymFlip.png new file mode 100644 index 0000000..905db25 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymFlip.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymMerge.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymMerge.png new file mode 100644 index 0000000..3bee5eb Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymMerge.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymPivot.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymPivot.png new file mode 100644 index 0000000..6d4951c Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/SymPivot.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Sym_Setting.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Sym_Setting.png new file mode 100644 index 0000000..1ed8116 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Sym_Setting.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/TabScrew_OFF.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/TabScrew_OFF.png new file mode 100644 index 0000000..b24f9a2 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/TabScrew_OFF.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/TabScrew_ON.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/TabScrew_ON.png new file mode 100644 index 0000000..0873f81 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/TabScrew_ON.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/UTILS.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/UTILS.psd new file mode 100644 index 0000000..a0df34f Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/UTILS.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_AlignPivot.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_AlignPivot.png new file mode 100644 index 0000000..63b83fa Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_AlignPivot.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_BtoA.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_BtoA.png new file mode 100644 index 0000000..7051008 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_BtoA.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_FreezeT.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_FreezeT.png new file mode 100644 index 0000000..07de8dc Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_FreezeT.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_Historique.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_Historique.png new file mode 100644 index 0000000..ced2f89 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_Historique.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_Optimize.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_Optimize.png new file mode 100644 index 0000000..e62ac78 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Util_Optimize.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Auto.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Auto.png new file mode 100644 index 0000000..f772c97 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Auto.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_GetShader.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_GetShader.png new file mode 100644 index 0000000..f600f30 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_GetShader.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Hdri.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Hdri.png new file mode 100644 index 0000000..ad7ed42 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Hdri.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Icons.psd b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Icons.psd new file mode 100644 index 0000000..d390ae3 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Icons.psd differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Planar.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Planar.png new file mode 100644 index 0000000..76124d7 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_Planar.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_UvShader.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_UvShader.png new file mode 100644 index 0000000..aeec5e5 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/VP_UvShader.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Vp_Lights.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Vp_Lights.png new file mode 100644 index 0000000..76259a4 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Vp_Lights.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Welder_Icon.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Welder_Icon.png new file mode 100644 index 0000000..a27b2b9 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Welder_Icon.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Welder_Paint.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Welder_Paint.png new file mode 100644 index 0000000..ab61736 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Welder_Paint.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WinDock.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WinDock.png new file mode 100644 index 0000000..ff2501b Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WinDock.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WinSize.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WinSize.png new file mode 100644 index 0000000..a2da56f Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WinSize.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Windows_Ico_Warning.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Windows_Ico_Warning.png new file mode 100644 index 0000000..18a3cc2 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/Windows_Ico_Warning.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WzxStore_ico.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WzxStore_ico.png new file mode 100644 index 0000000..a12e036 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/WzxStore_ico.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/delete_ON.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/delete_ON.png new file mode 100644 index 0000000..a8de0b4 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/delete_ON.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/delete_Off.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/delete_Off.png new file mode 100644 index 0000000..3c61c3c Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/delete_Off.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/fillet.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/fillet.png new file mode 100644 index 0000000..67a2152 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/fillet.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/fixFlow.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/fixFlow.png new file mode 100644 index 0000000..17616f8 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/fixFlow.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polyHard.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polyHard.png new file mode 100644 index 0000000..109f374 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polyHard.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polyNormalSetAngle.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polyNormalSetAngle.png new file mode 100644 index 0000000..be7a9d5 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polyNormalSetAngle.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polySoftEdge.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polySoftEdge.png new file mode 100644 index 0000000..688d820 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/polySoftEdge.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/saveDisk.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/saveDisk.png new file mode 100644 index 0000000..624ea2e Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/saveDisk.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setDel.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setDel.png new file mode 100644 index 0000000..c55cd68 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setDel.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setGet.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setGet.png new file mode 100644 index 0000000..e5fc71b Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setGet.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setIntersect.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setIntersect.png new file mode 100644 index 0000000..5d1efe1 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/setIntersect.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/sphere.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/sphere.png new file mode 100644 index 0000000..543bb6d Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/sphere.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/vertexBevel.png b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/vertexBevel.png new file mode 100644 index 0000000..cf70d94 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/Icons/Theme_Classic/vertexBevel.png differ diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/ModIt_2Bevels_UI.py b/Scripts/Modeling/Edit/ModIt/Modeling/ModIt_2Bevels_UI.py new file mode 100644 index 0000000..0bdc354 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/ModIt_2Bevels_UI.py @@ -0,0 +1,241 @@ +##-------------------------------------------------------------------------- +## ScriptName : ModIt 3.0 +## Author : Wizix +## StartDate : 2022/09/09 +## LastUpdate : 2022/13/09 +## Version : 0.0.1 +##-------------------------------------------------------------------------- I M P O R T +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +from maya import OpenMayaUI as omui +from functools import partial +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget +##---------------------------------------- Import Modules +import importlib +from .. import ModIt_Global +importlib.reload(ModIt_Global) +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) +##---------------------------------------- Import Classes + + +##-------------------------------------------------------------------------- G L O B A L V A R +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +WindowsTitle = "Bevel2" + +BevelA = "" +BevelB = "" + +##UI INFO +# ________________// +# ___________________________________________ +# ________________// +def SEND_INFO(BevelA_node, BevelB_node): + global BevelA + BevelA = BevelA_node + + global BevelB + BevelB = BevelB_node + + return BevelA + BevelB + + +class Bevel2_UI(QtWidgets.QDialog): + def __init__(self, parent=None): + super(Bevel2_UI, self).__init__() + self.setMinimumSize(420, 100) + self.buildUI() + + #Wireframe OnSHade ON + viewport = mc.getPanel(withFocus=True) + mc.modelEditor(viewport, edit=True, wireframeOnShaded=True) + + def buildUI(self): + ##UI - Preferences + iconButtonSize = 10 + + # ________________// + # ___________________________________________## UI + # ________________// + BEVELS2_MLyt = QtWidgets.QVBoxLayout(self) + self.setStyleSheet(ModIt_Global.Theme) + + + Title = QtWidgets.QLabel(" - M i x e d B e v e l s - ") + Title.setAlignment(QtCore.Qt.AlignCenter) + BEVELS2_MLyt.addWidget(Title) + BEVELS2_MLyt.addSpacing(10) + + + + # ___________________________________________## BEVEL A + SliderA_HLyt = QtWidgets.QHBoxLayout(self) + BEVELS2_MLyt.addLayout(SliderA_HLyt) + + BevA_Title = QtWidgets.QLabel(" - Bevel A ") + SliderA_HLyt.addWidget(BevA_Title) + + self.BevelA_Slider = QtWidgets.QSlider() + self.BevelA_Slider.setMinimum(1) + self.BevelA_Slider.setMaximum(95) + self.BevelA_Slider.setProperty("value", 50) + self.BevelA_Slider.setOrientation(QtCore.Qt.Horizontal) + self.BevelA_Slider.setTickPosition(QtWidgets.QSlider.TicksAbove) + self.BevelA_Slider.setTickInterval(1) + self.BevelA_Slider.setFixedHeight(22) + self.BevelA_Slider.valueChanged.connect(self.SliderA_Action) + SliderA_HLyt.addWidget(self.BevelA_Slider) + + + self.BevelA_SpinBox = QtWidgets.QDoubleSpinBox() + self.BevelA_SpinBox.setDecimals(2) + self.BevelA_SpinBox.setFixedWidth(40) + self.BevelA_SpinBox.setFixedHeight(18) + self.BevelA_SpinBox.setRange(0.01, 0.95) + self.BevelA_SpinBox.setValue(0.5) + self.BevelA_SpinBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons) + self.BevelA_SpinBox.editingFinished.connect(self.SpinBoxA_Action) + SliderA_HLyt.addWidget(self.BevelA_SpinBox) + + + + BEVELS2_MLyt.addSpacing(5) + + # ___________________________________________## BEVEL B + SliderB_HLyt = QtWidgets.QHBoxLayout(self) + BEVELS2_MLyt.addLayout(SliderB_HLyt) + + BevB_Title = QtWidgets.QLabel(" - Bevel B ") + SliderB_HLyt.addWidget(BevB_Title) + + self.BevelB_Slider = QtWidgets.QSlider() + self.BevelB_Slider.setMinimum(1) + self.BevelB_Slider.setMaximum(95) + self.BevelB_Slider.setProperty("value", 50) + self.BevelB_Slider.setOrientation(QtCore.Qt.Horizontal) + self.BevelB_Slider.setTickPosition(QtWidgets.QSlider.TicksAbove) + self.BevelB_Slider.setTickInterval(1) + self.BevelB_Slider.setFixedHeight(22) + self.BevelB_Slider.valueChanged.connect(self.SliderB_Action) + SliderB_HLyt.addWidget(self.BevelB_Slider) + + + self.BevelB_SpinBox = QtWidgets.QDoubleSpinBox() + self.BevelB_SpinBox.setDecimals(2) + self.BevelB_SpinBox.setFixedWidth(40) + self.BevelB_SpinBox.setFixedHeight(18) + self.BevelB_SpinBox.setRange(0.01, 0.95) + self.BevelB_SpinBox.setValue(0.5) + self.BevelB_SpinBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons) + self.BevelB_SpinBox.editingFinished.connect(self.SpinBoxB_Action) + SliderB_HLyt.addWidget(self.BevelB_SpinBox) + + + + + + + + BEVELS2_MLyt.addStretch() + + + def Action(self): + pass + + + def SliderA_Action(self): + BevelAValue = self.BevelA_Slider.value()/100 + self.BevelA_SpinBox.setValue(BevelAValue) + mc.setAttr(str(BevelA) + ".fraction", BevelAValue) + + + + + def SpinBoxA_Action(self): + SpinBoxAValue = self.BevelA_SpinBox.value()*100 + self.BevelA_Slider.setValue(SpinBoxAValue) + self.BevelA_SpinBox.clearFocus() + + + + + + + def SliderB_Action(self): + + BevelBValue = self.BevelB_Slider.value()/100 + self.BevelB_SpinBox.setValue(BevelBValue) + mc.setAttr(str(BevelB) + ".fraction", BevelBValue) + + + def SpinBoxB_Action(self): + SpinBoxBValue = self.BevelB_SpinBox.value()*100 + self.BevelB_Slider.setValue(SpinBoxBValue) + self.BevelB_SpinBox.clearFocus() + + +def Dock(Widget, width=200, height=200, hp="free", show=True): + label = getattr(Widget, "label", WindowsTitle) + + try: + mc.deleteUI(WindowsTitle) + except RuntimeError: + pass + + dockControl = mc.workspaceControl( + WindowsTitle, + initialWidth=width, + minimumWidth=False, + widthProperty=hp, + heightProperty=hp, + label=label + ) + + dockPtr = omui.MQtUtil.findControl(dockControl) + dockWidget = QtCompat.wrapInstance(int(dockPtr), QtWidgets.QWidget) + dockWidget.setAttribute(QtCore.Qt.WA_DeleteOnClose) + child = Widget(dockWidget) + dockWidget.layout().addWidget(child) + + if show: + mc.evalDeferred( + lambda *args: mc.workspaceControl( + dockControl, + edit=True, + widthProperty="free", + restore=True + ) + ) + return child + + + +def showUI(): + ui = Dock(Bevel2_UI) + ui.show() + + + # Get a pointer and convert it to Qt Widget object + qw = omui.MQtUtil.findWindow(WindowsTitle) + widget = wrapInstance(int(qw), QWidget) + # Create a QIcon object + icon = QIcon(IconPath + "ModIt_Window_Ico.png") + # Assign the icon + widget.setWindowIcon(icon) + + return ui + + + + diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/Section_COLORS.py b/Scripts/Modeling/Edit/ModIt/Modeling/Section_COLORS.py new file mode 100644 index 0000000..9d2608d --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/Section_COLORS.py @@ -0,0 +1,398 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS + + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 26 +iconButtonSize = 26 +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA +PRIM_MODE =(json.load(open(PreferencePath + 'Setting_Primitives_Placement.json',"r"))['PRIM_MODE']) +PRIM_SIZE =(json.load(open(PreferencePath + 'Setting_Primitives_Size.json',"r"))['PRIM_SIZE']) + + +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + + + + +class COLORS_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + SECTION_COLORS_LAYOUT = QtWidgets.QHBoxLayout()# MAIN + SECTION_COLORS_LAYOUT.setContentsMargins(10,5,5,10) + self.setLayout(SECTION_COLORS_LAYOUT) + + ##-------------------------------------------------------------------------------- COLOR : GREY + #QT PAINTER + if mc.objExists("ModItColor_" + "Grey"): + colorRGB_0to1 = mc.getAttr("ModItColor_Grey.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(150, 150, 150) + self.imgGrey = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgGrey) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgGrey.rect()) + + + self.ColorGreyBtn = MyCustomBtn_Widget() + self.ColorGreyBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorGreyBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorGreyBtn.setIcon(QtGui.QIcon(self.imgGrey)) + self.ColorGreyBtn.clicked.connect(partial(self.ApplyColor, "Grey", 0.5, 0.5, 0.5)) + + # C O N T E X T M E N U + self.ColorGreyBtn.customContextMenuRequested.connect(self.showPopup_Grey) + self.popupMenuGrey = QtWidgets.QMenu() + ColorGreyMenu_Entry_Select = self.popupMenuGrey.addAction("Select") + ColorGreyMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "Grey")) + ColorGreyMenu_Entry_Attributes = self.popupMenuGrey.addAction("Attributes") + ColorGreyMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "Grey")) + + ##-------------------------------------------------------------------------------- COLOR#2 : YELLOW + #QT PAINTER + if mc.objExists("ModItColor_" + "Yellow"): + colorRGB_0to1 = mc.getAttr("ModItColor_Yellow.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(229, 153, 0) + self.imgYellow = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgYellow) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgYellow.rect()) + + # BUTTON ICON COLOR + self.ColorYellowBtn = MyCustomBtn_Widget() + self.ColorYellowBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorYellowBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorYellowBtn.setIcon(QtGui.QIcon(self.imgYellow)) + self.ColorYellowBtn.clicked.connect(partial(self.ApplyColor, "Yellow", 0.9, 0.6, 0.0)) + + + # C O N T E X T M E N U + self.ColorYellowBtn.customContextMenuRequested.connect(self.showPopup_Yellow) + self.popupMenuYellow = QtWidgets.QMenu() + ColorYellowMenu_Entry_Select = self.popupMenuYellow.addAction("Select") + ColorYellowMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "Yellow")) + ColorYellowMenu_Entry_Attributes = self.popupMenuYellow.addAction("Attributes") + ColorYellowMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "Yellow")) + + ##-------------------------------------------------------------------------------- COLOR : ORANGE + #QT PAINTER + if mc.objExists("ModItColor_" + "ORange"): + colorRGB_0to1 = mc.getAttr("ModItColor_ORange.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(229, 89, 0) + self.imgORange = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgORange) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgORange.rect()) + + + self.ColorORangeBtn = MyCustomBtn_Widget() + self.ColorORangeBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorORangeBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorORangeBtn.setIcon(QtGui.QIcon(self.imgORange)) + self.ColorORangeBtn.clicked.connect(partial(self.ApplyColor, "ORange", 0.9, 0.35, 0.0)) + # C O N T E X T M E N U + self.ColorORangeBtn.customContextMenuRequested.connect(self.showPopup_ORange) + self.popupMenuORange = QtWidgets.QMenu() + ColorORangeMenu_Entry_Select = self.popupMenuORange.addAction("Select") + ColorORangeMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "ORange")) + ColorORangeMenu_Entry_Attributes = self.popupMenuORange.addAction("Attributes") + ColorORangeMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "ORange")) + + ##-------------------------------------------------------------------------------- COLOR : RED + #QT PAINTER + if mc.objExists("ModItColor_" + "Red"): + colorRGB_0to1 = mc.getAttr("ModItColor_Red.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(178, 3, 3) + self.imgRed = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgRed) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgRed.rect()) + + self.ColorRedBtn = MyCustomBtn_Widget() + self.ColorRedBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorRedBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorRedBtn.setIcon(QtGui.QIcon(self.imgRed)) + self.ColorRedBtn.clicked.connect(partial(self.ApplyColor, "Red", 0.7, 0.011, 0.011)) + # C O N T E X T M E N U + self.ColorRedBtn.customContextMenuRequested.connect(self.showPopup_Red) + self.popupMenuRed = QtWidgets.QMenu() + ColorRedMenu_Entry_Select = self.popupMenuRed.addAction("Select") + ColorRedMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "Red")) + ColorRedMenu_Entry_Attributes = self.popupMenuRed.addAction("Attributes") + ColorRedMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "Red")) + + ##-------------------------------------------------------------------------------- COLOR : GREEN + #QT PAINTER + if mc.objExists("ModItColor_" + "Green"): + colorRGB_0to1 = mc.getAttr("ModItColor_Green.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(0, 203, 74) + self.imgGreen = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgGreen) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgGreen.rect()) + + self.ColorGreenBtn = MyCustomBtn_Widget() + self.ColorGreenBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorGreenBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorGreenBtn.setIcon(QtGui.QIcon(self.imgGreen)) + self.ColorGreenBtn.clicked.connect(partial(self.ApplyColor, "Green", 0.0, 0.798, 0.292)) + # C O N T E X T M E N U + self.ColorGreenBtn.customContextMenuRequested.connect(self.showPopup_Green) + self.popupMenuGreen = QtWidgets.QMenu() + ColorGreenMenu_Entry_Select = self.popupMenuGreen.addAction("Select") + ColorGreenMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "Green")) + ColorGreenMenu_Entry_Attributes = self.popupMenuGreen.addAction("Attributes") + ColorGreenMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "Green")) + + ##-------------------------------------------------------------------------------- COLOR : CYAN + #QT PAINTER + if mc.objExists("ModItColor_" + "Cyan"): + colorRGB_0to1 = mc.getAttr("ModItColor_Cyan.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(0, 170, 227) + self.imgCyan = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgCyan) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgCyan.rect()) + + self.ColorCyanBtn = MyCustomBtn_Widget() + self.ColorCyanBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorCyanBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorCyanBtn.setIcon(QtGui.QIcon(self.imgCyan)) + self.ColorCyanBtn.clicked.connect(partial(self.ApplyColor, "Cyan", 0.0, 0.6684, 0.894)) + # C O N T E X T M E N U + self.ColorCyanBtn.customContextMenuRequested.connect(self.showPopup_Cyan) + self.popupMenuCyan = QtWidgets.QMenu() + ColorCyanMenu_Entry_Select = self.popupMenuCyan.addAction("Select") + ColorCyanMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "Cyan")) + ColorCyanMenu_Entry_Attributes = self.popupMenuCyan.addAction("Attributes") + ColorCyanMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "Cyan")) + + ##-------------------------------------------------------------------------------- COLOR : BLUE + #QT PAINTER + if mc.objExists("ModItColor_" + "Blue"): + colorRGB_0to1 = mc.getAttr("ModItColor_Blue.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(0, 110, 178) + self.imgBlue = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgBlue) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgBlue.rect()) + + + self.ColorBlueBtn = MyCustomBtn_Widget() + self.ColorBlueBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorBlueBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorBlueBtn.setIcon(QtGui.QIcon(self.imgBlue)) + self.ColorBlueBtn.clicked.connect(partial(self.ApplyColor, "Blue", 0, 0.432, 0.7)) + # C O N T E X T M E N U + self.ColorBlueBtn.customContextMenuRequested.connect(self.showPopup_Blue) + self.popupMenuBlue = QtWidgets.QMenu() + ColorBlueMenu_Entry_Select = self.popupMenuBlue.addAction("Select") + ColorBlueMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "Blue")) + ColorBlueMenu_Entry_Attributes = self.popupMenuBlue.addAction("Attributes") + ColorBlueMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "Blue")) + + ##-------------------------------------------------------------------------------- COLOR : BLACK + #QT PAINTER + if mc.objExists("ModItColor_" + "Black"): + colorRGB_0to1 = mc.getAttr("ModItColor_Black.baseColor")[0] + color = QtGui.QColor(colorRGB_0to1[0]*255, colorRGB_0to1[1]*255, colorRGB_0to1[2]*255) + else: + color = QtGui.QColor(15, 15, 15) + self.imgBlack = QtGui.QPixmap(IconPath + "Color_Default_Icon.png") + painter = QtGui.QPainter(self.imgBlack) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(self.imgBlack.rect()) + + + self.ColorBlackBtn = MyCustomBtn_Widget() + self.ColorBlackBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorBlackBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorBlackBtn.setIcon(QtGui.QIcon(self.imgBlack)) + self.ColorBlackBtn.clicked.connect(partial(self.ApplyColor, "Black", 0.05, 0.05, 0.05)) + # C O N T E X T M E N U + self.ColorBlackBtn.customContextMenuRequested.connect(self.showPopup_Black) + self.popupMenuBlack = QtWidgets.QMenu() + ColorBlackMenu_Entry_Select = self.popupMenuBlack.addAction("Select") + ColorBlackMenu_Entry_Select.triggered.connect(partial(self.SelectColor, "Black")) + ColorBlackMenu_Entry_Attributes = self.popupMenuBlack.addAction("Attributes") + ColorBlackMenu_Entry_Attributes.triggered.connect(partial(self.AttributColor, "Black")) + + + + ##---------------------------------------------------- Add to Layout + SECTION_COLORS_LAYOUT.addWidget(self.ColorGreyBtn) + SECTION_COLORS_LAYOUT.addWidget(self.ColorYellowBtn) + SECTION_COLORS_LAYOUT.addWidget(self.ColorORangeBtn) + SECTION_COLORS_LAYOUT.addWidget(self.ColorRedBtn) + SECTION_COLORS_LAYOUT.addWidget(self.ColorGreenBtn) + SECTION_COLORS_LAYOUT.addWidget(self.ColorCyanBtn) + SECTION_COLORS_LAYOUT.addWidget(self.ColorBlueBtn) + SECTION_COLORS_LAYOUT.addWidget(self.ColorBlackBtn) + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + + def ApplyColor(self, color, num1, num2, num3): + mc.undoInfo(openChunk=True, infinity=True) + selection = mc.ls(sl=True) + if mc.objExists("ModItColor_" + color): + mc.hyperShade(assign="ModItColor_" + color) + else: + ModItColor_StandarSurface = mc.shadingNode("standardSurface", asShader=True) + mc.setAttr(ModItColor_StandarSurface + ".baseColor", num1, num2, num3, type='double3') + mc.setAttr(ModItColor_StandarSurface + ".specularRoughness", 0.5) + mc.setAttr(ModItColor_StandarSurface + ".specularRoughness", 0.5) + mc.setAttr(ModItColor_StandarSurface + ".specular", 0.5) + mc.rename("ModItColor_" + color) + mc.select(selection) + mc.hyperShade(assign="ModItColor_" + color) + mc.undoInfo(closeChunk=True) + + def SelectColor(self, color): + mc.undoInfo(openChunk=True, infinity=True) + if mc.objExists("ModItColor_" + color): + mc.hyperShade(objects="ModItColor_" + color) + else: + print("Please First Create this FaceColor Shader") + mc.undoInfo(closeChunk=True) + + + + + def AttributColor(self, color): + if mc.objExists('ModItColor_' + color): + mc.select('ModItColor_' + color) + else: + print("Please First Create this FaceColor Shader") + + + + def lambert1(self): + mc.hyperShade(assign="lambert1") + + def SelectLambert(self): + if mc.objExists('lambert1'): + mc.hyperShade(objects="lambert1") + else: + print("Please First Create this FaceColor Shader") + + def TransLambert(self): + if mc.objExists('lambert1'): + mc.window(title='Lambert Transparancy') + mc.columnLayout() + mc.attrColorSliderGrp(at='lambert1.transparency') + mc.showWindow() + else: + print("Please First Create this FaceColor Shader") + + def AttributLambert(self): + if mc.objExists('lambert1'): + mc.select('lambert1') + else: + print("Please First Create this FaceColor Shader") + + + + def showPopup_Grey(self, position): + self.popupMenuGrey.exec_(self.ColorGreyBtn.mapToGlobal(position)) + self.ColorBlackBtn.update() + + def showPopup_Yellow(self, position): + self.popupMenuYellow.exec_(self.ColorYellowBtn.mapToGlobal(position)) + self.ColorYellowBtn.update() + + def showPopup_ORange(self, position): + self.popupMenuORange.exec_(self.ColorORangeBtn.mapToGlobal(position)) + self.ColorORangeBtn.update() + + def showPopup_Red(self, position): + self.popupMenuRed.exec_(self.ColorRedBtn.mapToGlobal(position)) + self.ColorRedBtn.update() + + def showPopup_Green(self, position): + self.popupMenuGreen.exec_(self.ColorGreenBtn.mapToGlobal(position)) + self.ColorGreenBtn.update() + + def showPopup_Cyan(self, position): + self.popupMenuCyan.exec_(self.ColorCyanBtn.mapToGlobal(position)) + self.ColorCyanBtn.update() + + def showPopup_Black(self, position): + self.popupMenuBlack.exec_(self.ColorBlackBtn.mapToGlobal(position)) + self.ColorBlackBtn.update() + + def showPopup_Blue(self, position): + self.popupMenuBlue.exec_(self.ColorBlueBtn.mapToGlobal(position)) + self.ColorBlueBtn.update() + diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/Section_MESH.py b/Scripts/Modeling/Edit/ModIt/Modeling/Section_MESH.py new file mode 100644 index 0000000..2f62ef8 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/Section_MESH.py @@ -0,0 +1,1126 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + +from . import ModIt_2Bevels_UI +importlib.reload(ModIt_2Bevels_UI) + + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 32 +iconButtonSize = 32 +separatorWidth = ModIt_Global.separatorWidth + + +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + + +class MESH_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + SECTION_MESH_LAYOUT = QtWidgets.QVBoxLayout() # MAIN + SECTION_MESH_LAYOUT.setContentsMargins(10, 0, 5, 0) + SECTION_MESH_LAYOUT.setSpacing(0) + self.setLayout(SECTION_MESH_LAYOUT) + + + MESH_HLyt_1 = QtWidgets.QHBoxLayout() + MESH_HLyt_1.setContentsMargins(0,0,0,0) + MESH_HLyt_1.setSpacing(0) + SECTION_MESH_LAYOUT.addLayout(MESH_HLyt_1) + + ##------------------------------------------------------------------------------- SOFT/HARD EDGE + ##---------------------------------------------------- SET SOFT EDGE + self.SoftEdge_btn = QtWidgets.QPushButton() + self.SoftEdge_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.SoftEdge_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SoftEdge_btn.setIcon(QtGui.QIcon(IconPath + "polySoftEdge.png")) + self.SoftEdge_btn.setToolTip(" Soften Edge ") + self.SoftEdge_btn.clicked.connect(self.SetSoftEdge) + MESH_HLyt_1.addWidget(self.SoftEdge_btn) + + ##---------------------------------------------------- SET HARD EDGE + self.HardEdge_btn = QtWidgets.QPushButton() + self.HardEdge_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.HardEdge_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.HardEdge_btn.setIcon(QtGui.QIcon(IconPath + "polyHard.png")) + self.HardEdge_btn.setToolTip(" Harden Edge ") + self.HardEdge_btn.clicked.connect(self.SetHardEdge) + MESH_HLyt_1.addWidget(self.HardEdge_btn) + + MESH_HLyt_1.addSpacing(5) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,30) + self.Separator.setStyleSheet("background-color:#fba636;") + MESH_HLyt_1.addWidget(self.Separator) + MESH_HLyt_1.addSpacing(5) + + + ##---------------------------------------------------- GET HARD EDGE + self.SelectHardEdge_btn = MyCustomBtn_Widget() + self.SelectHardEdge_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.SelectHardEdge_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SelectHardEdge_btn.setIcon(QtGui.QIcon(IconPath + "HardEdge.png")) + self.SelectHardEdge_btn.setToolTip(" Get Hard Edges from Selection ") + self.SelectHardEdge_btn.clicked.connect(self.GetHardEdges) + MESH_HLyt_1.addWidget(self.SelectHardEdge_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.SelectHardEdge_btn.customContextMenuRequested.connect(self.showPopupEdgeAngle) + # CUBE M E N U I T E M S + self.popupMenuEdgeAngle = QtWidgets.QMenu() + Angle_Entry_1 = self.popupMenuEdgeAngle.addAction("Smooth 30°") + Angle_Entry_1.triggered.connect(partial(self.SetSoftHardAngle, 30)) + Angle_Entry_2 = self.popupMenuEdgeAngle.addAction("Smooth 35°") + Angle_Entry_2.triggered.connect(partial(self.SetSoftHardAngle, 35)) + Angle_Entry_3 = self.popupMenuEdgeAngle.addAction("Smooth 40°") + Angle_Entry_3.triggered.connect(partial(self.SetSoftHardAngle, 40)) + Angle_Entry_4 = self.popupMenuEdgeAngle.addAction("Smooth 45°") + Angle_Entry_4.triggered.connect(partial(self.SetSoftHardAngle, 45)) + + MESH_HLyt_1.addSpacing(12) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,30) + self.Separator.setStyleSheet("background-color:#434343;") + MESH_HLyt_1.addWidget(self.Separator) + MESH_HLyt_1.addSpacing(12) + + + ##------------------------------------------------------------------------------- SYMETRY + ##---------------------------------------------------- SYM MERGE + self.SymMerge_btn = MyCustomBtn_Widget() + self.SymMerge_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.SymMerge_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SymMerge_btn.setIcon(QtGui.QIcon(IconPath + "SymMerge.png")) + self.SymMerge_btn.setToolTip(" Symmetry based on Pivot and Merge ") + self.SymMerge_btn.clicked.connect(partial(self.Symmetry, 4)) + MESH_HLyt_1.addWidget(self.SymMerge_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.SymMerge_btn.customContextMenuRequested.connect(self.showPopupSymMerge) + # CUBE M E N U I T E M S + self.popupMenuSymMerge = QtWidgets.QMenu() + SymMerge_Entry_1 = self.popupMenuSymMerge.addAction("X") + SymMerge_Entry_1.triggered.connect(partial(self.Symmetry, 0)) + SymMerge_Entry_2 = self.popupMenuSymMerge.addAction("Y") + SymMerge_Entry_2.triggered.connect(partial(self.Symmetry, 1)) + SymMerge_Entry_3 = self.popupMenuSymMerge.addAction("Z") + SymMerge_Entry_3.triggered.connect(partial(self.Symmetry, 2)) + + MESH_HLyt_1.addSpacing(5) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,30) + self.Separator.setStyleSheet("background-color:#ff5f70;") + MESH_HLyt_1.addWidget(self.Separator) + MESH_HLyt_1.addSpacing(5) + + + ##---------------------------------------------------- SYM FLIP + self.SymFlip_btn = MyCustomBtn_Widget() + self.SymFlip_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.SymFlip_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SymFlip_btn.setIcon(QtGui.QIcon(IconPath + "SymFlip.png")) + self.SymFlip_btn.setToolTip(" Flip on World Axis ") + self.SymFlip_btn.clicked.connect(partial(self.FlipWorld, 4)) + MESH_HLyt_1.addWidget(self.SymFlip_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.SymFlip_btn.customContextMenuRequested.connect(self.showPopupSymFlip) + # CUBE M E N U I T E M S + self.popupMenuSymFlip = QtWidgets.QMenu() + SymFlip_Entry_1 = self.popupMenuSymFlip.addAction("X") + SymFlip_Entry_1.triggered.connect(partial(self.FlipWorld, 0)) + SymFlip_Entry_2 = self.popupMenuSymFlip.addAction("Y") + SymFlip_Entry_2.triggered.connect(partial(self.FlipWorld, 1)) + SymFlip_Entry_3 = self.popupMenuSymFlip.addAction("Z") + SymFlip_Entry_3.triggered.connect(partial(self.FlipWorld, 2)) + + ##---------------------------------------------------- SYM PIVOT + self.SymPivot_btn = MyCustomBtn_Widget() + self.SymPivot_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.SymPivot_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SymPivot_btn.setIcon(QtGui.QIcon(IconPath + "SymPivot.png")) + self.SymPivot_btn.setToolTip(" Flip based on Pivot ") + self.SymPivot_btn.clicked.connect(partial(self.FlipPivot, 4)) + MESH_HLyt_1.addWidget(self.SymPivot_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.SymPivot_btn.customContextMenuRequested.connect(self.showPopupSymPivot) + # CUBE M E N U I T E M S + self.popupMenuSymPivot = QtWidgets.QMenu() + SymPivot_Entry_1 = self.popupMenuSymPivot.addAction("X") + SymPivot_Entry_1.triggered.connect(partial(self.FlipPivot, 0)) + SymPivot_Entry_2 = self.popupMenuSymPivot.addAction("Y") + SymPivot_Entry_2.triggered.connect(partial(self.FlipPivot, 1)) + SymPivot_Entry_3 = self.popupMenuSymPivot.addAction("Z") + SymPivot_Entry_3.triggered.connect(partial(self.FlipPivot, 2)) + + MESH_HLyt_1.addSpacing(5) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,30) + self.Separator.setStyleSheet("background-color:#ff5f70;") + MESH_HLyt_1.addWidget(self.Separator) + MESH_HLyt_1.addSpacing(5) + + + ##---------------------------------------------------- BAKE SYM + self.BakeSym_btn = MyCustomBtn_Widget() + self.BakeSym_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.BakeSym_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.BakeSym_btn.setIcon(QtGui.QIcon(IconPath + "SymBakeInstance.png")) + self.BakeSym_btn.setToolTip(" Bake Instances ") + self.BakeSym_btn.clicked.connect(self.BakeInstance) + MESH_HLyt_1.addWidget(self.BakeSym_btn) + + + + ## ______________________________________________________________________________________/ Separator + SECTION_MESH_LAYOUT.addSpacing(4) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(2000,1) + self.Separator.setStyleSheet("background-color:#434343;") + SECTION_MESH_LAYOUT.addWidget(self.Separator) + SECTION_MESH_LAYOUT.addSpacing(4) + + ##------------------------------------------------------------------------------- OPERATIONS + MESH_HLyt_2 = QtWidgets.QHBoxLayout() + MESH_HLyt_2.setContentsMargins(10,0,0,0) + MESH_HLyt_2.setSpacing(5) + SECTION_MESH_LAYOUT.addLayout(MESH_HLyt_2) + + Operation_VLyt = QtWidgets.QVBoxLayout() + MESH_HLyt_2.addLayout(Operation_VLyt) + Op_Line_1_Hlyt = QtWidgets.QHBoxLayout() + Operation_VLyt.addLayout(Op_Line_1_Hlyt) + Op_Line_2_Hlyt = QtWidgets.QHBoxLayout() + Operation_VLyt.addLayout(Op_Line_2_Hlyt) + + + ##---------------------------------------------------- COMBINE + self.Combine_btn = MyCustomBtn_Widget() + self.Combine_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.Combine_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.Combine_btn.setIcon(QtGui.QIcon(IconPath + "Combine.png")) + self.Combine_btn.setToolTip(" Combine ") + self.Combine_btn.clicked.connect(self.Combine) + Op_Line_1_Hlyt.addWidget(self.Combine_btn) + + ##---------------------------------------------------- SEPARATE + self.Separate_btn = MyCustomBtn_Widget() + self.Separate_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.Separate_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.Separate_btn.setIcon(QtGui.QIcon(IconPath + "Separate.png")) + self.Separate_btn.setToolTip(" Separate ") + self.Separate_btn.clicked.connect(self.Separate) + Op_Line_1_Hlyt.addWidget(self.Separate_btn) + ##---------------------------------------------------- DUPLICATE FACE + self.DupFace_btn = MyCustomBtn_Widget() + self.DupFace_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.DupFace_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.DupFace_btn.setIcon(QtGui.QIcon(IconPath + "FaceDupli.png")) + self.DupFace_btn.setToolTip(" Duplicate Faces ") + self.DupFace_btn.clicked.connect(self.DuplicatFace) + Op_Line_2_Hlyt.addWidget(self.DupFace_btn) + + ##---------------------------------------------------- EXTRACT FACE + self.ExtractFace_btn = MyCustomBtn_Widget() + self.ExtractFace_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.ExtractFace_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ExtractFace_btn.setIcon(QtGui.QIcon(IconPath + "FaceExtract.png")) + self.ExtractFace_btn.setToolTip(" Extract Faces ") + self.ExtractFace_btn.clicked.connect(self.ExtractFace) + Op_Line_2_Hlyt.addWidget(self.ExtractFace_btn) + + + + + MESH_HLyt_2.addSpacing(12) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,60) + self.Separator.setStyleSheet("background-color:#434343;") + MESH_HLyt_2.addWidget(self.Separator) + MESH_HLyt_2.addSpacing(12) + + Bevels_VLyt = QtWidgets.QVBoxLayout() + MESH_HLyt_2.addLayout(Bevels_VLyt) + + + + ##---------------------------------------------------- MIXED BEVEL + self.BevelTwo_btn = QtWidgets.QPushButton() + self.BevelTwo_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.BevelTwo_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.BevelTwo_btn.setIcon(QtGui.QIcon(IconPath + "2Bevel.png")) + self.BevelTwo_btn.setToolTip(" Mixed Bevels / Shift+Click : Mixed Bevels on 2 borders ") + self.BevelTwo_btn.clicked.connect(self.BevelVariable) + Bevels_VLyt.addWidget(self.BevelTwo_btn) + + + ##---------------------------------------------------- BEVEL VERTEX + self.BevelVertex_btn = MyCustomBtn_Widget() + self.BevelVertex_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.BevelVertex_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.BevelVertex_btn.setIcon(QtGui.QIcon(IconPath + "fillet.png")) + self.BevelVertex_btn.setToolTip(" Bevel Vertex on open area (use Marking Menu to change segment/offset ") + self.BevelVertex_btn.clicked.connect(self.BevelVertex) + Bevels_VLyt.addWidget(self.BevelVertex_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.BevelVertex_btn.customContextMenuRequested.connect(self.showPopupBevelHotkey) + # CUBE M E N U I T E M S + self.popupMenuBevelHotkey = QtWidgets.QMenu() + BevelHotkey_Entry = self.popupMenuBevelHotkey.addAction("Bevel Vertice Add Hotkey") + BevelHotkey_Entry.triggered.connect(self.BevelVertex_Hotkey) + + + + + + + + MESH_HLyt_2.addSpacing(12) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,60) + self.Separator.setStyleSheet("background-color:#434343;") + MESH_HLyt_2.addWidget(self.Separator) + MESH_HLyt_2.addSpacing(12) + + Flow_VLyt = QtWidgets.QVBoxLayout() + MESH_HLyt_2.addLayout(Flow_VLyt) + + + + ##---------------------------------------------------- EDGE FLOW + self.EdgeFlow_btn = QtWidgets.QPushButton() + self.EdgeFlow_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.EdgeFlow_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.EdgeFlow_btn.setIcon(QtGui.QIcon(IconPath + "fixFlow.png")) + self.EdgeFlow_btn.setToolTip(" Fix Edge Flow ") + self.EdgeFlow_btn.clicked.connect(self.EdgeFlow) + Flow_VLyt.addWidget(self.EdgeFlow_btn) + + + MESH_HLyt_2.addSpacing(20) + + + ##---------------------------------------------------- Add to Layout + + + + + + + + + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + # ------------------------------------------------ MENUS + def showPopupEdgeAngle(self, position): + self.popupMenuEdgeAngle.exec_(self.SelectHardEdge_btn.mapToGlobal(position)) + self.SelectHardEdge_btn.update() + + def showPopupSymMerge(self, position): + self.popupMenuSymMerge.exec_(self.SymMerge_btn.mapToGlobal(position)) + self.SymMerge_btn.update() + + def showPopupSymFlip(self, position): + self.popupMenuSymFlip.exec_(self.SymFlip_btn.mapToGlobal(position)) + self.SymFlip_btn.update() + + def showPopupSymPivot(self, position): + self.popupMenuSymPivot.exec_(self.SymPivot_btn.mapToGlobal(position)) + self.SymPivot_btn.update() + + def showPopupBevelHotkey(self, position): + self.popupMenuBevelHotkey.exec_(self.BevelVertex_btn.mapToGlobal(position)) + self.BevelVertex_btn.update() + + + + #------------------------------------------------ ACTIONS + def BAM(self): + print("BAMMM") + + + def SetHardEdge(self): + mc.PolygonHardenEdge() + + + def SetSoftEdge(self): + mc.PolygonSoftenEdge() + + + + def SetSoftHardAngle(self, angle): + myVar = str(angle) + mel.eval('polyPerformAction "polySoftEdge -a ' + myVar + '" e 0;') + + + + def GetHardEdges(self): + obSelName = str(mc.ls(sl=True)[0]) + objSel = mc.ls(sl=True) + mc.ConvertSelectionToEdgePerimeter() + + # verif if perim or nor + verifPerim = mc.ls(sl=True) + + if verifPerim == []: + mc.select(objSel) + mc.polySelectConstraint(m=3, t=0x8000, sm=1) + mc.polySelectConstraint(m=0) + mel.eval('doMenuComponentSelectionExt(" ' + obSelName + '", "edge", 0);') + else: + # Store EdgePerim Set + mc.sets(n="ModIt_EdgePerim_tempSet") + + mc.polySelectConstraint(m=3, t=0x8000, sm=1) + mc.polySelectConstraint(m=0) + + # Store All HardEdge + mc.sets(n="ModIt_AllHardEdge_tempSet") + + # Sub Perim Edge + mc.select("ModIt_EdgePerim_tempSet") + mc.sets(rm='ModIt_AllHardEdge_tempSet') + + mc.select("ModIt_AllHardEdge_tempSet") + + mc.delete("ModIt_AllHardEdge_tempSet") + mc.delete("ModIt_EdgePerim_tempSet") + + mel.eval('doMenuComponentSelectionExt(" ' + obSelName + '", "edge", 0);') + + + + def BakeInstance(self): + mc.ConvertInstanceToObject() + + + + + def Symmetry(self, axis): + # Store Sel + selection = mc.ls(sl=True, fl=True, dag=True) + selVerif = mc.ls(sl=True) + + #VERIR SEULEMENT 1 MESH + try: + mc.objectType(selection[1]) + except: + ModIt_Global.WarningWindow(" Symmetry is only working on Geometry Mesh.", 350) + return + + if mc.objectType(selection[1]) != "mesh": + ModIt_Global.WarningWindow(" Symmetry is only working on Geometry Mesh.", 350) + return + + if len(selVerif) > 1: + ModIt_Global.WarningWindow(" You should select ONE mesh only.", 350) + return + + selection = selection[0] + + + + mc.undoInfo(openChunk=True, infinity=True) + + #AXIS Info + if axis == 4: + AXIS = (json.load(open(PreferencePath + 'Pref_SymAxis.json', "r"))['VALUE']) + else: + AXIS = axis + + ##_____________________________________ Pour avoir l'info de quel sens faire la sym + # Clean + if mc.objExists("ModItSymInfo"): + mc.delete("ModItSymInfo") + if mc.objExists("ModIt_Sym_Loc"): + mc.delete("ModIt_Sym_Loc") + + # Dup and Center Piv + mc.duplicate(n="ModItSymInfo") + mc.CenterPivot() + mc.FreezeTransformations() + + # PlaceLocator / Freeze + mc.spaceLocator(p=[0, 0, 0], n="ModIt_Sym_Loc") + mc.select("ModIt_Sym_Loc", "ModItSymInfo") + mc.MatchTransform() + mc.select("ModIt_Sym_Loc") + mc.FreezeTransformations() + + # Mathc Locator / + mc.select("ModIt_Sym_Loc", selection) + mc.MatchTransform() + + # Analyz = VALUE + - + if AXIS == 0: + axisLetter = "X" + elif AXIS == 1: + axisLetter = "Y" + elif AXIS == 2: + axisLetter = "Z" + + locAxeValue = mc.getAttr("ModIt_Sym_Loc.translate" + axisLetter) + if locAxeValue > 0: + axisDir = -1 + print("axisDir = " + str(axisDir)) + if locAxeValue < 0: + axisDir = 1 + print("axisDir = " + str(axisDir)) + if locAxeValue == 0: + axisDir = 1 + print("axisDir = " + str(axisDir)) + + # Clean + if mc.objExists("ModItSymInfo"): + mc.delete("ModItSymInfo") + if mc.objExists("ModIt_Sym_Loc"): + mc.delete("ModIt_Sym_Loc") + + + + ##_____________________________________ + mc.select(selection) + mc.polyMirrorFace(cutMesh=1, mirrorAxis= 1, axis= AXIS, axisDirection= axisDir, mergeMode=1, mergeThresholdType=1, mergeThreshold =1, mirrorPosition=0, smoothingAngle=30, flipUVs=0, ch=1) + + + + mc.delete(ch=True) + mc.SelectVertexMask() + mc.SelectToggleMode() + + + mc.undoInfo(closeChunk=True) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + def FlipWorld(self, axis): + INSTANCE_MODE = (json.load(open(PreferencePath + 'InstanceMode.json', "r"))['VALUE']) + + if INSTANCE_MODE == 0: + mc.undoInfo(openChunk=True, infinity=True) + selection = mc.ls(sl = True, fl = True, dag = True, hd = 1) + + #CLEAN + if mc.objExists("DupliF"): + mc.delete("DupliF") + + DupSel = mc.duplicate(rc= True) + mel.eval('doGroup 0 1 1;') + NewGroup = mc.ls(sl=True) + mc.rename(NewGroup, "DupliF") # Group Named + + + if axis == 0: + mc.setAttr("DupliF.scaleX", -1) + elif axis == 1: + mc.setAttr("DupliF.scaleY", -1) + elif axis == 2: + mc.setAttr("DupliF.scaleZ", -1) + elif axis == 4: + AXIS = (json.load(open(PreferencePath + 'Pref_SymAxis.json', "r"))['VALUE']) + if AXIS == 0: + mc.setAttr("DupliF.scaleX", -1) + elif AXIS == 1: + mc.setAttr("DupliF.scaleY", -1) + elif AXIS == 2: + mc.setAttr("DupliF.scaleZ", -1) + + + mc.select("DupliF") + mc.FreezeTransformations() + mc.delete(ch=True) + mc.Ungroup() + mc.undoInfo(closeChunk=True) + + else: + mc.undoInfo(openChunk=True, infinity=True) + selection = mc.ls(sl=True, fl=True, dag=True, hd=1) + + # CLEAN + if mc.objExists("ModIt_DupliWorld_Instance"): + mc.delete("ModIt_DupliWorld_Instance") + + mel.eval('doGroup 0 1 1;') + # Group Named + NewGroup = mc.ls(sl=True) + mc.rename(NewGroup, "ModIt_DupliWorld_Instance") + + if axis == 0: + mel.eval("instance; scale -r -1 1 1") + elif axis == 1: + mel.eval("instance; scale -r 1 -1 1") + elif axis == 2: + mel.eval("instance; scale -r 1 1 -1") + elif axis == 4: + AXIS = (json.load(open(PreferencePath + 'Pref_SymAxis.json', "r"))['VALUE']) + if AXIS == 0: + mel.eval("instance; scale -r -1 1 1") + elif AXIS == 1: + mel.eval("instance; scale -r 1 -1 1") + elif AXIS == 2: + mel.eval("instance; scale -r 1 1 -1") + + instanceRootGroup = mc.ls(sl=True) + mc.select("ModIt_DupliWorld_Instance") + mc.CenterPivot() + mc.rename("ModIt_DupliWorld_Instance", "ModIt_InstanceOrigin_grp") + mc.select(instanceRootGroup) + mc.CenterPivot() + mc.rename(instanceRootGroup, "ModIt_InstanceWorld_grp") + mc.select(d=True) + + + + + def FlipPivot(self, axis): + INSTANCE_MODE = (json.load(open(PreferencePath + 'InstanceMode.json', "r"))['VALUE']) + + if INSTANCE_MODE == 0: + mc.undoInfo(openChunk=True, infinity=True) + mc.FreezeTransformations() + mc.duplicate(rc= True) + mc.rename("DupliF") + if axis == 0: + mc.setAttr("DupliF.scaleX", -1) + elif axis == 1: + mc.setAttr("DupliF.scaleY", -1) + elif axis == 2: + mc.setAttr("DupliF.scaleZ", -1) + elif axis == 4: + AXIS = (json.load(open(PreferencePath + 'Pref_SymAxis.json', "r"))['VALUE']) + if AXIS == 0: + mc.setAttr("DupliF.scaleX", -1) + elif AXIS == 1: + mc.setAttr("DupliF.scaleY", -1) + elif AXIS == 2: + mc.setAttr("DupliF.scaleZ", -1) + + mc.rename("DupliF", "DupliFlip") + mc.FreezeTransformations() + mc.delete(ch=True) + mc.undoInfo(closeChunk=True) + + else: + mc.undoInfo(openChunk=True, infinity=True) + selection = mc.ls(sl=True, fl=True, dag=True, hd=1) + # CLEAN + if mc.objExists("ModIt_DupliWorld_Instance"): + mc.delete("ModIt_DupliWorld_Instance") + + + if axis == 0: + mel.eval("instance; scale -r -1 1 1") + elif axis == 1: + mel.eval("instance; scale -r 1 -1 1") + elif axis == 2: + mel.eval("instance; scale -r 1 1 -1") + elif axis == 4: + AXIS = (json.load(open(PreferencePath + 'Pref_SymAxis.json', "r"))['VALUE']) + if AXIS == 0: + mel.eval("instance; scale -r -1 1 1") + elif AXIS == 1: + mel.eval("instance; scale -r 1 -1 1") + elif AXIS == 2: + mel.eval("instance; scale -r 1 1 -1") + + instanceRootGroup = mc.ls(sl=True) + mc.rename(instanceRootGroup, "ModIt_InstanceWorld_grp") + + + + + + def Separate(self): + mc.undoInfo(openChunk=True, infinity=True) + + testSelection = mc.ls(sl=True, l=True) + if testSelection == []: + print("ModIt Error : Nothing Selected") + return + else: + mc.SeparatePolygon() + getParent = mc.listRelatives(parent=True, f=True) + separateSel = mc.ls(sl=True, l=True) + mc.CenterPivot() + addSelToNewSet = mc.sets(n='ModIt_Set_Separate') + mc.delete(ch=True) + mc.ungroup(getParent) + mc.select('ModIt_Set_Separate') + newSel = mc.ls(sl=True, l=True) + mc.FreezeTransformations() + mc.delete('ModIt_Set_Separate') + mc.select(newSel[0]) + + mc.undoInfo(closeChunk=True) + + def Combine(self): + mc.undoInfo(openChunk=True, infinity=True) + try: + mel.eval('source "' + ToolsPath + 'Combine.mel"') + mc.CenterPivot() + except: + ModIt_Global.WarningWindow("You should select at least 2 meshes.", 300) + return + + mc.undoInfo(closeChunk=True) + + + def ExtractFace(self): + #Verif Selection is Face + checkSelectedComponent = mc.filterExpand(sm=34) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" You should select Faces.", 300) + return + else: + mel.eval('source "' + ToolsPath + 'ExtractFace.mel"') + + def DuplicatFace(self): + #Verif Selection is Face + checkSelectedComponent = mc.filterExpand(sm=34) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" You should select Faces.", 300) + return + else: + mel.eval('source "' + ToolsPath + 'DuplicateFace.mel"') + + def EdgeFlow(self): + #Verif Selection is Edge + checkSelectedComponent = mc.filterExpand(sm=32) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" You should select Edges.", 300) + return + else: + mc.polyEditEdgeFlow(ch=1, adjustEdgeFlow=1) + + + + + + def BevelVertex(self): + #Verif Selection is Vertex + checkSelectedComponent = mc.filterExpand(sm=31) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" Works only for Vertex on border.", 300) + return + else: + mc.undoInfo(openChunk=True, infinity=True) + ###_________Selection + VertexInitSelection = mc.ls(sl=True) + mc.ConvertSelectionToFaces() + mc.ConvertSelectionToContainedEdges() + BorderAll = mc.sets(n="Border_Set") + + mc.select(VertexInitSelection) + mc.ConvertSelectionToEdges() + BorderToVerif = mc.sets(n="ToVerif_Set") + + # Return the union of two sets + Verif = mc.sets("Border_Set", sub="ToVerif_Set") + mc.select(Verif) + EdgeSel = mc.ls(sl=True) + + mc.delete("Border_Set") + mc.delete("ToVerif_Set") + + mc.polyExtrudeEdge(EdgeSel, kft=True, pvx=0, pvy=0, pvz=0, divisions=1, twist=0, taper=1, offset=0, thickness=0) + + mc.ConvertSelectionToFaces() + extrudeFaces = mc.ls(sl=True) + # mc.ToggleVisibilityAndKeepSelection() + mc.ConvertSelectionToContainedEdges() + edgeToBevel = mc.ls(sl=True) + + mel.eval('dR_DoCmd("bevelPress")') + mc.undoInfo(closeChunk=True) + + def BevelVertex_Hotkey(self): + sourceNote = ModIt_Global.ToolPath + "Hotkeys/BevelVertice_Hotkey.txt" + print("sourceNote == " + str(sourceNote)) + path = os.path.realpath(sourceNote) + os.startfile(path) + + + + + + def BevelVariable(self): + edgeSelect = mc.ls(sl=True, l=True) + + + if edgeSelect == []: + ModIt_Global.WarningWindow("You should select one edge", 250) + return + # Verif if component mode is edge + just_the_selected_edges = cmds.filterExpand(sm=32) + if just_the_selected_edges == None: + ModIt_Global.WarningWindow("You should select 1 edge", 250) + return + else: + if len(just_the_selected_edges) > 1: + ModIt_Global.WarningWindow("You should select 1 edge only", 250) + return + + + + # CHECK IF OPEN MESH AND IF SO STORE EDGES INFO + mc.select(mc.listHistory(edgeSelect)[0]) + mc.ConvertSelectionToEdgePerimeter() + checkEdgesPerimt = mc.ls(sl=True) + + if checkEdgesPerimt == []: # SO OBJET PLEIN + pass + else: + mc.sets(n="ModIt_PerimEdge_Save") + mc.select(edgeSelect) + + # GET VERTEXS + mc.ConvertSelectionToVertices() + vertexOrgerList = [] + for vertex in mc.ls(sl=1, fl=1): + vertexOrgerList.append(vertex) + + # TEST VERTEX ONE + vertexOne = vertexOrgerList[0] + mc.select(vertexOne) + mc.ConvertSelectionToEdges() + mc.sets(n="ModIt_VertexOne_Edges") + + if mc.sets("ModIt_PerimEdge_Save", ii="ModIt_VertexOne_Edges") == False: + print("VextexOne is : Close") + VextexOne = False + else: + print("VextexOne is : Open") + VextexOne = True + + # TEST VERTEX ONE + vertexTwo = vertexOrgerList[1] + mc.select(vertexTwo) + mc.ConvertSelectionToEdges() + mc.sets(n="ModIt_VertexTwo_Edges") + + if mc.sets("ModIt_PerimEdge_Save", ii="ModIt_VertexTwo_Edges") == False: + print("VextexTwo is : Close") + VextexTwo = False + else: + print("VextexTwo is : Open") + VextexTwo = True + + + if VextexOne == True: + if mc.objExists("ModIt_PerimEdge_Save"): + mc.delete("ModIt_PerimEdge_Save") + if mc.objExists("ModIt_VertexTwo_Edges"): + mc.delete("ModIt_VertexTwo_Edges") + if mc.objExists("ModIt_VertexOne_Edges"): + mc.delete("ModIt_VertexOne_Edges") + ModIt_Global.WarningWindow("One side from the select edge is open which is not good topology for the tool", 500) + return + elif VextexTwo == True: + if mc.objExists("ModIt_PerimEdge_Save"): + mc.delete("ModIt_PerimEdge_Save") + if mc.objExists("ModIt_VertexTwo_Edges"): + mc.delete("ModIt_VertexTwo_Edges") + if mc.objExists("ModIt_VertexOne_Edges"): + mc.delete("ModIt_VertexOne_Edges") + ModIt_Global.WarningWindow("One side from the select edge is open which is not good topology for the tool", 500) + return + + if mc.objExists("ModIt_PerimEdge_Save"): + mc.delete("ModIt_PerimEdge_Save") + if mc.objExists("ModIt_VertexTwo_Edges"): + mc.delete("ModIt_VertexTwo_Edges") + if mc.objExists("ModIt_VertexOne_Edges"): + mc.delete("ModIt_VertexOne_Edges") + + + + + mc.undoInfo(openChunk=True, infinity=True) + + #CLEAN VERIF + if mc.objExists("EdgePerimBefore_SET"): + mc.delete("EdgePerimBefore_SET") + if mc.objExists("EdgePerimAfter_SET"): + mc.delete("EdgePerimAfter_SET") + if mc.objExists("FaceToDel_SET"): + mc.delete("FaceToDel_SET") + if mc.objExists("OriginVertexSave_SET"): + mc.delete("OriginVertexSave_SET") + + + + #START PROCEDURE + mc.select(mc.listHistory(edgeSelect)[0]) + objectName = mc.ls(sl=True, l=True) + + + mc.select(edgeSelect) + OriginVertexSave = mc.ConvertSelectionToVertices() + mc.sets(n="OriginVertexSave_SET") + + # Get face shader + mc.select(edgeSelect) + mc.ConvertSelectionToFaces() + cmds.hyperShade(shaderNetworksSelectMaterialNodes=True) + getMaterial = cmds.ls(sl=True)[0] + print(getMaterial) + + ## + mc.select(edgeSelect) + faceToDel = mc.ConvertSelectionToFaces() + mc.sets(n="FaceToDel_SET") + + # Save PerimBefore + mc.ConvertSelectionToEdgePerimeter() + edgePerimBefore = mc.sets(n="EdgePerimBefore_SET") + + # Del Face to hole + mc.select("FaceToDel_SET") + mc.delete() + + mc.select("OriginVertexSave_SET") + # Selected vertices + vertexOrgerList = [] + for vertex in mc.ls(sl=1, fl=1): + vertexOrgerList.append(vertex) + + vertexOne = vertexOrgerList[0] + + ##____ BEVEL VERTEX : 1 ______________________________________ + mc.select(vertexOne) + ###_________Selection + VertexInitSelection = mc.ls(sl=True) + mc.ConvertSelectionToFaces() + mc.ConvertSelectionToContainedEdges() + BorderAll = mc.sets(n="Border_Set") + + mc.select(VertexInitSelection) + mc.ConvertSelectionToEdges() + BorderToVerif = mc.sets(n="ToVerif_Set") + + # Return the union of two sets + Verif = mc.sets("Border_Set", sub="ToVerif_Set") + mc.select(Verif) + EdgeSel = mc.ls(sl=True) + + mc.delete("Border_Set") + mc.delete("ToVerif_Set") + + mc.polyExtrudeEdge(EdgeSel, kft=True, pvx=0, pvy=0, pvz=0, divisions=1, twist=0, taper=1, offset=0, thickness=0) + + mc.ConvertSelectionToFaces() + extrudeFaces = mc.ls(sl=True) + mc.ConvertSelectionToContainedEdges() + edgeToBevel = mc.ls(sl=True) + + mel.eval('dR_DoCmd("bevelPress")') + mel.eval('string $getBevelNode[] = `listHistory -lv 1`;') + mel.eval('setAttr ($getBevelNode[1] + ".segments") 4;') + + mc.setToolTo('moveSuperContext') + + ##____ BEVEL VERTEX : 2 ______________________________________ + mc.select("OriginVertexSave_SET") + ###_________Selection + VertexInitSelection = mc.ls(sl=True) + mc.ConvertSelectionToFaces() + mc.ConvertSelectionToContainedEdges() + BorderAll = mc.sets(n="Border_Set") + + mc.select(VertexInitSelection) + mc.ConvertSelectionToEdges() + BorderToVerif = mc.sets(n="ToVerif_Set") + + # Return the union of two sets + Verif = mc.sets("Border_Set", sub="ToVerif_Set") + mc.select(Verif) + EdgeSel = mc.ls(sl=True) + + mc.delete("Border_Set") + mc.delete("ToVerif_Set") + + mc.polyExtrudeEdge(EdgeSel, kft=True, pvx=0, pvy=0, pvz=0, divisions=1, twist=0, taper=1, offset=0, thickness=0) + + mc.ConvertSelectionToFaces() + extrudeFaces = mc.ls(sl=True) + mc.ConvertSelectionToContainedEdges() + edgeToBevel = mc.ls(sl=True) + + mel.eval('dR_DoCmd("bevelPress")') + mel.eval('string $getBevelNode[] = `listHistory -lv 1`;') + mel.eval('setAttr ($getBevelNode[1] + ".segments") 4;') + + mc.setToolTo('moveSuperContext') + + ##____ FILL HOLE and CONNECT ______________________________________ + # Get sel to Bridge then + mc.select("EdgePerimBefore_SET") + mc.FillHole() + mc.sets(n="EdgePerimAfter_SET") + mc.ConvertSelectionToContainedFaces() + mc.delete() + + setDiff = mc.sets("EdgePerimBefore_SET", sub="EdgePerimAfter_SET") + mc.select(setDiff) + # BRIDGE + mc.polyBridgeEdge(divisions=0) + mc.ConvertSelectionToFaces() + mc.polySoftEdge(angle=45) + # Fill Holes + mc.select("EdgePerimBefore_SET") + mc.FillHole() + mc.ConvertSelectionToContainedFaces() + mc.hyperShade(assign=str(getMaterial)) + mc.select("EdgePerimAfter_SET") + mc.polySoftEdge(angle=0) + + #Clear + mc.SelectNone() # Deselect All + mc.delete("EdgePerimBefore_SET") + mc.delete("EdgePerimAfter_SET") + mc.delete("FaceToDel_SET") + mc.delete("OriginVertexSave_SET") + + + + + # 1 - GET ALL BEVEL NODE + typ = "polyBevel3" + nodes = [] + print("objectName here = " + str(objectName)) + for obj in objectName: + for node in mc.listHistory(obj): + if mc.nodeType(node) == typ: + nodes.append(node) + + BevelA_node = nodes[0] + BevelB_node = nodes[1] + + print(BevelA_node) + print(BevelB_node) + mc.undoInfo(closeChunk=True) + #---------------------- UI + + + + #Pour eviter la boucle infinie avec le atClose qui clean la THumbScene + if mc.window("Bevel2", exists=True): + mc.deleteUI("Bevel2") + + + importlib.reload(ModIt_2Bevels_UI) + ModIt_2Bevels_UI.SEND_INFO(str(BevelA_node), str(BevelB_node)) + ModIt_2Bevels_UI.showUI() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/Section_PRIMITIVES.py b/Scripts/Modeling/Edit/ModIt/Modeling/Section_PRIMITIVES.py new file mode 100644 index 0000000..4ca4433 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/Section_PRIMITIVES.py @@ -0,0 +1,702 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = ModIt_Global.iconFixeSize +iconButtonSize = ModIt_Global.iconButtonSize +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA +PRIM_MODE =(json.load(open(PreferencePath + 'Setting_Primitives_Placement.json',"r"))['PRIM_MODE']) +PRIM_SIZE =(json.load(open(PreferencePath + 'Setting_Primitives_Size.json',"r"))['PRIM_SIZE']) + + +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + + + + +class PRIMITIVES_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + SECTION_PRIMITIVES_LAYOUT = QtWidgets.QHBoxLayout() # MAIN + SECTION_PRIMITIVES_LAYOUT.setContentsMargins(0,0,0,0) + self.setLayout(SECTION_PRIMITIVES_LAYOUT) + + ##---------------------------------------------------- PRIMITIVES - CUBE + #self.CubeBtn = QtWidgets.QPushButton() + self.CubeBtn = MyCustomBtn_Widget() + self.CubeBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.CubeBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.CubeBtn.setIcon(QtGui.QIcon(IconPath + "Prim_CUBE.png")) + self.CubeBtn.clicked.connect(partial(self.Create_Cube, 1)) + + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + #self.CubeBtn.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.CubeBtn.customContextMenuRequested.connect(self.showPopupCube) + # CUBE M E N U I T E M S + self.popupMenuCube = QtWidgets.QMenu() + CubeMenu_Entry_1 = self.popupMenuCube.addAction("Cube sbdv 1") + CubeMenu_Entry_2 = self.popupMenuCube.addAction("Cube sbdv 2") + CubeMenu_Entry_3 = self.popupMenuCube.addAction("Cube sbdv 3") + CubeMenu_Entry_4 = self.popupMenuCube.addAction("Cube sbdv 4") + CubeMenu_Entry_1.triggered.connect(partial(self.Create_Cube, 1)) + CubeMenu_Entry_2.triggered.connect(partial(self.Create_Cube, 2)) + CubeMenu_Entry_3.triggered.connect(partial(self.Create_Cube, 3)) + CubeMenu_Entry_4.triggered.connect(partial(self.Create_Cube, 4)) + + + ##---------------------------------------------------- PRIMITIVES - SPHERE + self.SphereBtn = MyCustomBtn_Widget() + self.SphereBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.SphereBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SphereBtn.setIcon(QtGui.QIcon(IconPath + "Prim_SPHERE.png")) + self.SphereBtn.clicked.connect(partial(self.Create_Sphere, 16, 10)) + + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.SphereBtn.customContextMenuRequested.connect(self.showPopupSphere) + # CUBE M E N U I T E M S + self.popupMenuSphere = QtWidgets.QMenu() + SphereMenu_Entry_1 = self.popupMenuSphere.addAction("Sphere sbdv 12") + SphereMenu_Entry_2 = self.popupMenuSphere.addAction("Sphere sbdv 14") + SphereMenu_Entry_3 = self.popupMenuSphere.addAction("Sphere sbdv 16") + SphereMenu_Entry_4 = self.popupMenuSphere.addAction("Sphere sbdv 18") + SphereMenu_Entry_5 = self.popupMenuSphere.addAction("Sphere sbdv 20") + SphereMenu_Entry_6 = self.popupMenuSphere.addAction("Sphere sbdv 22") + SphereMenu_Entry_1.triggered.connect(partial(self.Create_Sphere, 12, 6)) + SphereMenu_Entry_2.triggered.connect(partial(self.Create_Sphere, 14, 8)) + SphereMenu_Entry_3.triggered.connect(partial(self.Create_Sphere, 16, 10)) + SphereMenu_Entry_4.triggered.connect(partial(self.Create_Sphere, 18, 10)) + SphereMenu_Entry_5.triggered.connect(partial(self.Create_Sphere, 20, 12)) + SphereMenu_Entry_6.triggered.connect(partial(self.Create_Sphere, 22, 12)) + + ##---------------------------------------------------- PRIMITIVES - CYLINDER + self.CylinderBtn = MyCustomBtn_Widget() + self.CylinderBtn.setObjectName("TABSBTN") + self.CylinderBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.CylinderBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.CylinderBtn.setIcon(QtGui.QIcon(IconPath + "Prim_CYLINDRE.png")) + self.CylinderBtn.clicked.connect(partial(self.Create_Cylinder, 2, 16)) + + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.CylinderBtn.customContextMenuRequested.connect(self.showPopupCylinder) + # CUBE M E N U I T E M S + self.popupMenuCylinder = QtWidgets.QMenu() + CylinderMenu_Entry_0 = self.popupMenuCylinder.addAction("------------X") + CylinderMenu_Entry_1 = self.popupMenuCylinder.addAction("Cylinder 8") + CylinderMenu_Entry_2 = self.popupMenuCylinder.addAction("Cylinder 12") + CylinderMenu_Entry_3 = self.popupMenuCylinder.addAction("Cylinder 16") + CylinderMenu_Entry_4 = self.popupMenuCylinder.addAction("Cylinder 28") + CylinderMenu_Entry_00 = self.popupMenuCylinder.addAction("------------Y") + CylinderMenu_Entry_5 = self.popupMenuCylinder.addAction("Cylinder 8") + CylinderMenu_Entry_6 = self.popupMenuCylinder.addAction("Cylinder 12") + CylinderMenu_Entry_7 = self.popupMenuCylinder.addAction("Cylinder 16") + CylinderMenu_Entry_8 = self.popupMenuCylinder.addAction("Cylinder 28") + CylinderMenu_Entry_000 = self.popupMenuCylinder.addAction("------------Z") + CylinderMenu_Entry_9 = self.popupMenuCylinder.addAction("Cylinder 8") + CylinderMenu_Entry_10 = self.popupMenuCylinder.addAction("Cylinder 12") + CylinderMenu_Entry_11 = self.popupMenuCylinder.addAction("Cylinder 16") + CylinderMenu_Entry_12 = self.popupMenuCylinder.addAction("Cylinder 28") + CylinderMenu_Entry_1.triggered.connect(partial(self.Create_Cylinder, 1, 8)) + CylinderMenu_Entry_2.triggered.connect(partial(self.Create_Cylinder, 1, 12)) + CylinderMenu_Entry_3.triggered.connect(partial(self.Create_Cylinder, 1, 16)) + CylinderMenu_Entry_4.triggered.connect(partial(self.Create_Cylinder, 1, 28)) + + CylinderMenu_Entry_5.triggered.connect(partial(self.Create_Cylinder, 2, 8)) + CylinderMenu_Entry_6.triggered.connect(partial(self.Create_Cylinder, 2, 12)) + CylinderMenu_Entry_7.triggered.connect(partial(self.Create_Cylinder, 2, 16)) + CylinderMenu_Entry_8.triggered.connect(partial(self.Create_Cylinder, 2, 28)) + + CylinderMenu_Entry_9.triggered.connect(partial(self.Create_Cylinder, 3, 8)) + CylinderMenu_Entry_10.triggered.connect(partial(self.Create_Cylinder, 3, 12)) + CylinderMenu_Entry_11.triggered.connect(partial(self.Create_Cylinder, 3, 16)) + CylinderMenu_Entry_12.triggered.connect(partial(self.Create_Cylinder, 3, 28)) + + + + ##---------------------------------------------------- PRIMITIVES - PLANE + self.PlaneBtn = MyCustomBtn_Widget() + self.PlaneBtn.setObjectName("TABSBTN") + self.PlaneBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.PlaneBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.PlaneBtn.setIcon(QtGui.QIcon(IconPath + "Prim_PLANE.png")) + self.PlaneBtn.clicked.connect(partial(self.Create_Plane, 2)) + + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.PlaneBtn.customContextMenuRequested.connect(self.showPopupPlane) + # CUBE M E N U I T E M S + self.popupMenuPlane = QtWidgets.QMenu() + PlaneMenu_Entry_1 = self.popupMenuPlane.addAction("Plane X") + PlaneMenu_Entry_2 = self.popupMenuPlane.addAction("Plane Y") + PlaneMenu_Entry_3 = self.popupMenuPlane.addAction("Plane Z") + PlaneMenu_Entry_1.triggered.connect(partial(self.Create_Plane, 1)) + PlaneMenu_Entry_2.triggered.connect(partial(self.Create_Plane, 2)) + PlaneMenu_Entry_3.triggered.connect(partial(self.Create_Plane, 3)) + + + ##---------------------------------------------------- Add to Layout + SECTION_PRIMITIVES_LAYOUT.addWidget(self.CubeBtn) + SECTION_PRIMITIVES_LAYOUT.addWidget(self.SphereBtn) + SECTION_PRIMITIVES_LAYOUT.addWidget(self.CylinderBtn) + SECTION_PRIMITIVES_LAYOUT.addWidget(self.PlaneBtn) + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + #------------------------------------------------ + def BAM(self): + print("BAMMM") + + + # Data to be written + dictionary = { + "name": "Wizix", + "Age": 32, + "Tag": "wzx", + } + + open(PreferencePath + 'TestFile.json', "w").write(json.dumps(dictionary, indent=3)) + def BAM2(self): + print("BAMMM2") + + # Data to be written + entry = {"Age": 36} + + filename = PreferencePath + 'TestFile.json' + lst = [{'alice': 24, 'bob': 27}] + + with open(filename, mode='w') as f: + lst.append({'carl': 33}) + json.dump(lst, f) + + + def Create_Cube(self, subdiv): + #_______________VAR + MultiScale = (json.load(open(PreferencePath + 'Setting_Primitives_Size.json', "r"))['PRIM_SIZE']) + InteractionMode = (json.load(open(PreferencePath + 'Setting_Primitives_Placement.json', "r"))['PRIM_MODE']) + PRIM_TOPOF = (json.load(open(PreferencePath + 'Setting_Primitives_OnTopOf.json', "r"))['VALUE']) + + self.CubeBtn.update() + RenameName = "Cube_001" + + + if InteractionMode == 0: + selection = mc.ls(sl=True) + createCubePrim = mc.polyCube(w=10 * MultiScale, h=10 * MultiScale, d=10 * MultiScale, sx=subdiv, sy=subdiv, sz=subdiv, ax=[0, 1, 0], cuv=4, ch=1) + + if selection == []: #GRID MODE + createCubePrim + mc.select(createCubePrim) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + elif mc.objectType(selection[0]) == "mesh": #COMPONENT MODE + mc.select(selection) + mc.setToolTo('moveSuperContext') + pos = mc.manipMoveContext('Move', query=True, position=True) + createCubePrim + mc.select(createCubePrim) + # 1 - Place at component position + mc.move(pos[0], pos[1], pos[2]) + constr = mc.normalConstraint(selection, createCubePrim, aimVector=(0, 1, 0), worldUpType=0) + mc.delete(constr) + myObj = mc.rename(RenameName) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + + else: #ON TOP OF MODE + if PRIM_TOPOF == 1: + createCubePrim + mc.select(createCubePrim) + mc.xform(ws=1, a=1, piv=[0, 0, 0]) + mc.makeIdentity(apply=True) + + ##_______________Get Selection BBOX + bbox = mc.exactWorldBoundingBox(selection) + Ymin = bbox[1] + YMax = bbox[4] + + # 0 - Init Freeze at Origin asset + bbox = mc.exactWorldBoundingBox(createCubePrim) + bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2] + mc.xform(createCubePrim, piv=bottom, ws=True) + mc.move(0, 0, 0, createCubePrim, rpr=True) + mc.select(createCubePrim) + mc.makeIdentity(apply=True, t=1, r=1, s=1) + + + # 1 - Place at obj posion + mc.matchTransform(createCubePrim, selection, pos=True) + + # 2 - Up to Top + mc.move(YMax, createCubePrim, y=True, a=True) + + + mc.select(createCubePrim[0]) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + else: + pass + + else: + #VERIF SELECTION + SELECTION = mc.ls(sl=True) + if SELECTION == []: + ModIt_Global.WarningWindow("You should select a mesh", 250) + return + + mc.SelectVertexMask() + mc.SelectToggleMode() + + #ACTIVATE INTERACTIVE CREATION USER + if mc.optionVar(q="createPolyPrimitiveAsTool") == 0: + mc.ToggleCreatePolyPrimitivesAsTool() + if mc.optionVar(q="polyPrimitiveAsToolExitOnComplete") == 0: + mc.TogglePolyPrimitivesAsToolExitOnComplete() + + + #ADD TO SNAP OBJECT + ##KILL INTERACTIVE PRIM SCRIPT JOB + JOB_NUMBER = (json.load(open(PreferencePath + 'JobNumber.json', "r"))['JOB_NUMBER']) + + try: + mc.scriptJob(kill=JOB_NUMBER, force=True) + except: + pass + + mc.makeLive() + #ACTIVATE INTERACTIVE et EXIT + InteractiveModeScriptJob = mel.eval('int $jobNum = `scriptJob -ct "SomethingSelected" "makeLive -none;" -protected`;') + + open(PreferencePath + 'JobNumber.json', "w").write(json.dumps({"JOB_NUMBER": InteractiveModeScriptJob})) + + + mc.createPolyCubeCtx("CreatePolyCubeCtx", e=True, w=10*MultiScale, h=10*MultiScale, d=10*MultiScale, sh=subdiv, sd=subdiv, sw=subdiv) + mc.setToolTo("CreatePolyCubeCtx") + + + + + def Create_Sphere(self, subdivA, subdivH): + # _______________VAR + MultiScale = (json.load(open(PreferencePath + 'Setting_Primitives_Size.json', "r"))['PRIM_SIZE']) + InteractionMode = (json.load(open(PreferencePath + 'Setting_Primitives_Placement.json', "r"))['PRIM_MODE']) + PRIM_TOPOF = (json.load(open(PreferencePath + 'Setting_Primitives_OnTopOf.json', "r"))['VALUE']) + self.SphereBtn.update() + RenameName = "Sphere_001" + + if InteractionMode == 0: + selection = mc.ls(sl=True) + createSpherePrim = mc.polySphere(r=5*MultiScale, sx=subdivA, sy=subdivH, ax=[0, 1, 0], cuv=2,ch=1) + + if selection == []: # GRID MODE + createSpherePrim + mc.select(createSpherePrim) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + elif mc.objectType(selection[0]) == "mesh": # COMPONENT MODE + mc.select(selection) + mc.setToolTo('moveSuperContext') + pos = mc.manipMoveContext('Move', query=True, position=True) + createSpherePrim + mc.select(createSpherePrim) + # 1 - Place at component position + mc.move(pos[0], pos[1], pos[2]) + constr = mc.normalConstraint(selection, createSpherePrim, aimVector=(0, 1, 0), worldUpType=0) + mc.delete(constr) + myObj = mc.rename(RenameName) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + + else: # ON TOP OF MODE + if PRIM_TOPOF == 1: + createSpherePrim + mc.select(createSpherePrim) + mc.xform(ws=1, a=1, piv=[0, 0, 0]) + mc.makeIdentity(apply=True) + + ##_______________Get Selection BBOX + bbox = mc.exactWorldBoundingBox(selection) + Ymin = bbox[1] + YMax = bbox[4] + + # 0 - Init Freeze at Origin asset + bbox = mc.exactWorldBoundingBox(createSpherePrim) + bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2] + mc.xform(createSpherePrim, piv=bottom, ws=True) + mc.move(0, 0, 0, createSpherePrim, rpr=True) + mc.select(createSpherePrim) + mc.makeIdentity(apply=True, t=1, r=1, s=1) + + # 1 - Place at obj posion + mc.matchTransform(createSpherePrim, selection, pos=True) + + # 2 - Up to Top + mc.move(YMax, createSpherePrim, y=True, a=True) + + mc.select(createSpherePrim[0]) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + else: + pass + else: + # VERIF SELECTION + SELECTION = mc.ls(sl=True) + if SELECTION == []: + ModIt_Global.WarningWindow("You should select a mesh", 250) + return + + mc.SelectVertexMask() + mc.SelectToggleMode() + + # ACTIVATE INTERACTIVE CREATION USER + if mc.optionVar(q="createPolyPrimitiveAsTool") == 0: + mc.ToggleCreatePolyPrimitivesAsTool() + if mc.optionVar(q="polyPrimitiveAsToolExitOnComplete") == 0: + mc.TogglePolyPrimitivesAsToolExitOnComplete() + + # ADD TO SNAP OBJECT + ##KILL INTERACTIVE PRIM SCRIPT JOB + JOB_NUMBER = (json.load(open(PreferencePath + 'JobNumber.json', "r"))['JOB_NUMBER']) + + try: + mc.scriptJob(kill=JOB_NUMBER, force=True) + except: + pass + + mc.makeLive() + # ACTIVATE INTERACTIVE et EXIT + InteractiveModeScriptJob = mel.eval( + 'int $jobNum = `scriptJob -ct "SomethingSelected" "makeLive -none;" -protected`;') + + open(PreferencePath + 'JobNumber.json', "w").write(json.dumps({"JOB_NUMBER": InteractiveModeScriptJob})) + + mc.createPolySphereCtx("CreatePolySphereCtx", e=True, radius=5 * MultiScale, sh=subdivA, sw=subdivH) + mc.setToolTo("CreatePolySphereCtx") + mc.polySoftEdge(a=45, ch=1) + + def Create_Cylinder(self, axe, subdiv): + # _______________VAR + MultiScale = (json.load(open(PreferencePath + 'Setting_Primitives_Size.json', "r"))['PRIM_SIZE']) + InteractionMode = (json.load(open(PreferencePath + 'Setting_Primitives_Placement.json', "r"))['PRIM_MODE']) + PRIM_TOPOF = (json.load(open(PreferencePath + 'Setting_Primitives_OnTopOf.json', "r"))['VALUE']) + self.CylinderBtn.update() + RenameName = "Cylinder_001" + + if axe == 1: + axValue = [1, 0, 0] + elif axe == 2: + axValue = [0, 1, 0] + elif axe == 3: + axValue = [0, 0, 1] + + if InteractionMode == 0: + selection = mc.ls(sl=True) + createCylinderPrim = mc.polyCylinder(r=5 * MultiScale, h=10* MultiScale, sy=1, sz=0, ax= axValue, sc=0, cuv=4, ch=1, sa=subdiv) + + if selection == []: # GRID MODE + createCylinderPrim + mc.select(createCylinderPrim) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + + elif mc.objectType(selection[0]) == "mesh": # COMPONENT MODE + mc.select(selection) + mc.setToolTo('moveSuperContext') + pos = mc.manipMoveContext('Move', query=True, position=True) + createCylinderPrim + mc.select(createCylinderPrim) + # 1 - Place at component position + mc.move(pos[0], pos[1], pos[2]) + constr = mc.normalConstraint(selection, createCylinderPrim, aimVector=(0, 1, 0), worldUpType=0) + mc.delete(constr) + myObj = mc.rename(RenameName) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + + else: # ON TOP OF MODE + if PRIM_TOPOF == 1: + createCylinderPrim + mc.select(createCylinderPrim) + mc.xform(ws=1, a=1, piv=[0, 0, 0]) + mc.makeIdentity(apply=True) + + ##_______________Get Selection BBOX + bbox = mc.exactWorldBoundingBox(selection) + Ymin = bbox[1] + YMax = bbox[4] + + # 0 - Init Freeze at Origin asset + bbox = mc.exactWorldBoundingBox(createCylinderPrim) + bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2] + mc.xform(createCylinderPrim, piv=bottom, ws=True) + mc.move(0, 0, 0, createCylinderPrim, rpr=True) + mc.select(createCylinderPrim) + mc.makeIdentity(apply=True, t=1, r=1, s=1) + + # 1 - Place at obj posion + mc.matchTransform(createCylinderPrim, selection, pos=True) + + # 2 - Up to Top + mc.move(YMax, createCylinderPrim, y=True, a=True) + + mc.select(createCylinderPrim[0]) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl= True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + else: + pass + else: + # VERIF SELECTION + SELECTION = mc.ls(sl=True) + if SELECTION == []: + ModIt_Global.WarningWindow("You should select a mesh", 250) + return + + mc.SelectVertexMask() + mc.SelectToggleMode() + + # ACTIVATE INTERACTIVE CREATION USER + if mc.optionVar(q="createPolyPrimitiveAsTool") == 0: + mc.ToggleCreatePolyPrimitivesAsTool() + if mc.optionVar(q="polyPrimitiveAsToolExitOnComplete") == 0: + mc.TogglePolyPrimitivesAsToolExitOnComplete() + + # ADD TO SNAP OBJECT + ##KILL INTERACTIVE PRIM SCRIPT JOB + JOB_NUMBER = (json.load(open(PreferencePath + 'JobNumber.json', "r"))['JOB_NUMBER']) + + try: + mc.scriptJob(kill=JOB_NUMBER, force=True) + except: + pass + + mc.makeLive() + # ACTIVATE INTERACTIVE et EXIT + InteractiveModeScriptJob = mel.eval( + 'int $jobNum = `scriptJob -ct "SomethingSelected" "makeLive -none;" -protected`;') + + open(PreferencePath + 'JobNumber.json', "w").write(json.dumps({"JOB_NUMBER": InteractiveModeScriptJob})) + + mc.createPolyCylinderCtx("CreatePolyCylinderCtx", e=True, radius=5 * MultiScale, height=10 * MultiScale , sa =subdiv) + mc.setToolTo("CreatePolyCylinderCtx") + mc.polySoftEdge(a=45, ch=1) + + + def Create_Plane(self, axe): + # _______________VAR + MultiScale = (json.load(open(PreferencePath + 'Setting_Primitives_Size.json', "r"))['PRIM_SIZE']) + InteractionMode = (json.load(open(PreferencePath + 'Setting_Primitives_Placement.json', "r"))['PRIM_MODE']) + PRIM_TOPOF = (json.load(open(PreferencePath + 'Setting_Primitives_OnTopOf.json', "r"))['VALUE']) + self.CubeBtn.update() + RenameName = "Plane_001" + + if axe == 1: + axValue = [1, 0, 0] + elif axe == 2: + axValue = [0, 1, 0] + elif axe == 3: + axValue = [0, 0, 1] + + if InteractionMode == 0: + selection = mc.ls(sl=True) + createPlanePrim = mc.polyPlane(w=10 * MultiScale, h=10 * MultiScale, sx=1, sy=1, ax=axValue, cuv=2, ch=1) + + if selection == []: # GRID MODE + createPlanePrim + mc.select(createPlanePrim) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl=True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + elif mc.objectType(selection[0]) == "mesh": # COMPONENT MODE + mc.select(selection) + mc.setToolTo('moveSuperContext') + pos = mc.manipMoveContext('Move', query=True, position=True) + createPlanePrim + mc.select(createPlanePrim) + # 1 - Place at component position + mc.move(pos[0], pos[1], pos[2]) + constr = mc.normalConstraint(selection, createPlanePrim, aimVector=(0, 1, 0), worldUpType=0) + mc.delete(constr) + myObj = mc.rename(RenameName) + mc.select(cl=True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + + + else: # ON TOP OF MODE + if PRIM_TOPOF == 1: + createPlanePrim + mc.select(createPlanePrim) + mc.xform(ws=1, a=1, piv=[0, 0, 0]) + mc.makeIdentity(apply=True) + + ##_______________Get Selection BBOX + bbox = mc.exactWorldBoundingBox(selection) + Ymin = bbox[1] + YMax = bbox[4] + + # 0 - Init Freeze at Origin asset + bbox = mc.exactWorldBoundingBox(createPlanePrim) + bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2] + mc.xform(createPlanePrim, piv=bottom, ws=True) + mc.move(0, 0, 0, createPlanePrim, rpr=True) + mc.select(createPlanePrim) + mc.makeIdentity(apply=True, t=1, r=1, s=1) + + # 1 - Place at obj posion + mc.matchTransform(createPlanePrim, selection, pos=True) + + # 2 - Up to Top + mc.move(YMax, createPlanePrim, y=True, a=True) + + mc.select(createPlanePrim[0]) + mc.CenterPivot() + myObj = mc.rename(RenameName) + mc.polySoftEdge(a=45, ch=1) + mc.makeIdentity(apply=True) + mc.select(cl=True) + mc.select(myObj) + mc.setToolTo('moveSuperContext') + else: + pass + + + + else: + # VERIF SELECTION + SELECTION = mc.ls(sl=True) + if SELECTION == []: + ModIt_Global.WarningWindow("You should select a mesh", 250) + return + + mc.SelectVertexMask() + mc.SelectToggleMode() + + # ACTIVATE INTERACTIVE CREATION USER + if mc.optionVar(q="createPolyPrimitiveAsTool") == 0: + mc.ToggleCreatePolyPrimitivesAsTool() + if mc.optionVar(q="polyPrimitiveAsToolExitOnComplete") == 0: + mc.TogglePolyPrimitivesAsToolExitOnComplete() + + # ADD TO SNAP OBJECT + ##KILL INTERACTIVE PRIM SCRIPT JOB + JOB_NUMBER = (json.load(open(PreferencePath + 'JobNumber.json', "r"))['JOB_NUMBER']) + + try: + mc.scriptJob(kill=JOB_NUMBER, force=True) + except: + pass + + mc.makeLive() + # ACTIVATE INTERACTIVE et EXIT + InteractiveModeScriptJob = mel.eval( + 'int $jobNum = `scriptJob -ct "SomethingSelected" "makeLive -none;" -protected`;') + + open(PreferencePath + 'JobNumber.json', "w").write(json.dumps({"JOB_NUMBER": InteractiveModeScriptJob})) + + mc.createPolyPlaneCtx("CreatePolyPlaneCtx", e=True, w=10 * MultiScale, h=10 * MultiScale, sh=1, sw=1) + mc.setToolTo("CreatePolyPlaneCtx") + + + def showPopupCube(self, position): + self.popupMenuCube.exec_(self.CubeBtn.mapToGlobal(position)) + self.CubeBtn.update() + + def showPopupSphere(self, position): + self.popupMenuSphere.exec_(self.SphereBtn.mapToGlobal(position)) + self.SphereBtn.update() + + def showPopupCylinder(self, position): + self.popupMenuCylinder.exec_(self.CylinderBtn.mapToGlobal(position)) + self.CylinderBtn.update() + + def showPopupPlane(self, position): + self.popupMenuPlane.exec_(self.PlaneBtn.mapToGlobal(position)) + self.PlaneBtn.update() + + + + diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/Section_SELECTIONS.py b/Scripts/Modeling/Edit/ModIt/Modeling/Section_SELECTIONS.py new file mode 100644 index 0000000..fd5169b --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/Section_SELECTIONS.py @@ -0,0 +1,424 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 32 +iconButtonSize = 30 +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA +PRIM_MODE =(json.load(open(PreferencePath + 'Setting_Primitives_Placement.json',"r"))['PRIM_MODE']) +PRIM_SIZE =(json.load(open(PreferencePath + 'Setting_Primitives_Size.json',"r"))['PRIM_SIZE']) + + + +class MyCustomBtn_Widget_forIcon(QtWidgets.QPushButton): + def __init__(self, iconPath): + super().__init__() + #FOR ICON HOVER EFFECT + pix_normal = QtGui.QPixmap(iconPath) + pix_over = pix_normal.copy() + painter = QtGui.QPainter(pix_over) + painter.fillRect(pix_over.rect(), QtGui.QColor(250, 250, 250, 40)) + painter.setCompositionMode(QtGui.QPainter.CompositionMode_Plus) + painter.end() + self._icon_normal = QIcon(pix_normal) + self._icon_over = QIcon(pix_over) + self.setIcon(self._icon_normal) + #FOR CONTEXT MENU + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + + def enterEvent(self, event): #ICON + self.setIcon(self._icon_over) + return super(MyCustomBtn_Widget, self).enterEvent(event) + def leaveEvent(self, event): #ICON + self.setIcon(self._icon_normal) + return super(MyCustomBtn_Widget, self).leaveEvent(event) + + def mousePressEvent(self, event): #CONTEXT MENUE + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + + +class SELECTIONS_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + SECTION_SELECTIONS_LAYOUT = QtWidgets.QHBoxLayout() # MAIN + SECTION_SELECTIONS_LAYOUT.setContentsMargins(0,0,0,0) + SECTION_SELECTIONS_LAYOUT.setSpacing(0) + self.setLayout(SECTION_SELECTIONS_LAYOUT) + + ##---------------------------------------------------- ALIGN PIVOT + self.AlignPivotFace_btn = MyCustomBtn_Widget() + self.AlignPivotFace_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.AlignPivotFace_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.AlignPivotFace_btn.setIcon(QtGui.QIcon(IconPath + "AlignFace.png")) + self.AlignPivotFace_btn.setToolTip(" Align and Bake Object Pivot based on Face Normals ") + self.AlignPivotFace_btn.clicked.connect(self.alignPivotFace) + + + + ##---------------------------------------------------- CONTINUS EDGE + self.ContinusEdge_btn = MyCustomBtn_Widget() + self.ContinusEdge_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.ContinusEdge_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ContinusEdge_btn.setIcon(QtGui.QIcon(IconPath + "ContinusEdge.png")) + self.ContinusEdge_btn.setToolTip(" Select All Perimeter Contiguous Edge Until +45° angle ") + self.ContinusEdge_btn.clicked.connect(self.continusEdges) + + + + + + + + + + + ##---------------------------------------------------- SELECT INNER + self.SelIn_btn = QtWidgets.QPushButton() + self.SelIn_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.SelIn_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SelIn_btn.setIcon(QtGui.QIcon(IconPath + "SelIco1b.png")) + self.SelIn_btn.setToolTip(" Select Inner Faces ") + self.SelIn_btn.clicked.connect(self.selInner) + + + ##---------------------------------------------------- SELECT INNER + SELECTION + self.SelInAndSel_btn = QtWidgets.QPushButton() + self.SelInAndSel_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.SelInAndSel_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.SelInAndSel_btn.setIcon(QtGui.QIcon(IconPath + "SelIco1.png")) + self.SelInAndSel_btn.setToolTip(" Select Inner Faces and Keep Selection ") + self.SelInAndSel_btn.clicked.connect(self.selInnerPlus) + + + ##---------------------------------------------------- NX Edge + self.EdgeNx_btn = MyCustomBtn_Widget() + self.EdgeNx_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.EdgeNx_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.EdgeNx_btn.setIcon(QtGui.QIcon(IconPath + "SelIco3.png")) + self.EdgeNx_btn.setToolTip(" Select Every X Edges ") + self.EdgeNx_btn.clicked.connect(partial(self.selEdgeNX, "edgeLoop", 2)) + + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.EdgeNx_btn.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.EdgeNx_btn.customContextMenuRequested.connect(self.showPopupNedge) + # CUBE M E N U I T E M S + self.popupMenuNedge = QtWidgets.QMenu() + Loop_2 = self.popupMenuNedge.addAction(" > Loop : Select 1 Edge each 2 Edges") + Loop_3 = self.popupMenuNedge.addAction(" > Loop : Select 1 Edge each 3 Edges") + Loop_4 = self.popupMenuNedge.addAction(" > Loop : Select 1 Edge each 4 Edges") + Loop_2.triggered.connect(partial(self.selEdgeNX, "edgeLoop", 2)) + Loop_3.triggered.connect(partial(self.selEdgeNX, "edgeLoop", 3)) + Loop_4.triggered.connect(partial(self.selEdgeNX, "edgeLoop", 4)) + Ring_2 = self.popupMenuNedge.addAction(" > Ring : Select 1 Edge each 2 Edges") + Ring_3 = self.popupMenuNedge.addAction(" > Ring : Select 1 Edge each 3 Edges") + Ring_4 = self.popupMenuNedge.addAction(" > Ring : Select 1 Edge each 4 Edges") + Ring_2.triggered.connect(partial(self.selEdgeNX, "edgeRing", 2)) + Ring_3.triggered.connect(partial(self.selEdgeNX, "edgeRing", 3)) + Ring_4.triggered.connect(partial(self.selEdgeNX, "edgeRing", 4)) + + + + + + + + + + + + + ##---------------------------------------------------- CHECK FACES + self.CheckFace_btn = MyCustomBtn_Widget() + self.CheckFace_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.CheckFace_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.CheckFace_btn.setIcon(QtGui.QIcon(IconPath + "SelIco2.png")) + self.CheckFace_btn.setToolTip(" Select Object Faces By Type ") + self.CheckFace_btn.clicked.connect(self.checkNGon) + + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.CheckFace_btn.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.CheckFace_btn.customContextMenuRequested.connect(self.showPopupCheck) + # CUBE M E N U I T E M S + self.popupMenuCube = QtWidgets.QMenu() + Ngons = self.popupMenuCube.addAction(" Select all NGons faces on the selected mesh") + Quad = self.popupMenuCube.addAction(" Select all Quadrangles faces on the selected mesh") + Tri = self.popupMenuCube.addAction(" Select all Triangles faces on the selected mesh") + Concave = self.popupMenuCube.addAction(" Select all Concaves faces on the selected mesh") + Ngons.triggered.connect(self.checkNGon) + Quad.triggered.connect(self.checkQuad) + Tri.triggered.connect(self.checkTri) + Concave.triggered.connect(self.checkNConcave) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ##---------------------------------------------------- Add to Layout + SECTION_SELECTIONS_LAYOUT.addWidget(self.AlignPivotFace_btn) + SECTION_SELECTIONS_LAYOUT.addWidget(self.ContinusEdge_btn) + SECTION_SELECTIONS_LAYOUT.addWidget(self.SelIn_btn) + SECTION_SELECTIONS_LAYOUT.addWidget(self.SelInAndSel_btn) + SECTION_SELECTIONS_LAYOUT.addWidget(self.EdgeNx_btn) + SECTION_SELECTIONS_LAYOUT.addWidget(self.CheckFace_btn) + + + + + + + + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + #------------------------------------------------ + def BAM(self): + print("BAMMM") + + + def showPopupNedge(self, position): + self.popupMenuNedge.exec_(self.EdgeNx_btn.mapToGlobal(position)) + self.EdgeNx_btn.update() + + def showPopupCheck(self, position): + self.popupMenuCube.exec_(self.CheckFace_btn.mapToGlobal(position)) + self.CheckFace_btn.update() + + + + def Clean(self): + mc.sets(n="selInnerPlusSet1") + mc.sets(add="selInnerPlusSet1") + mc.SelectFacetMask() + mc.polyUVSet(d=True, uvSet="ModIt_UvLayout") + mc.select(clear=True) + mc.select("selInnerPlusSet1") + mc.delete("selInnerPlusSet1") + + def CleanPluss(self): + mc.sets(n="selInnerPlusSet1") + mc.sets(add="selInnerPlusSet1") + mc.SelectFacetMask() + mc.polyUVSet(d=True, uvSet="ModIt_UvLayout") + mc.select(clear=True) + mc.select("selInnerPlusSet1") + mc.delete("selInnerPlusSet1") + mc.GrowPolygonSelectionRegion() + + def selInner(self): + #Verif Selection is Face + checkSelectedComponent = mc.filterExpand(sm=34) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" You should select Faces.", 300) + return + + mc.undoInfo(openChunk=True, infinity=True) + selFace= mc.ls(sl=True) + selObj = cmds.ls(sl=1, fl=1, o=1) + mc.polyProjection (selObj, ch=1, type= "Planar", ibd = False, cm= True, uvSetName = "ModIt_UvLayout", kir = True, md= "c") + mc.polyUVSet(cuv= True, uvSet = "ModIt_UvLayout") + + selEdgePeri = mc.ConvertSelectionToEdgePerimeter() + mc.polyMapCut() + + mc.SelectMeshUVShell() + + mc.scriptJob( runOnce=True, e = ["SelectionChanged", self.Clean]) + mc.undoInfo(closeChunk=True) + + + def selInnerPlus(self): + #Verif Selection is Face + checkSelectedComponent = mc.filterExpand(sm=34) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" You should select Faces.", 300) + return + + mc.undoInfo(openChunk=True, infinity=True) + selFace=mc.ls(sl=True) + selObj = cmds.ls(sl=1, fl=1, o=1) + + mc.polyProjection (selObj, ch=1, type= "Planar", ibd = False, cm= True, uvSetName = "ModIt_UvLayout", kir = True, md= "c") + mc.polyUVSet(cuv= True, uvSet = "ModIt_UvLayout") + + selEdgePeri = mc.ConvertSelectionToEdgePerimeter() + mc.polyMapCut() + + mc.SelectMeshUVShell() + + mc.scriptJob( runOnce=True, e = ["SelectionChanged", self.CleanPluss]) + mc.undoInfo(closeChunk=True) + + + def selEdgeNX(self, type, nbr): + mel.eval('polySelectEdgesEveryN "%s" %s;' % (type, nbr)) + + def checkNGon(self): + mc.selectMode(q=True, co=True) + mc.polySelectConstraint(m=3 ,t = 0x0008, sz=3) + mc.polySelectConstraint(dis=True) + + def checkTri(self): + mc.selectMode(q=True, co=True) + mc.polySelectConstraint(m=3 ,t = 0x0008, sz=1) + mc.polySelectConstraint(dis=True) + + def checkQuad(self): + mc.selectMode(q=True, co=True) + mc.polySelectConstraint(m=3 ,t = 0x0008, sz=2) + mc.polySelectConstraint(dis=True) + + + def checkNConcave(self): + mc.selectMode(q=True, co=True) + mc.polySelectConstraint(m=3 ,t = 0x0008, c=1) + mc.polySelectConstraint(dis=True) + + + def alignPivotFace(self): + #Verif Selection is Face + checkSelectedComponent = mc.filterExpand(sm=34) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" Works on Face mode only.", 300) + return + + else: + mc.undoInfo(openChunk=True, infinity=True) + mc.setToolTo('Move') + getPivotPos = mel.eval("float $getPivotPos[] = `manipMoveContext -q -p Move`;") + mel.eval("ConvertSelectionToVertices;") + vtxSel = mc.ls(fl=1, sl=1) + selectedObjectStore = mc.ls(o=1, sl=1) + objectSelectionStore = mc.listRelatives(selectedObjectStore[0], p=1) + if len(vtxSel) < 3: + mc.warning("ModIt : Please select at least 3 Vertices, 2 Edges or 1 Face") + + plane = mc.polyPlane(cuv=2, sy=1, sx=1, h=1, n='rotationPlane', ch=1, w=1, ax=(0, 1, 0)) + mc.select((plane[0] + ".vtx[0:2]"), vtxSel[0], vtxSel[1], vtxSel[2]) + mel.eval("snap3PointsTo3Points(0)") + mc.parent(objectSelectionStore, plane[0]) + mc.makeIdentity(objectSelectionStore, apply=True, s=0, r=1, t=0, n=0) + mc.xform(ws=1, piv=(getPivotPos[0], getPivotPos[1], getPivotPos[2])) + mc.parent(objectSelectionStore, world=1) + mc.delete(plane) + mc.undoInfo(closeChunk=True) + + + + def continusEdges(self): + #Verif Selection is Edge + checkSelectedComponent = mc.filterExpand(sm=32) + if checkSelectedComponent == None: + ModIt_Global.WarningWindow(" You should select a border edge.", 300) + return + + else: + mc.undoInfo(openChunk=True, infinity=True) + # 1 - Continus Edge + mc.SelectContiguousEdges() + + # 2 - Store Continus Set + mc.sets(n="ModIt_SelContinus_tempSet") + + # Need to get select objectq + mc.SelectVertexMask() + mc.SelectToggleMode() + + objSel = mc.ls(sl=True) + + # GET ALL FACE + list = mc.ls(sl=True) + for item in list: + fCount = mc.polyEvaluate(v=True) + mc.select(cl=True) + mc.select(item + '.f[0:' + str(fCount) + ']', add=True) + + # CONVERT IN EDGE + mc.ConvertSelectionToContainedEdges() + mc.sets(n="ModIt_IntEdges_tempSet") + + mc.select(mc.sets('ModIt_IntEdges_tempSet', sub="ModIt_SelContinus_tempSet")) + + mc.sets(n="ModIt_GoodSel") + mc.select(d=True) + + obSelName = str(objSel[0]) + mel.eval('doMenuComponentSelectionExt(" ' + obSelName + '", "edge", 0);') + mc.select("ModIt_GoodSel") + + mc.delete("ModIt_IntEdges_tempSet") + mc.delete("ModIt_SelContinus_tempSet") + mc.delete("ModIt_GoodSel") diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/Section_SETS.py b/Scripts/Modeling/Edit/ModIt/Modeling/Section_SETS.py new file mode 100644 index 0000000..6dff8ed --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/Section_SETS.py @@ -0,0 +1,483 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 26 +iconButtonSize = 26 +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA +WIN_DISPLAY_SIZE =(json.load(open(PreferencePath + 'WinSize.json',"r"))['VALUE']) +DOCK =(json.load(open(PreferencePath + 'Dockable.json',"r"))['VALUE']) + + +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + +class SETS_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + SECTION_SETS_LAYOUT = QtWidgets.QVBoxLayout()# MAIN + SECTION_SETS_LAYOUT.setContentsMargins(25, 2, 2, 2) + self.setLayout(SECTION_SETS_LAYOUT) + + setBtnClickZone = 16 + setBtnIconSize = 14 + SetBoutonWidht = 80 + + ##--------------------------------------- + ##----------------------------------------------------------------------------------------------------------------------------------------------- STORE SETS + ##--------------------------------------- SET - LIGNE 1 + SET_A_LYT = QtWidgets.QHBoxLayout() + SET_A_LYT.setSpacing(7) + SECTION_SETS_LAYOUT.addLayout(SET_A_LYT) + SECTION_SETS_LAYOUT.setSpacing(0) + + ##----------------------------------------------------------------- - + self.Set_1_Min_Btn = QtWidgets.QPushButton() + self.Set_1_Min_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set_1_Min_Btn.setIconSize(QtCore.QSize(setBtnIconSize, setBtnIconSize)) + self.Set_1_Min_Btn.setIcon(QtGui.QIcon(IconPath + "Moins.png")) + self.Set_1_Min_Btn.clicked.connect(partial(self.Sub_Set, 1)) + SET_A_LYT.addWidget(self.Set_1_Min_Btn) + + ##----------------------------------------------------------------------------------------------------------------------------------------- STORE SET 1 + self.Set_1_Store_Btn = QtWidgets.QPushButton() + self.Set_1_Store_Btn.setFixedSize(SetBoutonWidht, 20) + self.Set_1_Store_Btn.setObjectName("StoreSet") + self.Set_1_Store_Btn.setText("S E T - 2") + if WIN_DISPLAY_SIZE == 1: #150 + self.Set_1_Store_Btn.setFont(QtGui.QFont('Calibri', 6)) + self.Set_1_Store_Btn.clicked.connect(partial(self.Store_Set, 1)) + SET_A_LYT.addWidget(self.Set_1_Store_Btn) + + ##----------------------------------------------------------------- + + self.Set_1_Plus_Btn = QtWidgets.QPushButton() + self.Set_1_Plus_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set_1_Plus_Btn.setIconSize(QtCore.QSize(setBtnIconSize, setBtnIconSize)) + self.Set_1_Plus_Btn.setIcon(QtGui.QIcon(IconPath + "Plus.png")) + self.Set_1_Plus_Btn.clicked.connect(partial(self.Add_Set, 1)) + SET_A_LYT.addWidget(self.Set_1_Plus_Btn) + + SET_A_LYT.addSpacing(12) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,20) + self.Separator.setStyleSheet("background-color:#404040;") + SET_A_LYT.addWidget(self.Separator) + SET_A_LYT.addSpacing(12) + + ##----------------------------------------------------------------- - + self.Set_2_Min_Btn = QtWidgets.QPushButton() + self.Set_2_Min_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set_2_Min_Btn.setIconSize(QtCore.QSize(setBtnIconSize, setBtnIconSize)) + self.Set_2_Min_Btn.setIcon(QtGui.QIcon(IconPath + "Moins.png")) + self.Set_2_Min_Btn.clicked.connect(partial(self.Sub_Set, 2)) + SET_A_LYT.addWidget(self.Set_2_Min_Btn) + + ##----------------------------------------------------------------- STORE SET 2 + self.Set_2_Store_Btn = QtWidgets.QPushButton() + self.Set_2_Store_Btn.setFixedSize(SetBoutonWidht, 20) + self.Set_2_Store_Btn.setObjectName("StoreSet") + self.Set_2_Store_Btn.setText("S E T - 2") + if WIN_DISPLAY_SIZE == 1: #150% + self.Set_2_Store_Btn.setFont(QtGui.QFont('Calibri', 6)) + self.Set_2_Store_Btn.clicked.connect(partial(self.Store_Set, 2)) + SET_A_LYT.addWidget(self.Set_2_Store_Btn) + + ##----------------------------------------------------------------- + + self.Set_2_Plus_Btn = QtWidgets.QPushButton() + self.Set_2_Plus_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set_2_Plus_Btn.setIconSize(QtCore.QSize(setBtnIconSize, setBtnIconSize)) + self.Set_2_Plus_Btn.setIcon(QtGui.QIcon(IconPath + "Plus.png")) + self.Set_2_Plus_Btn.clicked.connect(partial(self.Add_Set, 2)) + SET_A_LYT.addWidget(self.Set_2_Plus_Btn) + + + + + ##______________________________________________________________/ UNDER LAYOUT + SET_A_UNDER_LYT = QtWidgets.QHBoxLayout() + SET_A_UNDER_LYT.setSpacing(10) + SECTION_SETS_LAYOUT.addLayout(SET_A_UNDER_LYT) + SET_A_UNDER_LYT.addSpacing(38) + + ##----------------------------------------------------------------- DEL + self.Set_A_1_Del_btn = QtWidgets.QPushButton() + self.Set_A_1_Del_btn.setFixedSize(20, 14) + self.Set_A_1_Del_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_A_1_Del_btn.setIcon(QtGui.QIcon(IconPath + "setDel.png")) + self.Set_A_1_Del_btn.clicked.connect(partial(self.Del_Set, 1)) + SET_A_UNDER_LYT.addWidget(self.Set_A_1_Del_btn) + if mc.objExists("ModIt_Set_1"): + self.Set_A_1_Del_btn.setEnabled(1) + else: + self.Set_A_1_Del_btn.setEnabled(0) + + + + ##----------------------------------------------------------------- GET + self.Set_A_1_Get_btn = QtWidgets.QPushButton() + self.Set_A_1_Get_btn.setFixedSize(20, 14) + self.Set_A_1_Get_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_A_1_Get_btn.setIcon(QtGui.QIcon(IconPath + "setGet.png")) + self.Set_A_1_Get_btn.clicked.connect(partial(self.Get_Set, 1)) + SET_A_UNDER_LYT.addWidget(self.Set_A_1_Get_btn) + if mc.objExists("ModIt_Set_1"): + self.Set_A_1_Get_btn.setEnabled(1) + else: + self.Set_A_1_Get_btn.setEnabled(0) + + + SET_A_UNDER_LYT.addSpacing(106) + + ##----------------------------------------------------------------- DEL + self.Set_A_2_Del_btn = QtWidgets.QPushButton() + self.Set_A_2_Del_btn.setFixedSize(20, 14) + self.Set_A_2_Del_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_A_2_Del_btn.setIcon(QtGui.QIcon(IconPath + "setDel.png")) + self.Set_A_2_Del_btn.clicked.connect(partial(self.Del_Set, 2)) + SET_A_UNDER_LYT.addWidget(self.Set_A_2_Del_btn) + if mc.objExists("ModIt_Set_2"): + self.Set_A_2_Del_btn.setEnabled(1) + else: + self.Set_A_2_Del_btn.setEnabled(0) + + + ##----------------------------------------------------------------- GET + self.Set_A_2_Get_btn = QtWidgets.QPushButton() + self.Set_A_2_Get_btn.setFixedSize(20, 14) + self.Set_A_2_Get_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_A_2_Get_btn.setIcon(QtGui.QIcon(IconPath + "setGet.png")) + self.Set_A_2_Get_btn.clicked.connect(partial(self.Get_Set, 2)) + SET_A_UNDER_LYT.addWidget(self.Set_A_2_Get_btn) + if mc.objExists("ModIt_Set_2"): + self.Set_A_2_Get_btn.setEnabled(1) + else: + self.Set_A_2_Get_btn.setEnabled(0) + + + + SECTION_SETS_LAYOUT.addSpacing(4) + + + + ##--------------------------------------- SET - LIGNE 2 + SET_B_LYT = QtWidgets.QHBoxLayout() + SET_B_LYT.setSpacing(7) + SECTION_SETS_LAYOUT.addLayout(SET_B_LYT) + SECTION_SETS_LAYOUT.setSpacing(0) + + ##----------------------------------------------------------------- - + self.Set_3_Min_Btn = QtWidgets.QPushButton() + self.Set_3_Min_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set_3_Min_Btn.setIconSize(QtCore.QSize(18, 18)) + self.Set_3_Min_Btn.setIcon(QtGui.QIcon(IconPath + "Moins.png")) + self.Set_3_Min_Btn.clicked.connect(partial(self.Sub_Set, 3)) + SET_B_LYT.addWidget(self.Set_3_Min_Btn) + + ##----------------------------------------------------------------------------------------------------------------------------------------- STORE SET 1 + self.Set_3_Store_Btn = QtWidgets.QPushButton() + self.Set_3_Store_Btn.setFixedSize(SetBoutonWidht, 20) + self.Set_3_Store_Btn.setObjectName("StoreSet") + self.Set_3_Store_Btn.setText("S E T - 3") + if WIN_DISPLAY_SIZE == 1: #150% + self.Set_3_Store_Btn.setFont(QtGui.QFont('Calibri', 6)) + self.Set_3_Store_Btn.clicked.connect(partial(self.Store_Set, 3)) + SET_B_LYT.addWidget(self.Set_3_Store_Btn) + + ##----------------------------------------------------------------- + + self.Set_3_Plus_Btn = QtWidgets.QPushButton() + self.Set_3_Plus_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set_3_Plus_Btn.setIconSize(QtCore.QSize(setBtnIconSize, setBtnIconSize)) + self.Set_3_Plus_Btn.setIcon(QtGui.QIcon(IconPath + "Plus.png")) + self.Set_3_Plus_Btn.clicked.connect(partial(self.Add_Set, 3)) + SET_B_LYT.addWidget(self.Set_3_Plus_Btn) + + + + + ##----------------------------------------------------------------- INTERSECT + SET_B_LYT.addSpacing(2) + self.Set_Int_Min_Btn = QtWidgets.QPushButton() + self.Set_Int_Min_Btn.setFixedSize(20, 20) + self.Set_Int_Min_Btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_Int_Min_Btn.setIcon(QtGui.QIcon(IconPath + "setIntersect.png")) + self.Set_Int_Min_Btn.setToolTip(" Get Components that are both on Set-3 and Set-4 ") + self.Set_Int_Min_Btn.clicked.connect(self.BoolIntersect_Set) + SET_B_LYT.addWidget(self.Set_Int_Min_Btn) + SET_B_LYT.addSpacing(3) + + + + + ##----------------------------------------------------------------- - + self.Set__Min_Btn = QtWidgets.QPushButton() + self.Set__Min_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set__Min_Btn.setIconSize(QtCore.QSize(setBtnIconSize, setBtnIconSize)) + self.Set__Min_Btn.setIcon(QtGui.QIcon(IconPath + "Moins.png")) + self.Set__Min_Btn.clicked.connect(partial(self.Sub_Set, 4)) + SET_B_LYT.addWidget(self.Set__Min_Btn) + + ##----------------------------------------------------------------- STORE SET 2 + self.Set__Store_Btn = QtWidgets.QPushButton() + self.Set__Store_Btn.setFixedSize(SetBoutonWidht, 20) + self.Set__Store_Btn.setObjectName("StoreSet") + self.Set__Store_Btn.setText("S E T - 4") + if WIN_DISPLAY_SIZE == 1: # 150% + self.Set__Store_Btn.setFont(QtGui.QFont('Calibri', 6)) + self.Set__Store_Btn.clicked.connect(partial(self.Store_Set, 4)) + SET_B_LYT.addWidget(self.Set__Store_Btn) + + ##----------------------------------------------------------------- + + self.Set__Plus_Btn = QtWidgets.QPushButton() + self.Set__Plus_Btn.setFixedSize(setBtnClickZone, setBtnClickZone) + self.Set__Plus_Btn.setIconSize(QtCore.QSize(setBtnIconSize, setBtnIconSize)) + self.Set__Plus_Btn.setIcon(QtGui.QIcon(IconPath + "Plus.png")) + self.Set__Plus_Btn.clicked.connect(partial(self.Add_Set, 4)) + SET_B_LYT.addWidget(self.Set__Plus_Btn) + + + ##______________________________________________________________/ UNDER LAYOUT + SET_B_UNDER_LYT = QtWidgets.QHBoxLayout() + SET_B_UNDER_LYT.setSpacing(10) + SECTION_SETS_LAYOUT.addLayout(SET_B_UNDER_LYT) + SET_B_UNDER_LYT.addSpacing(38) + + ##----------------------------------------------------------------- DEL + self.Set_B_1_Del_btn = QtWidgets.QPushButton() + self.Set_B_1_Del_btn.setFixedSize(20, 14) + self.Set_B_1_Del_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_B_1_Del_btn.setIcon(QtGui.QIcon(IconPath + "setDel.png")) + self.Set_B_1_Del_btn.clicked.connect(partial(self.Del_Set, 3)) + SET_B_UNDER_LYT.addWidget(self.Set_B_1_Del_btn) + if mc.objExists("ModIt_Set_3"): + self.Set_B_1_Del_btn.setEnabled(1) + else: + self.Set_B_1_Del_btn.setEnabled(0) + + + ##----------------------------------------------------------------- GET + self.Set_B_1_Get_btn = QtWidgets.QPushButton() + self.Set_B_1_Get_btn.setFixedSize(20, 14) + self.Set_B_1_Get_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_B_1_Get_btn.setIcon(QtGui.QIcon(IconPath + "setGet.png")) + self.Set_B_1_Get_btn.clicked.connect(partial(self.Get_Set, 3)) + SET_B_UNDER_LYT.addWidget(self.Set_B_1_Get_btn) + if mc.objExists("ModIt_Set_3"): + self.Set_B_1_Get_btn.setEnabled(1) + else: + self.Set_B_1_Get_btn.setEnabled(0) + + SET_B_UNDER_LYT.addSpacing(106) + + ##----------------------------------------------------------------- DEL + self.Set_B_2_Del_btn = QtWidgets.QPushButton() + self.Set_B_2_Del_btn.setFixedSize(20, 14) + self.Set_B_2_Del_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_B_2_Del_btn.setIcon(QtGui.QIcon(IconPath + "setDel.png")) + self.Set_B_2_Del_btn.clicked.connect(partial(self.Del_Set, 4)) + SET_B_UNDER_LYT.addWidget(self.Set_B_2_Del_btn) + if mc.objExists("ModIt_Set_4"): + self.Set_B_2_Del_btn.setEnabled(1) + else: + self.Set_B_2_Del_btn.setEnabled(0) + + + ##----------------------------------------------------------------- GET + self.Set_B_2_Get_btn = QtWidgets.QPushButton() + self.Set_B_2_Get_btn.setFixedSize(20, 14) + self.Set_B_2_Get_btn.setIconSize(QtCore.QSize(20, 20)) + self.Set_B_2_Get_btn.setIcon(QtGui.QIcon(IconPath + "setGet.png")) + self.Set_B_2_Get_btn.clicked.connect(partial(self.Get_Set, 4)) + SET_B_UNDER_LYT.addWidget(self.Set_B_2_Get_btn) + if mc.objExists("ModIt_Set_4"): + self.Set_B_2_Get_btn.setEnabled(1) + else: + self.Set_B_2_Get_btn.setEnabled(0) + + + + + self.ColorGreyBtn = MyCustomBtn_Widget() + self.ColorGreyBtn.setFixedSize(iconFixeSize, iconFixeSize) + self.ColorGreyBtn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ColorGreyBtn.setIcon(QtGui.QIcon(IconPath + "ColorLambert.png")) + self.ColorGreyBtn.clicked.connect(self.Action) + # C O N T E X T M E N U + self.ColorGreyBtn.customContextMenuRequested.connect(self.showPopup_Lambert) + self.popupMenuGrey = QtWidgets.QMenu() + ColorGreyMenu_Entry_Select = self.popupMenuGrey.addAction("Select") + ColorGreyMenu_Entry_Select.triggered.connect(self.Action) + #ColorGreyMenu_Entry_Attributes.triggered.connect(self.AttributLambert) + + + if DOCK == 0: + SET_A_LYT.addStretch() + SET_B_LYT.addStretch() + SET_A_UNDER_LYT.addStretch() + SET_B_UNDER_LYT.addStretch() + SECTION_SETS_LAYOUT.addStretch() + + + + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + + def Action(self): + pass + + + def Store_Set(self, number): + if mc.objExists('ModIt_Set_' + str(number)): + mc.sets(add='ModIt_Set_' + str(number)) + else: + createNewSet = mc.sets(n= 'ModIt_Set_' + str(number)) + + if number == 1: + self.Set_A_1_Get_btn.setEnabled(1) + self.Set_A_1_Del_btn.setEnabled(1) + elif number == 2: + self.Set_A_2_Get_btn.setEnabled(1) + self.Set_A_2_Del_btn.setEnabled(1) + elif number == 3: + self.Set_B_1_Get_btn.setEnabled(1) + self.Set_B_1_Del_btn.setEnabled(1) + elif number == 4: + self.Set_B_2_Get_btn.setEnabled(1) + self.Set_B_2_Del_btn.setEnabled(1) + + + def Add_Set(self, number): + try: + mc.sets(add='ModIt_Set_' + str(number)) + + except: + print("ModIt Error : Create a set first") + + def Sub_Set(self, number): + try: + mc.sets(rm='ModIt_Set_' + str(number)) + except: + print("ModIt Error : Create a set first") + + + def Del_Set(self, number): + try: + mc.delete('ModIt_Set_' + str(number)) + except: + print("ModIt Error : Create a set first") + + if number == 1: + self.Set_A_1_Get_btn.setEnabled(0) + self.Set_A_1_Del_btn.setEnabled(0) + elif number == 2: + self.Set_A_2_Get_btn.setEnabled(0) + self.Set_A_2_Del_btn.setEnabled(0) + elif number == 3: + self.Set_B_1_Get_btn.setEnabled(0) + self.Set_B_1_Del_btn.setEnabled(0) + elif number == 4: + self.Set_B_2_Get_btn.setEnabled(0) + self.Set_B_2_Del_btn.setEnabled(0) + + def Get_Set(self, number): + try: + mc.select('ModIt_Set_' + str(number)) + + #obSelName = str(objSel[0]) + #mel.eval('doMenuComponentSelectionExt(" ' + obSelName + '", "edge", 0);') + except: + print("ModIt Error : Create a set first") + + + def DelIntersect_Set(self): + try: + mc.delete('ModIt_Set_A') + mc.delete('ModIt_Set_B') + except: + print("ModIt Error : Create a set first") + + def BoolIntersect_Set(self): + if mc.objExists('ModIt_Set_3'): + if mc.objExists('ModIt_Set_4'): + mc.select(mc.sets( 'ModIt_Set_3', intersection = "ModIt_Set_4")) + else: + ModIt_Global.WarningWindow("ModIt Warning : You should store Set-3 and Set-4 first.", 350) + return + else: + ModIt_Global.WarningWindow("ModIt Warning : You should store Set-3 and Set-4 first.", 350) + return + + + def showPopup_Lambert(self, position): + self.popupMenuGrey.exec_(self.ColorGreyBtn.mapToGlobal(position)) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/Section_TOOLS.py b/Scripts/Modeling/Edit/ModIt/Modeling/Section_TOOLS.py new file mode 100644 index 0000000..b168703 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/Section_TOOLS.py @@ -0,0 +1,792 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget +from maya import OpenMayaUI as omui +from PySide2.QtCore import Qt +from PySide2.QtGui import * +from PySide2.QtWidgets import * +from shiboken2 import wrapInstance + + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + +from ..Tools import ModIt_Bend_UI +from ..Tools import ModIt_DupLinear_UI +from ..Tools import ModIt_DupRadial_UI +from ..Tools import ModIt_DupCurve_UI + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath +RessourcePath = ModIt_Global.RessourcePath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 30 +iconButtonSize = 30 +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA + + + +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + + +class TOOLS_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + SECTION_TOOLS_LAYOUT = QtWidgets.QHBoxLayout() # MAIN + SECTION_TOOLS_LAYOUT.setContentsMargins(10,0,0,10) + SECTION_TOOLS_LAYOUT.setSpacing(0) + self.setLayout(SECTION_TOOLS_LAYOUT) + + ##---------------------------------------------------- DUP LINEAR + self.DupLinear_btn = MyCustomBtn_Widget() + self.DupLinear_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.DupLinear_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.DupLinear_btn.setIcon(QtGui.QIcon(IconPath + "Dup_Offset.png")) + self.DupLinear_btn.setToolTip(" Duplicate Linear ") + self.DupLinear_btn.clicked.connect(self.DupLinear) + SECTION_TOOLS_LAYOUT.addWidget(self.DupLinear_btn) + + + ##---------------------------------------------------- DUP RADIAL + self.DupRadial_btn = MyCustomBtn_Widget() + self.DupRadial_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.DupRadial_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.DupRadial_btn.setIcon(QtGui.QIcon(IconPath + "Dup_Radial.png")) + self.DupRadial_btn.setToolTip(" Duplicate Radial ") + self.DupRadial_btn.clicked.connect(self.DupRadia) + SECTION_TOOLS_LAYOUT.addWidget(self.DupRadial_btn) + + + ##---------------------------------------------------- DUP CURVE + self.DupCurv_btn = MyCustomBtn_Widget() + self.DupCurv_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.DupCurv_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.DupCurv_btn.setIcon(QtGui.QIcon(IconPath + "Dup_Curve.png")) + self.DupCurv_btn.setToolTip(" Duplicate on CURVE : Select Mesh first and Curve then ") + self.DupCurv_btn.clicked.connect(self.DupCurve) + SECTION_TOOLS_LAYOUT.addWidget(self.DupCurv_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.DupCurv_btn.customContextMenuRequested.connect(self.showPopupCurve) + # CUBE M E N U I T E M S + self.popupMenuCurve = QtWidgets.QMenu() + Curve_Entry_1 = self.popupMenuCurve.addAction("Bezier Tool") + Curve_Entry_1.triggered.connect(self.Bezier) + Curve_Entry_2 = self.popupMenuCurve.addAction("EPCurve Tool") + Curve_Entry_2.triggered.connect(self.EPCurve) + Curve_Entry_3 = self.popupMenuCurve.addAction("Pencil Curve Tool") + Curve_Entry_3.triggered.connect(self.Pencil) + Curve_Entry_sep = self.popupMenuCurve.addAction(" ---------------- ") + Curve_Entry_4 = self.popupMenuCurve.addAction(" Classic Chain Sample Mesh") + Curve_Entry_4.triggered.connect(self.ChainA) + Curve_Entry_5 = self.popupMenuCurve.addAction(" Classic Link Sample Mesh") + Curve_Entry_5.triggered.connect(self.ChainB) + Curve_Entry_6 = self.popupMenuCurve.addAction(" Transmission Chain Sample Mesh") + Curve_Entry_6.triggered.connect(self.ChainC) + + + + + ##-------------------------------------------------------------------------------------------------------- + + SECTION_TOOLS_LAYOUT.addSpacing(4) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,30) + self.Separator.setStyleSheet("background-color:#434343;") + SECTION_TOOLS_LAYOUT.addWidget(self.Separator) + SECTION_TOOLS_LAYOUT.addSpacing(4) + ##-------------------------------------------------------------------------------------------------------- + + + + ##---------------------------------------------------- BEND + self.Bend_btn = QtWidgets.QPushButton() + self.Bend_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.Bend_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.Bend_btn.setIcon(QtGui.QIcon(IconPath + "Deform_Bend.png")) + self.Bend_btn.setToolTip(" Bend Deformer ") + self.Bend_btn.clicked.connect(self.BendTool) + SECTION_TOOLS_LAYOUT.addWidget(self.Bend_btn) + + ##---------------------------------------------------- LATTICE + self.Lattice_btn = MyCustomBtn_Widget() + self.Lattice_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.Lattice_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.Lattice_btn.setIcon(QtGui.QIcon(IconPath + "Deform_Lattice.png")) + self.Lattice_btn.setToolTip(" Lattice Deformer ") + self.Lattice_btn.clicked.connect(partial(self.LatticeTool, 2)) + SECTION_TOOLS_LAYOUT.addWidget(self.Lattice_btn) + + + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.Lattice_btn.customContextMenuRequested.connect(self.showPopupLattice) + # CUBE M E N U I T E M S + self.popupMenuLattice = QtWidgets.QMenu() + Angle_Entry_1 = self.popupMenuLattice.addAction("Lattice Div 3") + Angle_Entry_1.triggered.connect(partial(self.LatticeTool, 3)) + Angle_Entry_2 = self.popupMenuLattice.addAction("Lattice Div 4") + Angle_Entry_2.triggered.connect(partial(self.LatticeTool, 4)) + Angle_Entry_3 = self.popupMenuLattice.addAction("Lattice Div 5") + Angle_Entry_3.triggered.connect(partial(self.LatticeTool, 5)) + Angle_Entry_4 = self.popupMenuLattice.addAction("Lattice Div 6") + Angle_Entry_4.triggered.connect(partial(self.LatticeTool, 6)) + Angle_Entry_5 = self.popupMenuLattice.addAction(" ---------------- ") + Angle_Entry_6 = self.popupMenuLattice.addAction("Reset Lattice (Selected)") + Angle_Entry_6.triggered.connect(mc.RemoveLatticeTweaks) + + + ##-------------------------------------------------------------------------------------------------------- + + SECTION_TOOLS_LAYOUT.addSpacing(4) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,30) + self.Separator.setStyleSheet("background-color:#434343;") + SECTION_TOOLS_LAYOUT.addWidget(self.Separator) + SECTION_TOOLS_LAYOUT.addSpacing(4) + ##-------------------------------------------------------------------------------------------------------- + + + + ##---------------------------------------------------- FULLSCREEN ON + self.FullScreenOn_btn = QtWidgets.QPushButton() + self.FullScreenOn_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.FullScreenOn_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.FullScreenOn_btn.setIcon(QtGui.QIcon(IconPath + "FullScreen_On.png")) + self.FullScreenOn_btn.setToolTip(" Maya Full Screen Enter ") + self.FullScreenOn_btn.clicked.connect(self.FullScreenOn) + SECTION_TOOLS_LAYOUT.addWidget(self.FullScreenOn_btn) + + ##---------------------------------------------------- FULLSCREEN OFF + self.FullScreenOff_btn = QtWidgets.QPushButton() + self.FullScreenOff_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.FullScreenOff_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.FullScreenOff_btn.setIcon(QtGui.QIcon(IconPath + "FullScreen_Off.png")) + self.FullScreenOff_btn.setToolTip(" Maya Full Screen Exit ") + self.FullScreenOff_btn.clicked.connect(self.FullScreenOff) + SECTION_TOOLS_LAYOUT.addWidget(self.FullScreenOff_btn) + + + + + + #SECTION_TOOLS_LAYOUT.addSpacing(4) + #self.Separator = QtWidgets.QLabel() + #self.Separator.setFixedSize(1,30) + #self.Separator.setStyleSheet("background-color:#434343;") + #SECTION_TOOLS_LAYOUT.addWidget(self.Separator) + #SECTION_TOOLS_LAYOUT.addSpacing(4) + + + ##---------------------------------------------------- SELECT INNER + SELECTION + #self.Welder_btn = QtWidgets.QPushButton() + #self.Welder_btn.setFixedSize(iconFixeSize, iconFixeSize) + #self.Welder_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + #self.Welder_btn.setIcon(QtGui.QIcon(IconPath + "Welder_Paint.png")) + #self.Welder_btn.setToolTip(" Select Inner Faces and Keep Selection ") + #self.Welder_btn.clicked.connect(self.BAM) + #SECTION_TOOLS_LAYOUT.addWidget(self.Welder_btn) + + + + + + + + + ##---------------------------------------------------- Add to Layout + + + + + + + + + + + + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + #------------------------------------------------ + def BAM(self): + print("BAMMM") + + def showPopupLattice(self, position): + self.popupMenuLattice.exec_(self.Lattice_btn.mapToGlobal(position)) + self.Lattice_btn.update() + + def showPopupCurve(self, position): + self.popupMenuCurve.exec_(self.DupCurv_btn.mapToGlobal(position)) + self.DupCurv_btn.update() + + + def BendTool(self): + objectName = mc.ls(sl=True, l=True) + + mc.Bend() + + # 1 - GET ALL BEVEL NODE + typ = "nonLinear" + nodes = [] + for obj in objectName: + for node in cmds.listHistory(obj): + if cmds.nodeType(node) == typ: + nodes.append(node) + Bend_node = nodes[0] + + mc.setAttr(str(Bend_node) + ".highBound", 2) + mc.setAttr(str(Bend_node) + ".lowBound", -2) + + # ------------------------------------------------ + + # Pour eviter la boucle infinie avec le atClose qui clean la THumbScene + if mc.window("Bend", exists=True): + mc.deleteUI("Bend") + + importlib.reload(ModIt_Bend_UI) + ModIt_Bend_UI.SEND_INFO(str(Bend_node), str(objectName)) + ModIt_Bend_UI.showUI() + + def LatticeTool(self, number): + objectName = mc.ls(sl=True, l=True) + + if objectName == []: + print("Warning : Nothing Selected") + return + else: + mc.CreateLattice() + theLatice = mc.ls(sl=True)[0] + mc.setAttr(str(theLatice) + "Shape.sDivisions", number) + mc.setAttr(str(theLatice) + "Shape.tDivisions", number) + mc.setAttr(str(theLatice) + "Shape.uDivisions", number) + + + def DupLinear(self): + LOCATOR_SIZE = (json.load(open(PreferencePath + 'Locator_Size.json', "r"))['VALUE']) + + import MASH.api as mapi + MeshSel = mc.ls(sl=True, fl=True, dag=True, hd=1) + mc.undoInfo(openChunk=True, infinity=True) + sel = mc.ls(sl=True) + if sel == []: + ModIt_Global.WarningWindow("You should select Mesh or Group with Meshes.", 300) + return + + try: # MODE EDIT + getName = sel[0].split("_") + if getName[1] == "Linear": + print("Edit Linear Mode") + import re + versionNum = re.findall(r'\d+', sel[0])[0] + print(versionNum) + + # Pour eviter la boucle infinie avec le atClose qui clean la THumbScene + if mc.window("Linear Duplication", exists=True): + mc.deleteUI("Linear Duplication") + + importlib.reload(ModIt_DupLinear_UI) + ModIt_DupLinear_UI.SEND_INFO(str(versionNum)) + ModIt_DupLinear_UI.showUI() + + + + + + except: # MODE CREATE NEW + ## 1 - VERIF + #That it well mesh or Group + sel = mc.ls(sl=True) + descendants = set(mc.ls(mc.listRelatives(sel, ad=True) or [], type='shape')) + mesh_descendants = set(mc.ls(descendants, type='mesh')) + is_valid = (descendants == mesh_descendants) + if is_valid == False : + ModIt_Global.WarningWindow("You should select Mesh or Group with Meshes only.", 300) + return + + #MASH is loaded + try: + mc.loadPlugin("MASH") + except: + pass + + try: + mc.parent(MeshSel, world=True) + except: + pass + + mc.FreezeTransformations() + mc.CenterPivot() + posSaveLocator = mc.spaceLocator(p=[0, 0, 0], n="ModIt_PosSave_Loc") + mc.select(posSaveLocator, MeshSel) + mc.MatchTranslation() + mc.move(0, 0, 0, MeshSel, rpr=True) + mc.makeIdentity(MeshSel, apply=True) + + + + #Origin Locator for NumName + orignLocator = mc.spaceLocator(p=[0, 0, 0], n="ModIt_Linear_OrignLoc1") + mc.setAttr(orignLocator[0] + ".localScaleX", LOCATOR_SIZE) + mc.setAttr(orignLocator[0] + ".localScaleY", LOCATOR_SIZE) + mc.setAttr(orignLocator[0] + ".localScaleZ", LOCATOR_SIZE) + mc.setAttr(orignLocator[0] + "Shape.overrideEnabled", 1) + mc.setAttr(orignLocator[0] + "Shape.overrideRGBColors", 1) + mc.setAttr(orignLocator[0] + "Shape.overrideColorRGB", 1, 0.192, 0) + + #Get num + import re + num = re.findall(r'\d+', orignLocator[0])[0] + + + + # Create a Locator, place it to mesh location and grab is name in case of name conflict to be sure to rename the MASH sysmte like him. + myLocator = mc.spaceLocator(p=[0, 0, 0], n="ModIt_Linear_Loc" + str(num)) + mc.setAttr(myLocator[0] + ".localScaleX", LOCATOR_SIZE) + mc.setAttr(myLocator[0] + ".localScaleY", LOCATOR_SIZE) + mc.setAttr(myLocator[0] + ".localScaleZ", LOCATOR_SIZE) + mc.setAttr(myLocator[0] + "Shape.overrideEnabled", 1) + mc.setAttr(myLocator[0] + "Shape.overrideRGBColors", 1) + mc.setAttr(myLocator[0] + "Shape.overrideColorRGB", 0.01, 0.461, 1.00) + + # GET Locator Number + myLocatorName = mc.ls(sl=True) + + + mc.select(myLocatorName, MeshSel) + mc.MatchTranslation() + mc.FreezeTransformations() + mc.select(MeshSel) + + # Create a new MASH network + mashNetwork = mapi.Network() + MashDistribute = mashNetwork.createNetwork(name="ModIt_Duplicate" + str(num), geometry="Instancer") + mc.setAttr("ModIt_Duplicate" + str(num) + "_Distribute.arrangement", 1) # set Linear Mode + MashInstancer = "ModIt_Duplicate" + str(num) + "_Instancer" + createRandomNode = mashNetwork.addNode("MASH_Random") + mc.setAttr("ModIt_Duplicate" + str(num) + "_Random.absoluteScale", 0) + mc.setAttr("ModIt_Duplicate" + str(num) + "_Random.positionX", 0) + mc.setAttr("ModIt_Duplicate" + str(num) + "_Random.positionY", 0) + mc.setAttr("ModIt_Duplicate" + str(num) + "_Random.positionZ", 0) + + + + + + + + # Place at selObj Pos + mc.parent(myLocatorName, MashInstancer) + mc.select(MashInstancer, posSaveLocator) + mc.MatchTranslation() + mc.delete(posSaveLocator) + + # Origin Locator Set + mc.select(orignLocator, MashInstancer) + mc.MatchTranslation() + mc.parent(MashInstancer, orignLocator) + + # Link Locator + mc.setAttr(myLocatorName[0] + ".translateX", 20) + mc.expression(s='ModIt_Duplicate' + str(num) + '_Distribute.amplitudeX = ' + myLocatorName[0] + ".translateX") + mc.expression(s='ModIt_Duplicate' + str(num) + '_Distribute.amplitudeY = ' + myLocatorName[0] + ".translateY") + mc.expression(s='ModIt_Duplicate' + str(num) + '_Distribute.amplitudeZ = ' + myLocatorName[0] + ".translateZ") + + # Rename OrignObj to found it later + mc.rename(MeshSel, "ModIt_Linear_" + str(num) + "_Mesh") + + mc.select(myLocatorName) + + # Pour eviter la boucle infinie avec le atClose qui clean la THumbScene + if mc.window("Linear Duplication", exists=True): + mc.deleteUI("Linear Duplication") + + importlib.reload(ModIt_DupLinear_UI) + ModIt_DupLinear_UI.SEND_INFO(str(num)) + ModIt_DupLinear_UI.showUI() + + mc.undoInfo(closeChunk=True) + + def DupRadia(self): + LOCATOR_SIZE = (json.load(open(PreferencePath + 'Locator_Size.json', "r"))['VALUE']) + + + import MASH.api as mapi + MeshSel = mc.ls(sl=True, fl=True, dag=True, hd=1) + mc.undoInfo(openChunk=True, infinity=True) + sel = mc.ls(sl=True) + if sel == []: + ModIt_Global.WarningWindow("You should select Mesh or Group with Meshes.", 300) + return + + try: # MODE EDIT + getName = sel[0].split("_") + if getName[1] == "Radial": + print("Edit Radial Mode") + import re + versionNum = re.findall(r'\d+', sel[0])[0] + print(versionNum) + + # Pour eviter la boucle infinie avec le atClose qui clean la THumbScene + if mc.window("Radial Duplication", exists=True): + mc.deleteUI("Radial Duplication") + + importlib.reload(ModIt_DupRadial_UI) + ModIt_DupRadial_UI.SEND_INFO(str(versionNum)) + ModIt_DupRadial_UI.showUI() + + + + + + except: # MODE CREATE NEW + ## 1 - VERIF + #That it well mesh or Group + sel = mc.ls(sl=True) + descendants = set(mc.ls(mc.listRelatives(sel, ad=True) or [], type='shape')) + mesh_descendants = set(mc.ls(descendants, type='mesh')) + is_valid = (descendants == mesh_descendants) + if is_valid == False : + ModIt_Global.WarningWindow("You should select Mesh or Group with Meshes only.", 300) + return + + #MASH is loaded + try: + mc.loadPlugin("MASH") + except: + pass + + + + try: + mc.parent(MeshSel, world=True) + except: + pass + + mc.FreezeTransformations() + mc.CenterPivot() + posSaveLocator = mc.spaceLocator(p=[0, 0, 0], n="ModIt_PosSave_Loc") + mc.select(posSaveLocator, MeshSel) + mc.MatchTranslation() + mc.move(0, 0, 0, MeshSel, rpr=True) + mc.makeIdentity(MeshSel, apply=True) + + + + #Origin Locator for NumName + orignLocator = mc.spaceLocator(p=[0, 0, 0], n="ModIt_Radial_OrignLoc1") + mc.setAttr(orignLocator[0] + ".localScaleX", LOCATOR_SIZE) + mc.setAttr(orignLocator[0] + ".localScaleY", LOCATOR_SIZE) + mc.setAttr(orignLocator[0] + ".localScaleZ", LOCATOR_SIZE) + mc.setAttr(orignLocator[0] + "Shape.overrideEnabled", 1) + mc.setAttr(orignLocator[0] + "Shape.overrideRGBColors", 1) + mc.setAttr(orignLocator[0] + "Shape.overrideColorRGB", 1, 0.192, 0) + + #Get num + import re + num = re.findall(r'\d+', orignLocator[0])[0] + + + # Create a Locator, place it to mesh location and grab is name in case of name conflict to be sure to rename the MASH sysmte like him. + myLocator = mc.spaceLocator(p=[0, 0, 0], n="ModIt_Radial_Loc" + str(num)) + mc.setAttr(myLocator[0] + ".localScaleX", LOCATOR_SIZE) + mc.setAttr(myLocator[0] + ".localScaleY", LOCATOR_SIZE) + mc.setAttr(myLocator[0] + ".localScaleZ", LOCATOR_SIZE) + mc.setAttr(myLocator[0] + "Shape.overrideEnabled", 1) + mc.setAttr(myLocator[0] + "Shape.overrideRGBColors", 1) + mc.setAttr(myLocator[0] + "Shape.overrideColorRGB", 0.01, 0.461, 1.00) + + # GET Locator Number + myLocatorName = mc.ls(sl=True) + + + mc.select(myLocatorName, MeshSel) + mc.MatchTranslation() + mc.FreezeTransformations() + mc.select(MeshSel) + + # Create a new MASH network + mashNetwork = mapi.Network() + MashDistribute = mashNetwork.createNetwork(name="ModIt_Duplicate_Radial" + str(num), geometry="Instancer") + mc.setAttr("ModIt_Duplicate_Radial" + str(num) + "_Distribute.arrangement", 2) #set RadialMode + MashInstancer = "ModIt_Duplicate_Radial" + str(num) + "_Instancer" + createRandomNode = mashNetwork.addNode("MASH_Random") + mc.setAttr("ModIt_Duplicate_Radial" + str(num) + "_Random.absoluteScale", 0) + mc.setAttr("ModIt_Duplicate_Radial" + str(num) + "_Random.positionX", 0) + mc.setAttr("ModIt_Duplicate_Radial" + str(num) + "_Random.positionY", 0) + mc.setAttr("ModIt_Duplicate_Radial" + str(num) + "_Random.positionZ", 0) + + + + + # Place at selObj Pos + mc.parent(myLocatorName, MashInstancer) + mc.select(MashInstancer, posSaveLocator) + mc.MatchTranslation() + mc.delete(posSaveLocator) + + # Origin Locator Set + mc.select(orignLocator, MashInstancer) + mc.MatchTranslation() + mc.parent(MashInstancer, orignLocator) + + # Link Locator + mc.setAttr(myLocatorName[0] + ".translateX", 10) + mc.expression(s='ModIt_Duplicate_Radial' + str(num) + '_Distribute.radialRadius = ' + myLocatorName[0] + ".translateX") + + + # Rename OrignObj to found it later + mc.rename(MeshSel, "ModIt_Radial_" + str(num) + "_Mesh") + + mc.select(myLocatorName) + + # Pour eviter la boucle infinie avec le atClose qui clean la THumbScene + if mc.window("Radial Duplication", exists=True): + mc.deleteUI("Radial Duplication") + + importlib.reload(ModIt_DupRadial_UI) + ModIt_DupRadial_UI.SEND_INFO(str(num)) + ModIt_DupRadial_UI.showUI() + + mc.undoInfo(closeChunk=True) + + def DupCurve(self): + import MASH.api as mapi + MeshSel = mc.ls(sl=True, fl=True, dag=True, hd=1) + CurveSelection = mc.ls(sl=True, fl=True, dag=True, tl=1, shapes=True) + + mc.undoInfo(openChunk=True, infinity=True) + + sel = mc.ls(sl=True) + if sel == []: #SI RIEN ERREUR + ModIt_Global.WarningWindow("You should select 1-Mesh and 2-Curve.", 300) + return + + if len(sel) == 1: #VERIF EDIT MODE + print("EditModeVerif") + + descendants = set(mc.ls(mc.listRelatives(sel, ad=True) or [], type='shape')) + bezier_descendants = set(mc.ls(descendants, type='bezierCurve')) + is_valid_bezier = (descendants == bezier_descendants) + + nurbsh_descendants = set(mc.ls(descendants, type='nurbsCurve')) + is_valid_nurbs = (descendants == nurbsh_descendants) + + if is_valid_bezier == False : + if is_valid_nurbs == False : + ModIt_Global.WarningWindow("You should select the Curve to edit mode.", 300) + return + else: + curveName = CurveSelection[0] + + if mc.window("Curve Duplication", exists=True): + mc.deleteUI("Curve Duplication") + + importlib.reload(ModIt_DupCurve_UI) + ModIt_DupCurve_UI.SEND_INFO(str(curveName)) + ModIt_DupCurve_UI.showUI() + + else: + curveName = CurveSelection[0] + + if mc.window("Curve Duplication", exists=True): + mc.deleteUI("Curve Duplication") + + importlib.reload(ModIt_DupCurve_UI) + ModIt_DupCurve_UI.SEND_INFO(str(curveName)) + ModIt_DupCurve_UI.showUI() + + + if len(sel) == 2: #VERIF CREATION MODE + if mc.nodeType(CurveSelection) == "nurbsCurve": + pass + else: + if mc.nodeType(CurveSelection) == "bezierCurve": + pass + else: + ModIt_Global.WarningWindow("You should select Mesh First and Curve in Second.", 300) + return + + + + + #MASH is loaded + try: + mc.loadPlugin("MASH") + except: + pass + + try: + mc.parent(MeshSel, world=True) + except: + pass + + mc.FreezeTransformations() + mc.CenterPivot() + mc.move(0, 0, 0, MeshSel, rpr=True) + mc.makeIdentity(MeshSel, apply=True) + + + + + + #Get num qui ici est le nom de la curve + num = CurveSelection[0] + + + mc.select(MeshSel) + + + + # Create a new MASH network + mashNetwork = mapi.Network() + MashDistribute = mashNetwork.createNetwork(name="ModIt_Duplicate_Curve" + str(num), geometry="Instancer") + mc.setAttr("ModIt_Duplicate_Curve" + str(num) + "_Distribute.arrangement", 8) #set CurveMode + MashInstancer = "ModIt_Duplicate_Curve" + str(num) + "_Instancer" + + # create a world node + curveNode = mashNetwork.addNode("MASH_Curve") + mc.connectAttr(CurveSelection[0] + ".worldSpace[0]", "ModIt_Duplicate_Curve" + str(num) + "_Curve" + ".inCurves[0]") + mc.setAttr("ModIt_Duplicate_Curve" + str(num) + "_Curve" + ".parametricLength", 1) + + # create a Random node + createRandomNode = mashNetwork.addNode("MASH_Random") + mc.setAttr("ModIt_Duplicate_Curve" + str(num) + "_Random.absoluteScale", 0) + mc.setAttr("ModIt_Duplicate_Curve" + str(num) + "_Random.positionX", 0) + mc.setAttr("ModIt_Duplicate_Curve" + str(num) + "_Random.positionY", 0) + mc.setAttr("ModIt_Duplicate_Curve" + str(num) + "_Random.positionZ", 0) + + + + + mc.select(CurveSelection) + + # Pour eviter la boucle infinie avec le atClose qui clean la THumbScene + if mc.window("Curve Duplication", exists=True): + mc.deleteUI("Curve Duplication") + + importlib.reload(ModIt_DupCurve_UI) + ModIt_DupCurve_UI.SEND_INFO(str(num)) + ModIt_DupCurve_UI.showUI() + + mc.undoInfo(closeChunk=True) + + + def Bezier(self): + mc.CreateBezierCurveTool() + + def EPCurve(self): + mc.EPCurveTool() + + def Pencil(self): + mc.PencilCurveTool() + + + def ChainA(self): + fileO = RessourcePath + "Mesh/Chain_A.ma" + mc.file(fileO, i=True) + + def ChainB(self): + fileO = RessourcePath + "Mesh/Chain_B.ma" + mc.file(fileO, i=True) + + def ChainC(self): + fileO = RessourcePath + "Mesh/Chain_C.ma" + mc.file(fileO, i=True) + + + + def FullScreenOn(self): + mainWindowPtr = omui.MQtUtil.mainWindow() + mainWindow = wrapInstance(int(mainWindowPtr), QMainWindow) + mainWindow.showFullScreen() + + def FullScreenOff(self): + mainWindowPtr = omui.MQtUtil.mainWindow() + mainWindow = wrapInstance(int(mainWindowPtr), QMainWindow) + mainWindow.showNormal() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Scripts/Modeling/Edit/ModIt/Modeling/Section_UTILITIES.py b/Scripts/Modeling/Edit/ModIt/Modeling/Section_UTILITIES.py new file mode 100644 index 0000000..488c233 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Modeling/Section_UTILITIES.py @@ -0,0 +1,227 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 32 +iconButtonSize = 32 +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA +PRIM_MODE =(json.load(open(PreferencePath + 'Setting_Primitives_Placement.json',"r"))['PRIM_MODE']) +PRIM_SIZE =(json.load(open(PreferencePath + 'Setting_Primitives_Size.json',"r"))['PRIM_SIZE']) + + +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + + #def enterEvent(self, event): + # print("ENTER EVENT") + #def leaveEvent(self, event): + # print("LEAVE EVENT") + + +class UTILITIES_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + SECTION_UTILITIES_LAYOUT = QtWidgets.QHBoxLayout() # MAIN + SECTION_UTILITIES_LAYOUT.setContentsMargins(10,0,0,10) + SECTION_UTILITIES_LAYOUT.setSpacing(0) + self.setLayout(SECTION_UTILITIES_LAYOUT) + + ##-------------------------------------------------------------------------------- HISTORY + self.DelHistory_btn = MyCustomBtn_Widget() + self.DelHistory_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.DelHistory_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.DelHistory_btn.setIcon(QtGui.QIcon(IconPath + "Util_Historique.png")) + self.DelHistory_btn.setToolTip(" Delete History on Selection ") + self.DelHistory_btn.clicked.connect(mc.DeleteHistory) + SECTION_UTILITIES_LAYOUT.addWidget(self.DelHistory_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.DelHistory_btn.customContextMenuRequested.connect(self.showPopup_DelHisto) + # CUBE M E N U I T E M S + self.popupMenu_DelHisto = QtWidgets.QMenu() + DelHisto_Entry_1 = self.popupMenu_DelHisto.addAction("Delete All") + DelHisto_Entry_1.triggered.connect(mc.DeleteAllHistory) + + + ##-------------------------------------------------------------------------------- FREEZE + self.FreezeTransform_btn = MyCustomBtn_Widget() + self.FreezeTransform_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.FreezeTransform_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.FreezeTransform_btn.setIcon(QtGui.QIcon(IconPath + "Util_FreezeT.png")) + self.FreezeTransform_btn.setToolTip(" Freeze Transformation on Selection ") + self.FreezeTransform_btn.clicked.connect(mc.FreezeTransformations) + SECTION_UTILITIES_LAYOUT.addWidget(self.FreezeTransform_btn) + + + ##-------------------------------------------------------------------------------- CENTER PIVOT + self.CenterPivot_btn = MyCustomBtn_Widget() + self.CenterPivot_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.CenterPivot_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.CenterPivot_btn.setIcon(QtGui.QIcon(IconPath + "Util_AlignPivot.png")) + self.CenterPivot_btn.setToolTip(" Center Pivot ") + self.CenterPivot_btn.clicked.connect(mc.CenterPivot) + SECTION_UTILITIES_LAYOUT.addWidget(self.CenterPivot_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.CenterPivot_btn.customContextMenuRequested.connect(self.showPopup_CenterPivot) + # CUBE M E N U I T E M S + self.popupMenu_CenterPivot = QtWidgets.QMenu() + CenterPivot_Entry_1 = self.popupMenu_CenterPivot.addAction("Center Pivot at Base") + CenterPivot_Entry_1.triggered.connect(self.PivotBottom) + CenterPivot_Entry_2 = self.popupMenu_CenterPivot.addAction("Center Pivot at Base and Grid") + CenterPivot_Entry_2.triggered.connect(self.PivotGrid) + + ##-------------------------------------------------------------------------------- OPTIMIZE + self.Optimize_btn = QtWidgets.QPushButton() + self.Optimize_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.Optimize_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.Optimize_btn.setIcon(QtGui.QIcon(IconPath + "Util_Optimize.png")) + self.Optimize_btn.setToolTip(" Optimize Scene ") + self.Optimize_btn.clicked.connect(mc.OptimizeScene) + SECTION_UTILITIES_LAYOUT.addWidget(self.Optimize_btn) + + ##-------------------------------------------------------------------------------- BTOA + self.BtoA_btn = MyCustomBtn_Widget() + self.BtoA_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.BtoA_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.BtoA_btn.setIcon(QtGui.QIcon(IconPath + "Util_BtoA.png")) + self.BtoA_btn.setToolTip(" Match Position and Rotation ") + self.BtoA_btn.clicked.connect(self.MatchPosRot) + SECTION_UTILITIES_LAYOUT.addWidget(self.BtoA_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.BtoA_btn.customContextMenuRequested.connect(self.showPopup_BtoA) + # CUBE M E N U I T E M S + self.popupMenu_BtoA = QtWidgets.QMenu() + BtoA_Entry_1 = self.popupMenu_BtoA.addAction("Match All Transforms") + BtoA_Entry_1.triggered.connect(mc.MatchTransform) + BtoA_Entry_2 = self.popupMenu_BtoA.addAction("Match Pivots") + BtoA_Entry_2.triggered.connect(mc.MatchPivots) + + + + SECTION_UTILITIES_LAYOUT.addSpacing(4) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,30) + self.Separator.setStyleSheet("background-color:#434343;") + SECTION_UTILITIES_LAYOUT.addWidget(self.Separator) + SECTION_UTILITIES_LAYOUT.addSpacing(4) + + + + ##-------------------------------------------------------------------------------- SHOW + self.DisplayShow_btn = QtWidgets.QPushButton() + self.DisplayShow_btn.setFixedSize(30, 30) + self.DisplayShow_btn.setIconSize(QtCore.QSize(30, 30)) + self.DisplayShow_btn.setIcon(QtGui.QIcon(IconPath + "Display_Show.png")) + self.DisplayShow_btn.setToolTip(" Show All Hidden Object ") + self.DisplayShow_btn.clicked.connect(mc.ShowAll) + SECTION_UTILITIES_LAYOUT.addWidget(self.DisplayShow_btn) + + + ##-------------------------------------------------------------------------------- HIDE + self.DisplayHide_btn = QtWidgets.QPushButton() + self.DisplayHide_btn.setFixedSize(30, 30) + self.DisplayHide_btn.setIconSize(QtCore.QSize(30, 30)) + self.DisplayHide_btn.setIcon(QtGui.QIcon(IconPath + "Display_Hide.png")) + self.DisplayHide_btn.setToolTip(" Hide Unselected Objects ") + self.DisplayHide_btn.clicked.connect(mc.HideUnselectedObjects) + SECTION_UTILITIES_LAYOUT.addWidget(self.DisplayHide_btn) + + + + + + + + + + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + #------------------------------------------------ MENU + def showPopup_CenterPivot(self, position): + self.popupMenu_CenterPivot.exec_(self.CenterPivot_btn.mapToGlobal(position)) + self.CenterPivot_btn.update() + + def showPopup_DelHisto(self, position): + self.popupMenu_DelHisto.exec_(self.DelHistory_btn.mapToGlobal(position)) + self.DelHistory_btn.update() + + def showPopup_BtoA(self, position): + self.popupMenu_BtoA.exec_(self.BtoA_btn.mapToGlobal(position)) + self.BtoA_btn.update() + + + + #------------------------------------------------ ACTIONS + + def BAM(self): + print("BAMMM") + + def PivotBottom(self): + sel = mc.ls(sl=True) + bbox = mc.exactWorldBoundingBox(sel) + bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2] + mc.xform(sel, piv=bottom, ws=True) + + def PivotGrid(self): + sel = mc.ls(sl=True) + bbox = mc.exactWorldBoundingBox(sel) + bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2] + mc.xform(sel, piv=bottom, ws=True) + mc.move(0, 0, 0, sel, rpr=True) + + + def MatchPosRot(self): + mc.undoInfo(openChunk=True, infinity=True) + mc.MatchTranslation() + mc.MatchRotation() + mc.undoInfo(closeChunk=True) + + + + + + diff --git a/Scripts/Modeling/Edit/ModIt/Placement/Layout_PLACEMENT.py b/Scripts/Modeling/Edit/ModIt/Placement/Layout_PLACEMENT.py new file mode 100644 index 0000000..a8fa1b4 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Placement/Layout_PLACEMENT.py @@ -0,0 +1,416 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +# import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + + + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath +RessourcePath = ModIt_Global.RessourcePath + + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 20 +iconButtonSize = 20 +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA +SCREW_MODE =(json.load(open(PreferencePath + 'Screw_Mode.json',"r"))['VALUE']) +SCREW_SIZE =(json.load(open(PreferencePath + 'MultiSize.json',"r"))['MULTISIZEVALUE']) + +WIN_DISPLAY_SIZE =(json.load(open(PreferencePath + 'WinSize.json',"r"))['VALUE']) + + +class PLACEMENT_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + SECTION_PLACEMENT_LAYOUT = QtWidgets.QVBoxLayout() # MAIN + self.setLayout(SECTION_PLACEMENT_LAYOUT) + SECTION_PLACEMENT_LAYOUT.setContentsMargins(0,0,0,0) + + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B M O D E L I N G + ###------------------------------------------------------------------------------------// SCREW + SCREW_Label = QtWidgets.QLabel(self) + SCREW_Label.setText(" - S C R E W / B O L T - ") + if WIN_DISPLAY_SIZE == 0: # 125 + SCREW_Label.setFont(QtGui.QFont('Candara', 8)) + else: + SCREW_Label.setFont(QtGui.QFont('Candara', 7)) + + SCREW_Label.setAlignment(QtCore.Qt.AlignCenter) + SECTION_PLACEMENT_LAYOUT.addWidget(SCREW_Label) + SECTION_PLACEMENT_LAYOUT.addSpacing(5) + + ###---------------------------------------------------- H LAYOUT + Parameters_Hlyt = QtWidgets.QHBoxLayout() + SECTION_PLACEMENT_LAYOUT.addLayout(Parameters_Hlyt) + + + + ###-------------------------------------------------------------------------------------------------- DRAG MODE + self.ImportDrag_btn = QtWidgets.QPushButton() + self.ImportDrag_btn.setObjectName("TABSBTN") + self.ImportDrag_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.ImportDrag_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ImportDrag_btn.clicked.connect(self.set_DragMode) + Parameters_Hlyt.addWidget(self.ImportDrag_btn) + + + ###-------------------------------------------------------------------------------------------------- FACE MODE + self.ImportComponent_btn = QtWidgets.QPushButton() + self.ImportComponent_btn.setObjectName("TABSBTN") + self.ImportComponent_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.ImportComponent_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ImportComponent_btn.clicked.connect(self.set_FaceMode) + Parameters_Hlyt.addWidget(self.ImportComponent_btn) + + if SCREW_MODE == 1: + self.ImportDrag_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Drag.png")) + self.ImportComponent_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Selection_OFF.png")) + else: + self.ImportDrag_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Drag_OFF.png")) + self.ImportComponent_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Selection.png")) + + + + + #####---------------------------------------------------- / SEPARATOR / + self.Separator = QtWidgets.QPushButton() + self.Separator.setFixedSize(separatorWidth,iconButtonSize) + self.Separator.setObjectName("Separator") + self.Separator.setIconSize(QtCore.QSize(26, iconButtonSize)) + self.Separator.setIcon(QtGui.QIcon(IconPath + "SeparatorBtn.png")) + self.Separator.setEnabled(0) + Parameters_Hlyt.addWidget(self.Separator) + + + + ###-------------------------------------------------------------------------------------------------- SIZE SLIDER + Size_Title = QtWidgets.QLabel("Size ") + Parameters_Hlyt.addWidget(Size_Title) + + self.Size_Slider = QtWidgets.QSlider() + self.Size_Slider.setMinimum(0.01) + self.Size_Slider.setMaximum(100) + self.Size_Slider.setProperty("value", SCREW_SIZE) + self.Size_Slider.setOrientation(QtCore.Qt.Horizontal) + self.Size_Slider.setTickPosition(QtWidgets.QSlider.TicksAbove) + self.Size_Slider.setTickInterval(1) + self.Size_Slider.setFixedHeight(22) + self.Size_Slider.valueChanged.connect(self.set_MultiSize_Slider) + Parameters_Hlyt.addWidget(self.Size_Slider) + + + self.Size_SpinBox = QtWidgets.QDoubleSpinBox() + self.Size_SpinBox.setDecimals(2) + self.Size_SpinBox.setFixedWidth(40) + self.Size_SpinBox.setFixedHeight(18) + self.Size_SpinBox.setRange(0.01, 1000) + self.Size_SpinBox.setValue(SCREW_SIZE) + self.Size_SpinBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons) + self.Size_SpinBox.editingFinished.connect(self.set_MultiSize_SpinBox) + Parameters_Hlyt.addWidget(self.Size_SpinBox) + + SECTION_PLACEMENT_LAYOUT.addSpacing(5) + + + ##---------------------------------------------------- Separator + SECTION_PLACEMENT_LAYOUT.addSpacing(3) + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #282828;}") + separator.setMaximumHeight(2) + SECTION_PLACEMENT_LAYOUT.addWidget(separator) + SECTION_PLACEMENT_LAYOUT.addSpacing(3) + + + + + ##-------------------------------------------------- + ##----------------------------------------------------------/ S C R E W / B O L T S + ##-------------------------------------------------- + separatorSpacingValue = 3 + + Screw_PNGList = [] + Bolt_PNGList = [] + Special_PNGList = [] + SciFi_PNGList = [] + + ##----------------------------------------------------------/ S C R E W + Screw_Base_path = RessourcePath + "Mesh/Screw" + listAllInFolder = os.listdir(Screw_Base_path) + + for each in listAllInFolder: + full_screw_filePath = Screw_Base_path + "/" + each + #Find and keep only .png files + if full_screw_filePath.endswith(".png"): + Screw_PNGList.append(full_screw_filePath) + + grid_Lyt = QtWidgets.QGridLayout() + SECTION_PLACEMENT_LAYOUT.addLayout(grid_Lyt) + + gridIconSize = 40 + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Screw_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Screw_PNGList.index(each)] + yPos = positions[Screw_PNGList.index(each)] + self.Asset_btn = QtWidgets.QPushButton() + self.Asset_btn.setFixedSize(gridIconSize, gridIconSize) + self.Asset_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.Asset_btn.setIcon(QtGui.QIcon(each)) + self.Asset_btn.clicked.connect(partial(self.set_Import, Asset_ma_path)) + grid_Lyt.addWidget(self.Asset_btn, xPos[0], yPos[1]) + + + ##---------------------------------------------------- Separator + SECTION_PLACEMENT_LAYOUT.addSpacing(separatorSpacingValue) + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #666; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + SECTION_PLACEMENT_LAYOUT.addWidget(separator) + SECTION_PLACEMENT_LAYOUT.addSpacing(separatorSpacingValue) + + ##----------------------------------------------------------/ B O L T S + Bolt_Base_path = RessourcePath + "Mesh/Bolt" + listAllInFolder = os.listdir(Bolt_Base_path) + + for each in listAllInFolder: + full_Bolt_filePath = Bolt_Base_path + "/" + each + #Find and keep only .png files + if full_Bolt_filePath.endswith(".png"): + Bolt_PNGList.append(full_Bolt_filePath) + + grid_Lyt = QtWidgets.QGridLayout() + SECTION_PLACEMENT_LAYOUT.addLayout(grid_Lyt) + + gridIconSize = 40 + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Bolt_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Bolt_PNGList.index(each)] + yPos = positions[Bolt_PNGList.index(each)] + self.Asset_btn = QtWidgets.QPushButton() + self.Asset_btn.setFixedSize(gridIconSize, gridIconSize) + self.Asset_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.Asset_btn.setIcon(QtGui.QIcon(each)) + self.Asset_btn.clicked.connect(partial(self.set_Import, Asset_ma_path)) + grid_Lyt.addWidget(self.Asset_btn, xPos[0], yPos[1]) + + ##---------------------------------------------------- Separator + SECTION_PLACEMENT_LAYOUT.addSpacing(separatorSpacingValue) + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #666; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + SECTION_PLACEMENT_LAYOUT.addWidget(separator) + SECTION_PLACEMENT_LAYOUT.addSpacing(separatorSpacingValue) + + + + ##----------------------------------------------------------/ S C I - F I + SciFi_Base_path = RessourcePath + "Mesh/SciFi" + listAllInFolder = os.listdir(SciFi_Base_path) + + for each in listAllInFolder: + full_SciFi_filePath = SciFi_Base_path + "/" + each + #Find and keep only .png files + if full_SciFi_filePath.endswith(".png"): + SciFi_PNGList.append(full_SciFi_filePath) + + grid_Lyt = QtWidgets.QGridLayout() + SECTION_PLACEMENT_LAYOUT.addLayout(grid_Lyt) + + gridIconSize = 40 + positions = [(x, y) for x in range(10) for y in range(6)] + for each in SciFi_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[SciFi_PNGList.index(each)] + yPos = positions[SciFi_PNGList.index(each)] + self.Asset_btn = QtWidgets.QPushButton() + self.Asset_btn.setFixedSize(gridIconSize, gridIconSize) + self.Asset_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.Asset_btn.setIcon(QtGui.QIcon(each)) + self.Asset_btn.clicked.connect(partial(self.set_Import, Asset_ma_path)) + grid_Lyt.addWidget(self.Asset_btn, xPos[0], yPos[1]) + + + ##---------------------------------------------------- Separator + SECTION_PLACEMENT_LAYOUT.addSpacing(separatorSpacingValue) + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #666; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + SECTION_PLACEMENT_LAYOUT.addWidget(separator) + SECTION_PLACEMENT_LAYOUT.addSpacing(separatorSpacingValue) + + + ##----------------------------------------------------------/ S P E C I A L S + Special_Base_path = RessourcePath + "Mesh/Special" + listAllInFolder = os.listdir(Special_Base_path) + + for each in listAllInFolder: + full_Special_filePath = Special_Base_path + "/" + each + #Find and keep only .png files + if full_Special_filePath.endswith(".png"): + Special_PNGList.append(full_Special_filePath) + + grid_Lyt = QtWidgets.QGridLayout() + SECTION_PLACEMENT_LAYOUT.addLayout(grid_Lyt) + + gridIconSize = 40 + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Special_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Special_PNGList.index(each)] + yPos = positions[Special_PNGList.index(each)] + self.Asset_btn = QtWidgets.QPushButton() + self.Asset_btn.setFixedSize(gridIconSize, gridIconSize) + self.Asset_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.Asset_btn.setIcon(QtGui.QIcon(each)) + self.Asset_btn.clicked.connect(partial(self.set_Import, Asset_ma_path)) + grid_Lyt.addWidget(self.Asset_btn, xPos[0], yPos[1]) + + + + + + + self.AssetItPromo_btn = QtWidgets.QPushButton("- C u s t o m B o l t -") + self.AssetItPromo_btn.setObjectName("StoreSet") + self.AssetItPromo_btn.setFixedHeight(18) + self.AssetItPromo_btn.setStyleSheet("color:#808080;") + if WIN_DISPLAY_SIZE == 1: #150 + self.AssetItPromo_btn.setFont(QtGui.QFont('Calibri', 6)) + self.AssetItPromo_btn.clicked.connect(self.AssetItPromo) + SECTION_PLACEMENT_LAYOUT.addWidget(self.AssetItPromo_btn) + + + + + + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + #------------------------------------------------ + def AssetItPromo(self): + from . import ModIt_AssetIt + importlib.reload(ModIt_AssetIt) + ModIt_AssetIt.showUI() + + + def set_DragMode(self): + self.ImportDrag_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Drag.png")) + self.ImportComponent_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Selection_OFF.png")) + open(PreferencePath + 'Screw_Mode.json', "w").write(json.dumps({"VALUE": 1})) + + def set_FaceMode(self): + self.ImportDrag_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Drag_OFF.png")) + self.ImportComponent_btn.setIcon(QtGui.QIcon(IconPath + "Placement_Selection.png")) + open(PreferencePath + 'Screw_Mode.json', "w").write(json.dumps({"VALUE": 2})) + + + + + + + def set_MultiSize_Slider(self): + SliderValue = self.Size_Slider.value() + self.Size_SpinBox.setValue(SliderValue) + + + def set_MultiSize_SpinBox(self): + SpinBoxAValue = self.Size_SpinBox.value() + self.Size_Slider.setValue(SpinBoxAValue) + self.Size_SpinBox.clearFocus() + open(PreferencePath + 'MultiSize.json', "w").write(json.dumps({"MULTISIZEVALUE": SpinBoxAValue})) + + + + + + def set_Import(self, maPath): + SCREW_MODE = (json.load(open(PreferencePath + 'Screw_Mode.json', "r"))['VALUE']) + + if SCREW_MODE == 1: + #VERIF THERE IS A MESH + listAllGeometrieScene = cmds.ls(type="mesh") + if listAllGeometrieScene == []: + ModIt_Global.WarningWindow("Drag Placement mode need at least one mesh in the scene.", 350) + return + + from . import ModIt_DragTool + importlib.reload(ModIt_DragTool) + ModIt_DragTool.goPress(maPath) + + else: + SaveSize_pref = json.load(open(PreferencePath + 'MultiSize.json', "r")) + MULTISIZEVALUE = (SaveSize_pref['MULTISIZEVALUE']) + + + selectionCheck = cmds.ls(sl=True) + if selectionCheck == []: + ModIt_Global.WarningWindow("On 'Place at Selection' mode : you should select component first.", 350) + return + + cmds.setToolTo('moveSuperContext') + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True, l=True) + + ##_________________IMPORT L'ASSET + before = set(cmds.ls(assemblies=True)) + cmds.file(maPath , i=True) + + after = set(cmds.ls(assemblies=True)) + imported = after.difference(before) + cmds.select(imported) + objImported = cmds.ls(sl=True)[0] + + + cmds.setAttr(objImported + ".scaleX", MULTISIZEVALUE) + cmds.setAttr(objImported + ".scaleY", MULTISIZEVALUE) + cmds.setAttr(objImported + ".scaleZ", MULTISIZEVALUE) + cmds.select(objImported) + cmds.makeIdentity(apply=True) + + cmds.select(objImported) + cmds.makeIdentity(apply=True) + cmds.xform(ws=1, a=1, piv=[0, 0, 0]) + + cmds.move(pos[0], pos[1], pos[2], objImported) + constr = cmds.normalConstraint(selection, objImported, aimVector=(0, 1, 0), worldUpType=0) + cmds.delete(constr) + + cmds.select(objImported) + cmds.setToolTo('moveSuperContext') + + + + diff --git a/Scripts/Modeling/Edit/ModIt/Placement/ModIt_AssetIt.py b/Scripts/Modeling/Edit/ModIt/Placement/ModIt_AssetIt.py new file mode 100644 index 0000000..71f6684 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Placement/ModIt_AssetIt.py @@ -0,0 +1,152 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath +RessourcePath = ModIt_Global.RessourcePath + + +##GLOBAL VAR +WindowsTitle = " - AssetIt -" + + +#________________// +#___________________________________________ +#________________// +class AssetItPromo_UI(QtWidgets.QDialog): + def __init__(self, parent=None): + super(AssetItPromo_UI, self).__init__() + self.setMinimumSize(1420, 950) + self.buildUI() + + def buildUI(self): + UILayout = QtWidgets.QVBoxLayout(self) + self.setStyleSheet(ModIt_CSS.ModIt_CSS) + ##UI - Preferences + iconButtonSize = 22 + + ############################################# + + + + ## SCATTER TAB Banner + label = QtWidgets.QLabel(self) + pixmap = QtGui.QPixmap(IconPath + "AssetIt_Presa_Img.jpg") + label.setPixmap(pixmap) + label.setAlignment(QtCore.Qt.AlignTop) + UILayout.addWidget(label) + + ## TEXT + LandscapeTitle = QtWidgets.QLabel(self) + LandscapeTitle.setFont(QtGui.QFont('Candara', 10)) + LandscapeTitle.setStyleSheet("QLabel {color : #65BEF1; }") + LandscapeTitle.setText(""" Allow users to create custom Bolts would mean the need to : set a user folder path, creation thumbnail, pivot placement setting, allow any type of mesh possible... + +> Which is so called an Asset Manager and for that I created AssetIt script. + +- So if you need more control about Bold and you want to create your own, I invited you to take a look at AssetIt script. -""") + LandscapeTitle.setAlignment(QtCore.Qt.AlignCenter) + UILayout.addWidget(LandscapeTitle) + + + + BoutonsLayout = QtWidgets.QHBoxLayout() + UILayout.addLayout(BoutonsLayout) + + GetAssetIt_btn = QtWidgets.QPushButton("- G e t A s s e t I t -") + GetAssetIt_btn.setFont(QtGui.QFont('Candara', 10)) + GetAssetIt_btn.setObjectName("AssetIt") + GetAssetIt_btn.setFixedHeight(22) + GetAssetIt_btn.setShortcut(QtGui.QKeySequence("Return")) + GetAssetIt_btn.clicked.connect(self.GetAssetIt) + BoutonsLayout.addWidget(GetAssetIt_btn) + + + + + + + def GetAssetIt(self): + cmds.deleteUI(WindowsTitle) + + QtGui.QDesktopServices.openUrl( + QtCore.QUrl("https://wzx.gumroad.com/l/AssetIt")) + + + + +def Dock(Widget, width=200, height=200, hp="free", show=True): + label = getattr(Widget, "label", WindowsTitle) + + try: + cmds.deleteUI(WindowsTitle) + except RuntimeError: + pass + + dockControl = cmds.workspaceControl( + WindowsTitle, + initialWidth=width, + minimumWidth=False, + widthProperty=hp, + heightProperty=hp, + label=label + ) + + dockPtr = omui.MQtUtil.findControl(dockControl) + dockWidget = QtCompat.wrapInstance(int(dockPtr), QtWidgets.QWidget) + dockWidget.setAttribute(QtCore.Qt.WA_DeleteOnClose) + child = Widget(dockWidget) + dockWidget.layout().addWidget(child) + + if show: + cmds.evalDeferred( + lambda *args: cmds.workspaceControl( + dockControl, + edit=True, + widthProperty="free", + restore=True + ) + ) + return child + +def showUI(): + ui = Dock(AssetItPromo_UI) + ui.show() + + # Get a pointer and convert it to Qt Widget object + qw = omui.MQtUtil.findWindow(WindowsTitle) + widget = wrapInstance(int(qw), QWidget) + # Create a QIcon object + icon = QIcon(IconPath + "ModIt_Window_Ico.png") + # Assign the icon + widget.setWindowIcon(icon) + + + return ui + diff --git a/Scripts/Modeling/Edit/ModIt/Placement/ModIt_DragTool.py b/Scripts/Modeling/Edit/ModIt/Placement/ModIt_DragTool.py new file mode 100644 index 0000000..de70dc7 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Placement/ModIt_DragTool.py @@ -0,0 +1,827 @@ +import maya.cmds as cmds +import maya.mel as mel +import maya.OpenMaya as om +import maya.OpenMayaUI as omui +from maya.OpenMaya import MGlobal +import math +import os +import os, json +import random +import re +from pymel.core.datatypes import Vector, Matrix, Point +import pymel.core as pm +import shutil + +from .. import ModIt_Global +import importlib +importlib.reload(ModIt_Global) + +##_______________________________________________ GLOBALS VAR +sampleFileChoice = [] +PreferencePath = ModIt_Global.PreferencePath +##______________________________ PLACE TOOL + + +def goPress(fileMA): #_________________________________________LA DEF QUI LANCE LE PLACE TOOL + SaveSize_pref = json.load(open(PreferencePath + 'MultiSize.json', "r")) + MULTISIZEVALUE = (SaveSize_pref['MULTISIZEVALUE']) + + sampleMesh = str(fileMA) #GET THE ASSET CLICK FULL PATH MA + + + global selAnyList + selAnyList = cmds.ls(sl=1,fl=1,l=1) + global sampleFileChoice + global pressFirstTime + global betweenFirstTime + global screenX,screenY + global betweenList + global betweenListShape + global checkVisList + global selectionPool + global combineSelPool + screenX = 0 + screenY = 0 + betweenList = [] + betweenListShape = [] + betweenFirstTime = 1 + pressFirstTime = 1 + selectionPool = [] + combineSelPool = [] + checkVisList = screenVisPoly() + + + sampleName = (sampleMesh.split('/')[-1]).split('.')[0] + cmds.CreateEmptyGroup() + cmds.rename(sampleName + '_Ctrl') ##__________________________________________CREATION DU GROUPE QUI CONTIENT LE MESH + checkName=cmds.ls(sl=True) + ##__________________________________________IMPORT ASSET + #____ Alembic + #command = 'AbcImport -mode import -reparent '+ checkName[0] + ' ' + '"' + sampleMesh + '"' + #newNode = mel.eval(command) + #print ("command = " + str(command)) + + # ____ .MA + before = set(cmds.ls(assemblies=True, l= True)) + + cmds.file(sampleMesh, i=True) + + after = set(cmds.ls(assemblies=True, l= True)) + imported = after.difference(before) + cmds.select(imported) + + cmds.parent(imported, checkName[0]) + cmds.select(checkName[0]) + + + cmds.setAttr(checkName[0] + ".scaleX", MULTISIZEVALUE) + cmds.setAttr(checkName[0] + ".scaleY", MULTISIZEVALUE) + cmds.setAttr(checkName[0] + ".scaleZ", MULTISIZEVALUE) + + cmds.makeIdentity(apply=True) + + cmds.xform(ws=1, a=1 ,piv =[0, 0, 0]) + cmds.pickWalk(d="down") + tempSel = cmds.ls(sl=True,type='transform',l=True) + folderName = (sampleMesh.split('/')[-2]) + + cmds.select(tempSel) + + + tempSel = cmds.ls(sl=True,type='transform',l=True) + cmds.select(tempSel[0]) + sampleFileChoice = checkName + cmds.setAttr((sampleFileChoice[0]+'.scaleX'),0) + cmds.setAttr((sampleFileChoice[0]+'.scaleY'),0) + cmds.setAttr((sampleFileChoice[0]+'.scaleZ'),0) + + runIt() + + if sampleFileChoice: + if cmds.objExists(sampleFileChoice[0]): + childNode = cmds.listRelatives(sampleFileChoice[0],type='transform',ad=True,f=True) + for c in childNode: + if not cmds.attributeQuery('targetGeo', node = c, ex=True ): + cmds.addAttr(c, ln='targetGeo', dt= 'string') + cmds.setAttr((c+'.targetGeo'),e=True, keyable=True) + +def runIt(): + global ctx + ctx = 'Click2dTo3dCtx' + # Delete dragger context if it already exists + if cmds.draggerContext(ctx, exists=True): + cmds.deleteUI(ctx) + # Create dragger context and set it to the active tool + cmds.draggerContext(ctx, pressCommand = onPressPlace, rc = offPressPlace, dragCommand = onDragPlace, fnz = finishTool, name=ctx, cursor='crossHair',undoMode='step') + cmds.setToolTo(ctx) + +##______________________________ PLACE TOOL - DRAGGER VAR +def getPosition(SX, SY): + global betweenListShape + global checkVisList + + pos = om.MPoint() + dir = om.MVector() + hitpoint = om.MFloatPoint() + omui.M3dView().active3dView().viewToWorld(int(SX), int(SY), pos, dir) + pos2 = om.MFloatPoint(pos.x, pos.y, pos.z) + # current camera + view = omui.M3dView.active3dView() + cam = om.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + + cameraTrans = cmds.listRelatives(camPath, type='transform', p=True) + cameraPosition = cmds.xform(cameraTrans, q=1, ws=1, rp=1) + + checkHit = 0 + finalMesh = [] + finalX = [] + finalY = [] + finalZ = [] + + shortDistance = 10000000000 + distanceBetween = 1000000000 + + hitFacePtr = om.MScriptUtil().asIntPtr() + hitFace = [] + checkList = [] + + checkStackMode = 1 + shapesNodestOnly = [] + try: + shapesList = cmds.listRelatives(betweenListShape, ad=True, f=True) + shapesNodestOnly = cmds.ls(shapesList, type='shape', l=1, fl=1) + except: + pass + if checkStackMode == 1: + checkList = checkVisList + try: + checkList = list(set(checkVisList) - set(shapesNodestOnly)) + except: + pass + else: + checkList = screenVisPoly() + checkList = list(set(checkList) - set(shapesNodestOnly)) + + for mesh in checkList: + selectionList = om.MSelectionList() + selectionList.add(mesh) + dagPath = om.MDagPath() + selectionList.getDagPath(0, dagPath) + fnMesh = om.MFnMesh(dagPath) + + intersection = fnMesh.closestIntersection( + om.MFloatPoint(pos2), + om.MFloatVector(dir), + None, + None, + False, + om.MSpace.kWorld, + 99999, + False, + None, + hitpoint, + None, + hitFacePtr, + None, + None, + None) + + if intersection: + x = hitpoint.x + y = hitpoint.y + z = hitpoint.z + distanceBetween = math.sqrt( + ((float(cameraPosition[0]) - x) ** 2) + ((float(cameraPosition[1]) - y) ** 2) + ( + (float(cameraPosition[2]) - z) ** 2)) + if distanceBetween < shortDistance: + shortDistance = distanceBetween + finalMesh = mesh + finalX = x + finalY = y + finalZ = z + hitFace = om.MScriptUtil(hitFacePtr).asInt() + + + return finalX, finalY, finalZ, finalMesh, hitFace + cmds.refresh(cv=True, f=True) + +def onPressPlace(): + global ctx + global betweenListShape + betweenListShape = [] + global SycList + SycList = [] + global sampleFileChoice + global selectionPool + global combineSelPool + global pressFirstTime + global betweenFirstTime + betweenFirstTime = 1 + global screenX, screenY + global headMesh + headMesh = [] + global tailMesh + global lastSnapMesh + global currentScaleRecord + global currentRotRecord + tailMesh = [] + checkSnapState = 1 + + vpX, vpY, _ = cmds.draggerContext(ctx, query=True, anchorPoint=True) + screenX = vpX + screenY = vpY + + meshTypeState = 1 # 1 = MESH / 2 = INSTANCE + + try: + if pressFirstTime == 1: + # check samplePool still item, if yes random select one + # multiMode + newChoice = [] + if len(sampleFileChoice) > 1: + randomNumber = random.randint(0, (len(sampleFileChoice) - 1)) + newChoice = sampleFileChoice[randomNumber] + sampleFileChoice.remove(newChoice) + selectionPool.append(newChoice) + + else: + newChoice = sampleFileChoice[0] + sampleFileChoice.remove(newChoice) + selectionPool.append(newChoice) + pressFirstTime = 0 + + # combine two list for selection###bug + combineSelPool = list(set(sampleFileChoice + selectionPool)) + cmds.select(newChoice) + + else: + newNodeA = [] + randomNumber = random.randint(0, (len(combineSelPool) - 1)) + newChoiceA = combineSelPool[randomNumber] + + if meshTypeState == 2: + # only instance mesh not tranform node + newNodeA = cmds.duplicate(newChoiceA, rr=True) + cmds.select(newNodeA) + cmds.pickWalk(d='Down') + meshNode = cmds.ls(sl=True, l=True) + cmds.select(newChoiceA) + cmds.pickWalk(d='Down') + cmds.instance() + cmds.delete(meshNode) + intNode = cmds.ls(sl=True, l=True) + cmds.parent(intNode, newNodeA) + cmds.rename(meshNode[0].split('|')[-1]) + cmds.pickWalk(d='up') + else: + newNodeA = cmds.duplicate(newChoiceA, rr=True) + cmds.select(newNodeA) + + tempSel = cmds.ls(sl=1, type='transform') + + + wx, wy, wz, hitmesh, hitFace = getPosition(screenX, screenY) + lastSnapMesh = hitmesh + cmds.setAttr((tempSel[0] + '.translateX'), wx) + cmds.setAttr((tempSel[0] + '.translateY'), wy) + cmds.setAttr((tempSel[0] + '.translateZ'), wz) + hitFaceName = (hitmesh + '.f[' + str(hitFace) + ']') + + if checkSnapState == 1: + rx, ry, rz = checkFaceAngle(hitFaceName) + cmds.setAttr((tempSel[0] + '.rotateX'), rx) + cmds.setAttr((tempSel[0] + '.rotateY'), ry) + cmds.setAttr((tempSel[0] + '.rotateZ'), rz) + + cmds.setAttr((tempSel[0] + '.scaleX'), 1) + cmds.setAttr((tempSel[0] + '.scaleY'), 1) + cmds.setAttr((tempSel[0] + '.scaleZ'), 1) + + + ##__________________________# Initialement Valeur de Slider + currentScaleX = 1.0 + currnetRotY = 0.0 + currentDepth = 0.0 + randomY = 0.0 + silderScale = 1.0 + randomScale = 0.0 + randomSwing = 0.0 + + cmds.pickWalk(tempSel[0], direction='down') + meshNode = cmds.ls(sl=1, type='transform', l=1) + # meshNode = cmds.listRelatives(tempSel[0],c=True, typ = 'transform',f=True) + SycList.append(meshNode[0]) + cmds.setAttr((meshNode[0] + '.scaleX'), currentScaleX) + cmds.setAttr((meshNode[0] + '.scaleY'), currentScaleX) + cmds.setAttr((meshNode[0] + '.scaleZ'), currentScaleX) + + currentScaleRecord = currentScaleX + cmds.setAttr((meshNode[0] + '.rotateY'), currnetRotY) + currentRotRecord = currnetRotY + cmds.setAttr((meshNode[0] + '.translateY'), currentDepth) + + if (randomY > 0): + randomNumber = random.uniform(0, randomY) + cmds.setAttr((meshNode[0] + '.rotateY'), int(randomNumber)) + currentRotRecord = int(randomNumber) + + if (randomScale > 0): + randomNumber = random.uniform((-1 * randomScale), randomScale) + cmds.setAttr((meshNode[0] + '.scaleX'), (randomNumber + silderScale)) + cmds.setAttr((meshNode[0] + '.scaleY'), (randomNumber + silderScale)) + cmds.setAttr((meshNode[0] + '.scaleZ'), (randomNumber + silderScale)) + currentScaleRecord = (randomNumber + silderScale) + + if randomSwing > 0: + offsetNode = cmds.listRelatives(meshNode[0], type='transform', p=True) + randomNumberX = random.uniform(-1 * randomSwing, randomSwing) + cmds.setAttr((offsetNode[0] + '.rotateX'), int(randomNumberX)) + randomNumberZ = random.uniform(-1 * randomSwing, randomSwing) + cmds.setAttr((offsetNode[0] + '.rotateZ'), int(randomNumberZ)) + + cmds.select(tempSel) + + + ####################################################################### + + transNode = cmds.listRelatives(lastSnapMesh, type='transform', p=True, f=True) + cmds.setAttr((meshNode[0] + '.targetGeo'), transNode[0], type="string") + + ######################################################################### + except: + pass + + cmds.refresh(cv=True, f=True) + +def offPressPlace(): + global tempCmd + global betweenList + global betweenList3DPos + betweenList3DPos = [] + + for e in betweenList: + attList = ['translateX','translateY','translateZ'] + attListRecord =['ptX','ptY','ptZ'] + for a in range(len(attList)): + attListRecord[a] = cmds.getAttr(e +'.'+attList[a]) + pos3D = (attListRecord[0],attListRecord[1],attListRecord[2]) + betweenList3DPos.append(pos3D ) + cmds.refresh(cv=True,f=True) + deSelect() + + #Get Active Sel Mode + activeSelMode = cmds.selectMode(q=True, root=True) + if activeSelMode == False: + cmds.selectMode(root=True) + + else: + cmds.selectMode(object=True) + + + +def onDragPlace(): + + global tempCmd + tempCmd = [] + global ctx + global pressFirstTime + global betweenFirstTime + global screenX,screenY + global betweenList + global betweenListShape + global checkVisList + global combineSelPool + global SycList + global headMesh + global tailMesh + global lastPanelActive + global lastSnapMesh + global currentScaleRecord + global currentRotRecord + + + checkSnapState = 1 + lastPanelActive = cmds.getPanel(underPointer=True) + currentSX = 0 + currnetSY = 0 + goStrightLine = 0.0 + randomY = 0.0 + meshTypeState = 1 + selSample = [] + selSample = cmds.ls(sl=True,fl=True,l=True) + headMesh = selSample[0] + + + + + if len(selSample)>0: + if (goStrightLine > 0): + if betweenFirstTime == 1: + #need to give one sample to first position + attList = ['translateX','translateY','translateZ','rotateX','rotateY','rotateZ','scaleX','scaleY','scaleZ'] + attListRecord =['ptX','ptY','ptZ','prX','prY','prZ','psX','psY','psZ'] + for a in range(len(attList)): + attListRecord[a] = cmds.getAttr(selSample[0]+'.'+attList[a]) + #pick up sample if multiMode + if len(combineSelPool)>1: + randomNumber = random.randint(0,(len(combineSelPool)-1)) + cmds.select(combineSelPool[randomNumber]) + else: + cmds.select(selSample[0]) + keepItMesh = cmds.ls(sl=1,fl=1) + #make a copy + if meshTypeState == 2: + #only instance mesh not tranform node + newKeepNode = cmds.duplicate(keepItMesh[0],rr=True) + cmds.select(newKeepNode) + cmds.pickWalk(d='Down') + meshKeepNode = cmds.ls(sl=True,l=True) + cmds.select(keepItMesh[0]) + cmds.pickWalk(d='Down') + cmds.instance() + cmds.delete(meshKeepNode) + intKeepNode = cmds.ls(sl=True,l=True) + cmds.parent(intKeepNode,newKeepNode) + intKeepNode = cmds.ls(sl=True,l=True) + cmds.rename(meshKeepNode[0].split('|')[-1]) + cmds.pickWalk(d='up') + else: + cmds.duplicate(keepItMesh[0]) + #restore position + checkKeepNode = cmds.ls(sl=1,fl=1) + for b in range(len(attList)): + cmds.setAttr((checkKeepNode[0]+'.'+attList[b]),attListRecord[b]) + checkKeepNodeChild = cmds.listRelatives(checkKeepNode[0],c=True, typ = 'transform',f=True) + SycList.append(checkKeepNodeChild[0]) + + meshNodeA = cmds.listRelatives(selSample[0],c=True, typ = 'transform',f=True) + + SycList.append(meshNodeA[0]) + if randomY > 0: + randomNumber = random.uniform(0,randomY) + cmds.setAttr((meshNodeA[0]+'.rotateY'),int(randomNumber)) + + tailMesh = checkKeepNode[0] + betweenList = [] + betweenListShape = [] + #get in between element + for i in range(int(goStrightLine)): + if len(combineSelPool)>1: + randomNumber = random.randint(0,(len(combineSelPool)-1)) + cmds.select(combineSelPool[randomNumber]) + else: + cmds.select(selSample[0]) + + newBetweenDulpi = cmds.ls(sl=True,fl=True,l=True) + if meshTypeState == 2: + #only instance mesh not tranform node + newNode = cmds.duplicate(newBetweenDulpi[0],rr=True) + cmds.select(newNode) + cmds.pickWalk(d='Down') + meshNode = cmds.ls(sl=True,l=True) + cmds.select(newBetweenDulpi[0]) + cmds.pickWalk(d='Down') + cmds.instance() + cmds.delete(meshNode) + intNode = cmds.ls(sl=True,l=True) + cmds.parent(intNode,newNode) + intNode = cmds.ls(sl=True,l=True) + cmds.rename(meshNode[0].split('|')[-1]) + cmds.pickWalk(d='up') + else: + cmds.duplicate(newBetweenDulpi[0]) + + selBetween = cmds.ls(sl=True,fl=True,l=True) + meshNodeB = cmds.listRelatives(selBetween[0],c=True, typ = 'transform',f=True) + + silderScale = 1.0 + randomScale = 0.0 + randomSwing = 0.0 + + if (randomScale > 0): + randomNumber = random.uniform((-1*randomScale),randomScale) + newScale = (randomNumber+silderScale) + #bug calucation done but update not fast enough to show, evalDeferred works but not great + cmdx = 'cmds.setAttr("' + meshNodeB[0] +'.scaleX",' + str(newScale) + ')' + cmds.evalDeferred(cmdx) + cmdy = 'cmds.setAttr("' + meshNodeB[0] +'.scaleY",' + str(newScale) + ')' + cmds.evalDeferred(cmdy) + cmdz = 'cmds.setAttr("' + meshNodeB[0] +'.scaleZ",' + str(newScale) + ')' + cmds.evalDeferred(cmdz) + + + if randomY > 0: + randomNumber = random.uniform(0,randomY) + cmds.setAttr((meshNodeB[0]+'.rotateY'),int(randomNumber)) + + if randomSwing > 0: + offsetNode = cmds.listRelatives(meshNodeB[0],type='transform',p=True) + randomNumberX = random.uniform(-1*randomSwing,randomSwing) + cmds.setAttr((offsetNode[0]+'.rotateX'),int(randomNumberX)) + randomNumberZ = random.uniform(-1*randomSwing,randomSwing) + cmds.setAttr((offsetNode[0]+'.rotateZ'),int(randomNumberZ)) + + SycList.append(meshNodeB[0]) + betweenShape = cmds.listRelatives(selBetween[0], fullPath=True ,c=True) + betweenList.append(selBetween[0]) + betweenListShape.append(betweenShape[0]) + betweenFirstTime = 0 + else: + betweenListShape = [] + + modifiers = cmds.getModifiers() + SycList = list(set(SycList)) + if (modifiers == 4): + #print 'ctrl Press' + + vpX, vpY, _ = cmds.draggerContext(ctx, query=True, dragPoint=True) + distanceA = (vpX - screenX) + rotateCheck = (distanceA) + rotateRun = currentRotRecord + rotateCheck + + if rotateRun > 360 : + rotateRun = 360 + elif rotateRun < -360 : + rotateRun = -360 + getR = int(rotateRun / 15)*15 + if rotateRun != getR: + rotateRun = getR + #cmds.floatSliderGrp( 'meshRotSlide', e=1 ,v = rotateRun ) + cmds.setAttr((selSample[0]+'.rotateAxisY'),rotateRun) + #cmds.refresh(f=True) + + elif(modifiers == 1): + + #print 'shift selSample' + vpX, vpY, _ = cmds.draggerContext(ctx, query=True, dragPoint=True) + distanceB = vpX - screenX + scaleCheck = distanceB / 100 + scaleRun = currentScaleRecord + scaleCheck + if scaleRun > 5: + scaleRun = 5 + elif scaleRun < 0: + scaleRun = 0.1 + + #cmds.floatSliderGrp( 'meshScaleSlide', e=1 ,v = scaleRun ) + if len(SycList)>0: + cmds.setAttr((selSample[0] + '.scaleX'),scaleRun) + cmds.setAttr((selSample[0] + '.scaleY'),scaleRun) + cmds.setAttr((selSample[0] + '.scaleZ'),scaleRun) + #cmds.refresh(cv=True,f=True) + else: + vpX, vpY, _ = cmds.draggerContext(ctx, query=True, dragPoint=True) + currentSX = vpX + currentSY = vpY + pos = om.MPoint() + dir = om.MVector() + hitpoint = om.MFloatPoint() + omui.M3dView().active3dView().viewToWorld(int(vpX), int(vpY), pos, dir) + pos2 = om.MFloatPoint(pos.x, pos.y, pos.z) + + #current camera + view = omui.M3dView.active3dView() + cam = om.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + + cameraTrans = cmds.listRelatives(camPath,type='transform',p=True) + cameraPosition = cmds.xform(cameraTrans,q=1,ws=1,rp=1) + + checkHit = 0 + finalMesh = [] + finalX = 0 + finalY = 0 + finalZ = 0 + shortDistance = 10000000000 + distanceBetween = 1000000000 + + checkList=[] + meshNode = cmds.listRelatives(selSample, fullPath=True ,c=True) + myShape = cmds.listRelatives(meshNode, shapes=True,f=True) + + shapesList = cmds.listRelatives(betweenListShape,ad=True,f=True) + shapesNodestOnly = cmds.ls(shapesList,type='shape',l=1,fl=1) + + + if myShape == None:#gpu + checkList = list(set(checkVisList)) + else: + checkStackMode = 1 + if checkStackMode == 1: + checkList = list(set(checkVisList)-set(myShape)-set(shapesNodestOnly)) + else: + checkList = screenVisPoly() + checkList.remove(myShape[0]) + SycListShape = cmds.listRelatives(SycList, shapes=True,f=True) + checkList = list(set(checkList) - set(shapesNodestOnly)- set(SycListShape)) + hitFacePtr = om.MScriptUtil().asIntPtr() + hitFace = [] + for mesh in checkList: + selectionList = om.MSelectionList() + selectionList.add(mesh) + dagPath = om.MDagPath() + selectionList.getDagPath(0, dagPath) + fnMesh = om.MFnMesh(dagPath) + intersection = fnMesh.closestIntersection( + om.MFloatPoint(pos2), + om.MFloatVector(dir), + None, + None, + False, + om.MSpace.kWorld, + 99999, + False, + None, + hitpoint, + None, + hitFacePtr, + None, + None, + None) + if intersection: + x = hitpoint.x + y = hitpoint.y + z = hitpoint.z + distanceBetween = math.sqrt( ((float(cameraPosition[0]) - x)**2) + ((float(cameraPosition[1]) - y)**2) + ((float(cameraPosition[2]) - z)**2)) + if distanceBetween < shortDistance: + shortDistance = distanceBetween + finalMesh = mesh + hitFace = om.MScriptUtil(hitFacePtr).asInt() + hitFaceName = (finalMesh + '.f[' + str(hitFace) +']') + #buggy when this is done after it return incorrect information + if checkSnapState == 1: + rx, ry, rz = checkFaceAngle(hitFaceName) + cmds.setAttr((selSample[0] + '.rotateX'), rx) + cmds.setAttr((selSample[0] + '.rotateY'), ry) + cmds.setAttr((selSample[0] + '.rotateZ'), rz) + finalX = x + finalY = y + finalZ = z + lastSnapMesh = finalMesh + ####################################################################### + childNode = cmds.listRelatives(selSample[0],type='transform',ad=True,f=True) + transNode=cmds.listRelatives(lastSnapMesh,type='transform',p=True,f=True) + for c in childNode: + cmds.setAttr((c + '.targetGeo'),transNode[0],type="string") + ######################################################################### + cmds.setAttr((selSample[0] + '.translateX'), finalX) + cmds.setAttr((selSample[0] + '.translateY'), finalY) + cmds.setAttr((selSample[0] + '.translateZ'), finalZ) + hitFaceName = (finalMesh + '.f[' + str(hitFace) +']') + + lockVtxCheck = 0.0 + if (lockVtxCheck > 0): + cvX = 0 + cvY = 0 + cvZ = 0 + shortDistanceCheck = 10000 + checkCVDistance = 10000 + mostCloseDist = lockVtxCheck + hitFaceName = (finalMesh + '.f[' + str(hitFace) +']') + cvList = (cmds.polyInfo(hitFaceName , fv=True )[0]).split(':')[-1].split(' ') + cvList = [x for x in cvList if x.strip()] + mostCloseCVPoint = [] + for v in cvList: + checkNumber = ''.join([n for n in v.split('|')[-1] if n.isdigit()]) + if len(checkNumber) > 0: + cvPoint = (finalMesh + '.vtx[' + str(checkNumber) +']') + cvPosition = cmds.pointPosition(cvPoint) + checkCVDistance = math.sqrt( ((float(cvPosition[0]) - finalX)**2) + ((float(cvPosition[1]) - finalY)**2) + ((float(cvPosition[2]) - finalZ)**2)) + if checkCVDistance < shortDistanceCheck: + shortDistanceCheck = checkCVDistance + cvX = float(cvPosition[0]) + cvY = float(cvPosition[1]) + cvZ = float(cvPosition[2]) + mostCloseCVPoint = cvPoint + if shortDistanceCheck < mostCloseDist: + cmds.setAttr((selSample[0] + '.translateX'), cvX) + cmds.setAttr((selSample[0] + '.translateY'), cvY) + cmds.setAttr((selSample[0] + '.translateZ'), cvZ) + #get average normal angle from suround faces + if checkSnapState == 1: + rX,rY,rZ = avgVertexNormalAngle(cvPoint) + cmds.setAttr(selSample[0]+'.rotateX', rX) + cmds.setAttr(selSample[0]+'.rotateY', rY) + cmds.setAttr(selSample[0]+'.rotateZ', rZ) + + silderRandomPos = 0.0 + # caculate new inBetween position + for a in range(int(goStrightLine)): + disX = (screenX - currentSX)/(goStrightLine+1) + disY = (screenY - currentSY)/(goStrightLine+1) + nextX = 0 + nextY = 0 + if silderRandomPos > 0: + randomNumberX = random.uniform((-1*silderRandomPos),silderRandomPos) + randomNumberY = random.uniform((-1*silderRandomPos),silderRandomPos) + nextX = (screenX -(disX*(a+1) ))*(1+(randomNumberX*0.1)) + nextY = (screenY -(disY*(a+1))) *(1+(randomNumberY*0.1)) + + else: + nextX = screenX -(disX*(a+1)) + nextY = screenY -(disY*(a+1)) + wx,wy,wz,hitmesh,hitFace = getPosition(nextX,nextY) + if wx != []: + ####################################################################### + childNode = cmds.listRelatives(betweenList[a],type='transform',ad=True,f=True) + transNode=cmds.listRelatives(hitmesh,type='transform',p=True,f=True) + for c in childNode: + cmds.setAttr((c + '.targetGeo'),transNode[0],type="string") + ######################################################################### + cmds.setAttr((betweenList[a] + '.translateX'), wx) + cmds.setAttr((betweenList[a] + '.translateY'), wy) + cmds.setAttr((betweenList[a] + '.translateZ'), wz) + if checkSnapState == 1: + hitFaceName = (hitmesh + '.f[' + str(hitFace) +']') + rx, ry, rz = checkFaceAngle(hitFaceName) + cmds.setAttr((betweenList[a] + '.rotateX'), rx) + cmds.setAttr((betweenList[a] + '.rotateY'), ry) + cmds.setAttr((betweenList[a] + '.rotateZ'), rz) + + cmds.select(selSample[0]) + cmds.refresh(cv=True,f=True) + +def finishTool(): + restoreSelVis() + #cmds.MoveTool() + cmds.select(cl=True) + +##______________________________ PLACE TOOL - HELPERS +def restoreSelVis(): + cmds.modelEditor('modelPanel1', e=True, sel=True) + cmds.modelEditor('modelPanel2', e=True, sel=True) + cmds.modelEditor('modelPanel3', e=True, sel=True) + cmds.modelEditor('modelPanel4', e=True, sel=True) + +def screenVisPoly(): + commonList= [] + view = omui.M3dView.active3dView() + om.MGlobal.selectFromScreen(0, 0, view.portWidth(), view.portHeight(), om.MGlobal.kReplaceList) + objects = om.MSelectionList() + sel = om.MSelectionList() + om.MGlobal.getActiveSelectionList(objects) + #restore selection + om.MGlobal.setActiveSelectionList(sel, om.MGlobal.kReplaceList) + #return the objects as strings + fromScreen = [] + objects.getSelectionStrings(fromScreen) + shapesOnScreen = cmds.listRelatives(fromScreen, shapes=True,f=True) + meshList = cmds.ls(type='mesh',l=True)#only polygon + if len(meshList)>0 and shapesOnScreen is not None: + commonList = list(set(meshList) & set(shapesOnScreen)) + return commonList + else: + commonList = [] + return commonList + +def deSelect(): + obj_shape = cmds.listRelatives(parent=True, f=True) + obj = cmds.listRelatives(obj_shape,parent=True, f=True) + cmds.select(obj) + cmds.selectMode(leaf=True) + cmd = "changeSelectMode -object;" + mel.eval(cmd) + cmds.select(clear=True) + +def checkFaceAngle(faceName): + shapeNode = cmds.listRelatives(faceName, fullPath=True , parent=True ) + transformNode = cmds.listRelatives(shapeNode[0], fullPath=True , parent=True ) + obj_matrix = Matrix(cmds.xform(transformNode, query=True, worldSpace=True, matrix=True)) + face_normals_text = cmds.polyInfo(faceName, faceNormals=True)[0] + face_normals = [float(digit) for digit in re.findall(r'-?\d*\.\d*', face_normals_text)] + v = Vector(face_normals) * obj_matrix + if max(abs(v[0]), abs(v[1]), abs(v[2])) == -v[1]: + pass + #print face, v #if reverse, need to rotate another 180 degree + upvector = om.MVector (0,1,0) + getHitNormal = v + quat = om.MQuaternion(upvector, getHitNormal) + quatAsEuler = om.MEulerRotation() + quatAsEuler = quat.asEulerRotation() + rx, ry, rz = math.degrees(quatAsEuler.x), math.degrees(quatAsEuler.y), math.degrees(quatAsEuler.z) + return rx, ry, rz + +def screenVisPoly(): + commonList= [] + view = omui.M3dView.active3dView() + om.MGlobal.selectFromScreen(0, 0, view.portWidth(), view.portHeight(), om.MGlobal.kReplaceList) + objects = om.MSelectionList() + sel = om.MSelectionList() + om.MGlobal.getActiveSelectionList(objects) + #restore selection + om.MGlobal.setActiveSelectionList(sel, om.MGlobal.kReplaceList) + #return the objects as strings + fromScreen = [] + objects.getSelectionStrings(fromScreen) + shapesOnScreen = cmds.listRelatives(fromScreen, shapes=True,f=True) + meshList = cmds.ls(type='mesh',l=True)#only polygon + if len(meshList)>0 and shapesOnScreen is not None: + commonList = list(set(meshList) & set(shapesOnScreen)) + return commonList + else: + commonList = [] + return commonList + + diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Autoload.json b/Scripts/Modeling/Edit/ModIt/Preferences/Autoload.json new file mode 100644 index 0000000..9281fa8 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Autoload.json @@ -0,0 +1 @@ +{"VALUE": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Dockable.json b/Scripts/Modeling/Edit/ModIt/Preferences/Dockable.json new file mode 100644 index 0000000..9281fa8 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Dockable.json @@ -0,0 +1 @@ +{"VALUE": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/FirstLaunch.json b/Scripts/Modeling/Edit/ModIt/Preferences/FirstLaunch.json new file mode 100644 index 0000000..22c244d --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/FirstLaunch.json @@ -0,0 +1 @@ +{"FIRST_LAUNCH": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/ImportShader.json b/Scripts/Modeling/Edit/ModIt/Preferences/ImportShader.json new file mode 100644 index 0000000..781f5a3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/ImportShader.json @@ -0,0 +1 @@ +{"IMPORTSHADERMODE": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/InstanceMode.json b/Scripts/Modeling/Edit/ModIt/Preferences/InstanceMode.json new file mode 100644 index 0000000..9281fa8 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/InstanceMode.json @@ -0,0 +1 @@ +{"VALUE": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/JobExist.json.todel b/Scripts/Modeling/Edit/ModIt/Preferences/JobExist.json.todel new file mode 100644 index 0000000..8ec8558 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/JobExist.json.todel @@ -0,0 +1 @@ +{"JOB_EXIST": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/JobNumber.json b/Scripts/Modeling/Edit/ModIt/Preferences/JobNumber.json new file mode 100644 index 0000000..582ad9f --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/JobNumber.json @@ -0,0 +1 @@ +{"JOB_NUMBER": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Locator_Size.json b/Scripts/Modeling/Edit/ModIt/Preferences/Locator_Size.json new file mode 100644 index 0000000..afab452 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Locator_Size.json @@ -0,0 +1 @@ +{"VALUE": 3.0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/MultiSize.json b/Scripts/Modeling/Edit/ModIt/Preferences/MultiSize.json new file mode 100644 index 0000000..d67d64b --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/MultiSize.json @@ -0,0 +1 @@ +{"MULTISIZEVALUE": 0.01} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Pref_IconSize.json b/Scripts/Modeling/Edit/ModIt/Preferences/Pref_IconSize.json new file mode 100644 index 0000000..93b8e2c --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Pref_IconSize.json @@ -0,0 +1 @@ +{"ICONSIZE": 18} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Pref_SymAxis.json b/Scripts/Modeling/Edit/ModIt/Preferences/Pref_SymAxis.json new file mode 100644 index 0000000..9281fa8 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Pref_SymAxis.json @@ -0,0 +1 @@ +{"VALUE": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Pref_Theme.json b/Scripts/Modeling/Edit/ModIt/Preferences/Pref_Theme.json new file mode 100644 index 0000000..7416369 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Pref_Theme.json @@ -0,0 +1 @@ +{"THEME": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Screw_Mode.json b/Scripts/Modeling/Edit/ModIt/Preferences/Screw_Mode.json new file mode 100644 index 0000000..4d7f75c --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Screw_Mode.json @@ -0,0 +1 @@ +{"VALUE": 2} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Section_Colors.json b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Colors.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Colors.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Section_Mesh.json b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Mesh.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Mesh.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Section_Primitives.json b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Primitives.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Primitives.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Section_Selections.json b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Selections.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Selections.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Section_Sets.json b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Sets.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Sets.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Section_Tools.json b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Tools.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Tools.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Section_Utilities.json b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Utilities.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Section_Utilities.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/SetBool.json b/Scripts/Modeling/Edit/ModIt/Preferences/SetBool.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/SetBool.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_OnTopOf.json b/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_OnTopOf.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_OnTopOf.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_Placement.json b/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_Placement.json new file mode 100644 index 0000000..37588d9 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_Placement.json @@ -0,0 +1 @@ +{"PRIM_MODE": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_Size.json b/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_Size.json new file mode 100644 index 0000000..8fa4fb1 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/Setting_Primitives_Size.json @@ -0,0 +1 @@ +{"PRIM_SIZE": 1.0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/ShaderAttributs.json b/Scripts/Modeling/Edit/ModIt/Preferences/ShaderAttributs.json new file mode 100644 index 0000000..9281fa8 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/ShaderAttributs.json @@ -0,0 +1 @@ +{"VALUE": 0} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/TabOpen.json b/Scripts/Modeling/Edit/ModIt/Preferences/TabOpen.json new file mode 100644 index 0000000..9e34703 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/TabOpen.json @@ -0,0 +1 @@ +{"TAB_OPEN": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/TestFile.json b/Scripts/Modeling/Edit/ModIt/Preferences/TestFile.json new file mode 100644 index 0000000..430bc66 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/TestFile.json @@ -0,0 +1,5 @@ +{ + "name": "Wizix", + "Age": 32, + "Tag": "wzx" +} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/UI_Adapt_Height.json b/Scripts/Modeling/Edit/ModIt/Preferences/UI_Adapt_Height.json new file mode 100644 index 0000000..e8dc53c --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/UI_Adapt_Height.json @@ -0,0 +1 @@ +{"VALUE": 660} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/UserLibPath.json b/Scripts/Modeling/Edit/ModIt/Preferences/UserLibPath.json new file mode 100644 index 0000000..83486fd --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/UserLibPath.json @@ -0,0 +1 @@ +{"USER_LIB_PATH": "C:/Users/chauliac/Documents/maya/2023/scripts/AssetIt/AssetIt_LIBRARY"} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/WinSize.json b/Scripts/Modeling/Edit/ModIt/Preferences/WinSize.json new file mode 100644 index 0000000..dc959b3 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/WinSize.json @@ -0,0 +1 @@ +{"VALUE": 1} \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Preferences/settingsFile.ini b/Scripts/Modeling/Edit/ModIt/Preferences/settingsFile.ini new file mode 100644 index 0000000..32d6ddf --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Preferences/settingsFile.ini @@ -0,0 +1,2 @@ +[General] +windowGeometry="@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\x1\xcf\0\0\0\xe3\0\0\x3$\0\0\x3-\0\0\x1\xd0\0\0\x1\x2\0\0\x3#\0\0\x3,\0\0\0\0\0\0\0\0\a\x80\0\0\x1\xd0\0\0\x1\x2\0\0\x3#\0\0\x3,)" diff --git a/Scripts/Modeling/Edit/ModIt/Setting/Layout_SETTING.py b/Scripts/Modeling/Edit/ModIt/Setting/Layout_SETTING.py new file mode 100644 index 0000000..26b81e2 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Setting/Layout_SETTING.py @@ -0,0 +1,823 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 20 +iconButtonSize = 20 +separatorWidth = ModIt_Global.separatorWidth + +##JSON PREF DATA +PRIM_MODE =(json.load(open(PreferencePath + 'Setting_Primitives_Placement.json',"r"))['PRIM_MODE']) +PRIM_SIZE =(json.load(open(PreferencePath + 'Setting_Primitives_Size.json',"r"))['PRIM_SIZE']) +SHADER_ATTRIBUTS = (json.load(open(PreferencePath + 'ShaderAttributs.json',"r"))['VALUE']) +INSTANCE_MODE = (json.load(open(PreferencePath + 'InstanceMode.json',"r"))['VALUE']) +AUTOLOAD = (json.load(open(PreferencePath + 'Autoload.json',"r"))['VALUE']) +LOCATOR_SIZE =(json.load(open(PreferencePath + 'Locator_Size.json',"r"))['VALUE']) +PRIM_TOPOF =(json.load(open(PreferencePath + 'Setting_Primitives_OnTopOf.json',"r"))['VALUE']) + +WIN_DISPLAY_SIZE =(json.load(open(PreferencePath + 'WinSize.json',"r"))['VALUE']) +if WIN_DISPLAY_SIZE == 0: # 125 + Title_Text_Size = 8 + Text_Size = 7 +else: #150 + Title_Text_Size = 7 + Text_Size = 7 + +DOCK =(json.load(open(PreferencePath + 'Dockable.json',"r"))['VALUE']) + + +class SETTING_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + SECTION_SETTING_LAYOUT = QtWidgets.QVBoxLayout() # MAIN + self.setLayout(SECTION_SETTING_LAYOUT) + SECTION_SETTING_LAYOUT.setContentsMargins(0,0,0,0) + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B G E N E R A L + ##------------------------------------------------------------------------------------// + General_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(General_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + General_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" G E N E R A L ") + MODELING_label.setFont(QtGui.QFont('Candara', Title_Text_Size)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + General_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + General_Title_Hlyt.addWidget(separator) + + + ###------------------------------------------------------------------------------------// DOCK FLOATING MODE + ###---------------------------------------------------- H LAYOUT + DockMode_Hlyt = QtWidgets.QHBoxLayout() + DockMode_Hlyt.setSpacing(0) + SECTION_SETTING_LAYOUT.addLayout(DockMode_Hlyt) + + ###---------------------------------------------------- ICON + Autosave_img = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "WinDock.png") + Autosave_img.setPixmap(pixmap) + DockMode_Hlyt.addWidget(Autosave_img) + DockMode_Hlyt.addSpacing(5) + + ###---------------------------------------------------- LABEL + label = QtWidgets.QLabel(self) + label.setText(" ModIt Mode : ") + if WIN_DISPLAY_SIZE == 1: # 125 + label.setFont(QtGui.QFont('Candara', Text_Size)) + DockMode_Hlyt.addWidget(label) + DockMode_Hlyt.addSpacing(15) + + ###---------------------------------------------------- FLOATING BTN + DockMode_Btn = QtWidgets.QPushButton() + DockMode_Btn.setText("Floating") + DockMode_Btn.clicked.connect(self.set_Floating) + + if DOCK == 0: + DockMode_Btn.setStyleSheet("QPushButton {color : #29b1ea;}") + DockMode_Btn.setEnabled(0) + else: + DockMode_Btn.setStyleSheet("QPushButton {color : #404040;}") + DockMode_Hlyt.addWidget(DockMode_Btn) + DockMode_Hlyt.addSpacing(15) + + ###---------------------------------------------------- DOCK BTN + FloatingMode_Btn = QtWidgets.QPushButton() + FloatingMode_Btn.setText("Dockable") + FloatingMode_Btn.clicked.connect(self.set_Dockable) + + if DOCK == 1: + FloatingMode_Btn.setStyleSheet("QPushButton {color : #29b1ea;}") + FloatingMode_Btn.setEnabled(0) + else: + FloatingMode_Btn.setStyleSheet("QPushButton {color : #404040;}") + + DockMode_Hlyt.addWidget(FloatingMode_Btn) + + + + + + ###------------------------------------------------------------------------------------// DISPLAY SIZE + ###---------------------------------------------------- H LAYOUT + DisplaySize_Hlyt = QtWidgets.QHBoxLayout() + DisplaySize_Hlyt.setSpacing(0) + SECTION_SETTING_LAYOUT.addLayout(DisplaySize_Hlyt) + + ###---------------------------------------------------- ICON + Autosave_img = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "WinSize.png") + Autosave_img.setPixmap(pixmap) + DisplaySize_Hlyt.addWidget(Autosave_img) + DisplaySize_Hlyt.addSpacing(5) + + ###---------------------------------------------------- LABEL + label = QtWidgets.QLabel(self) + label.setText(" Windows Display Size : ") + if WIN_DISPLAY_SIZE == 1: # 125 + label.setFont(QtGui.QFont('Candara', Text_Size)) + DisplaySize_Hlyt.addWidget(label) + + ###---------------------------------------------------- 100% BTN + Display100_Btn = QtWidgets.QPushButton() + Display100_Btn.setText("100%") + Display100_Btn.setFixedWidth(50) + Display100_Btn.clicked.connect(self.set_WinSize100) + if WIN_DISPLAY_SIZE == 1: + Display100_Btn.setStyleSheet( "QPushButton {color : #404040;}") + else: + Display100_Btn.setStyleSheet("QPushButton {color : #29b1ea;}") + Display100_Btn.setEnabled(0) + DisplaySize_Hlyt.addWidget(Display100_Btn) + + ###---------------------------------------------------- 150% BTN + Display150_Btn = QtWidgets.QPushButton() + Display150_Btn.setText("150%") + Display150_Btn.setFixedWidth(50) + Display150_Btn.clicked.connect(self.set_WinSize150) + if WIN_DISPLAY_SIZE == 1: + Display150_Btn.setStyleSheet( "QPushButton {color : #29b1ea;}") + Display150_Btn.setEnabled(0) + else: + Display150_Btn.setStyleSheet("QPushButton {color : #404040;}") + DisplaySize_Hlyt.addWidget(Display150_Btn) + + + + + + + + + + DisplaySize_Hlyt.addStretch() + DockMode_Hlyt.addStretch() + + + ###------------------------------------------------------------------------------------// Attributs PopUp + ###---------------------------------------------------- H LAYOUT + Autosave_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(Autosave_Hlyt) + + ###---------------------------------------------------- ICON + Autosave_img = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "saveDisk.png") + Autosave_img.setPixmap(pixmap) + Autosave_Hlyt.addWidget(Autosave_img) + + ###---------------------------------------------------- MODE LABEL + Autosave_label = QtWidgets.QLabel(self) + Autosave_label.setText(" Open ModIt at launch :") + if WIN_DISPLAY_SIZE == 1: # 125 + Autosave_label.setFont(QtGui.QFont('Candara', Text_Size)) + #Autosave_label.setFixedHeight(19) + Autosave_Hlyt.addWidget(Autosave_label) + + ###---------------------------------------------------- CHECKBOX + self.Autosave_Cbx = QtWidgets.QCheckBox() + self.Autosave_Cbx.setFixedSize(20, 20) + if AUTOLOAD == 0: + self.Autosave_Cbx.setChecked(0) + else: + self.Autosave_Cbx.setChecked(1) + self.Autosave_Cbx.toggled.connect(self.Autoload_ON_OFF) + Autosave_Hlyt.addWidget(self.Autosave_Cbx) + Autosave_Hlyt.addStretch() + + + + + + + + + + + + + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B M O D E L I N G + ##------------------------------------------------------------------------------------// + SECTION_SETTING_LAYOUT.addSpacing(5) + Modeling_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(Modeling_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Modeling_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" M O D E L I N G ") + MODELING_label.setFont(QtGui.QFont('Candara', Title_Text_Size)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + Modeling_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Modeling_Title_Hlyt.addWidget(separator) + + ###------------------------------------------------------------------------------------// Primitives + + Primitive_label = QtWidgets.QLabel(self) + Primitive_label.setText(" / P r i m i t i v e s ") + Primitive_label.setFont(QtGui.QFont('Candara', Title_Text_Size)) + #Primitive_label.setAlignment(QtCore.Qt.AlignCenter) + SECTION_SETTING_LAYOUT.addWidget(Primitive_label) + + ###---------------------------------------------------- INTERACTIVE MODE + ###---------------------------------------------------- H LAYOUT + Modeling_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(Modeling_Hlyt) + + ###---------------------------------------------------- ICON + GlobalScaleImg = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "Placement_Drag.png") + GlobalScaleImg.setPixmap(pixmap) + Modeling_Hlyt.addWidget(GlobalScaleImg) + + ###---------------------------------------------------- MODE LABEL + InteractiveMode_label = QtWidgets.QLabel(self) + InteractiveMode_label.setText("Interactive Mode :") + if WIN_DISPLAY_SIZE == 1: # 125 + InteractiveMode_label.setFont(QtGui.QFont('Candara', Text_Size)) + #InteractiveMode_label.setFixedHeight(19) + Modeling_Hlyt.addWidget(InteractiveMode_label) + + ###---------------------------------------------------- CHECKBOX + self.InteractivePlacementCbx = QtWidgets.QCheckBox() + self.InteractivePlacementCbx.setFixedSize(20, 20) + self.InteractivePlacementCbx.toggled.connect(self.PrimMode_Interactive) + if PRIM_MODE == 0: + self.InteractivePlacementCbx.setChecked(0) + else: + self.InteractivePlacementCbx.setChecked(1) + Modeling_Hlyt.addWidget(self.InteractivePlacementCbx) + + + + + + + ###---------------------------------------------------- ON TOP OF MODE + ###---------------------------------------------------- H LAYOUT + OnTopOf_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(OnTopOf_Hlyt) + + ###---------------------------------------------------- ICON + GlobalScaleImg = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "Prim_OnTopOf.png") + GlobalScaleImg.setPixmap(pixmap) + OnTopOf_Hlyt.addWidget(GlobalScaleImg) + + ###---------------------------------------------------- MODE LABEL + OnTopOf_label = QtWidgets.QLabel(self) + OnTopOf_label.setText("On Top of Selection :") + if WIN_DISPLAY_SIZE == 1: # 125 + OnTopOf_label.setFont(QtGui.QFont('Candara', Text_Size)) + #OnTopOf_label.setFixedHeight(19) + OnTopOf_Hlyt.addWidget(OnTopOf_label) + + ###---------------------------------------------------- CHECKBOX + self.OnTopOf_Cbx = QtWidgets.QCheckBox() + self.OnTopOf_Cbx.setFixedSize(20, 20) + self.OnTopOf_Cbx.toggled.connect(self.Prim_TopOF) + if PRIM_TOPOF == 0: + self.OnTopOf_Cbx.setChecked(0) + else: + self.OnTopOf_Cbx.setChecked(1) + OnTopOf_Hlyt.addWidget(self.OnTopOf_Cbx) + OnTopOf_Hlyt.addStretch() + + + + + + + + #####---------------------------------------------------- / SEPARATOR / + self.Separator = QtWidgets.QPushButton() + self.Separator.setFixedSize(separatorWidth,iconButtonSize) + self.Separator.setObjectName("Separator") + self.Separator.setIconSize(QtCore.QSize(26, iconButtonSize)) + self.Separator.setIcon(QtGui.QIcon(IconPath + "SeparatorBtn.png")) + self.Separator.setEnabled(0) + Modeling_Hlyt.addWidget(self.Separator) + + + ## COMBO UNIT // HIDE + self.UnitComboList = [ + 'cm', + 'inch', + ] + + self.UnitCombo = QtWidgets.QComboBox() + self.UnitCombo.addItems(self.UnitComboList) + self.UnitCombo.setFixedWidth(50) + self.UnitCombo.setFixedHeight(20) + #self.UnitCombo.currentIndexChanged.connect(self.SET_Theme) + self.UnitCombo.setCurrentIndex(1) + #Modeling_Hlyt.addWidget(self.UnitCombo) + + + + ###---------------------------------------------------- SIZE MULTIPLICATEUR + SizeM_label = QtWidgets.QLabel(self) + SizeM_label.setText("Size X :") + if WIN_DISPLAY_SIZE == 1: # 125 + SizeM_label.setFont(QtGui.QFont('Candara', Text_Size)) + #SizeM_label.setFixedHeight(19) + Modeling_Hlyt.addWidget(SizeM_label) + + self.SizeSpinBox = QtWidgets.QDoubleSpinBox() + self.SizeSpinBox.setDecimals(1) + + + self.SizeSpinBox.setFixedWidth(40) + self.SizeSpinBox.setFixedHeight(23) + + self.SizeSpinBox.setRange(0, 10000) + self.SizeSpinBox.setValue(PRIM_SIZE) + self.SizeSpinBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons) + self.SizeSpinBox.editingFinished.connect(self.set_MultiSize) + Modeling_Hlyt.addWidget(self.SizeSpinBox) + + + SECTION_SETTING_LAYOUT.addSpacing(2) + Modeling_Hlyt.addStretch() + Modeling_Hlyt.setSpacing(6) + + + + ###------------------------------------------------------------------------------------// MESH + ###---------------------------------------------------- TITLE + Sym_Label = QtWidgets.QLabel(self) + Sym_Label.setText(" / M e s h ") + Sym_Label.setFont(QtGui.QFont('Candara', Title_Text_Size)) + #Sym_Label.setAlignment(QtCore.Qt.AlignCenter) + SECTION_SETTING_LAYOUT.addWidget(Sym_Label) + + ###---------------------------------------------------- H LAYOUT + Symmetry_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(Symmetry_Hlyt) + + ###---------------------------------------------------- ICON + GlobalScaleImg = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "Sym_Setting.png") + GlobalScaleImg.setPixmap(pixmap) + Symmetry_Hlyt.addWidget(GlobalScaleImg) + + ###---------------------------------------------------- SYM LABEL + SymetryDefault_label = QtWidgets.QLabel(self) + SymetryDefault_label.setText("Symmetry Default Axis :") + if WIN_DISPLAY_SIZE == 1: # 125 + SymetryDefault_label.setFont(QtGui.QFont('Candara', Text_Size)) + SymetryDefault_label.setFixedHeight(22) + Symmetry_Hlyt.addWidget(SymetryDefault_label) + + ###---------------------------------------------------- SYM AXIS + AXIS = (json.load(open(PreferencePath + 'Pref_SymAxis.json', "r"))['VALUE']) + + itemsList = [" X", " Y", " Z"] + self.SymAxisChoice_combo = QtWidgets.QComboBox(self) + self.SymAxisChoice_combo.setFixedWidth(35) + self.SymAxisChoice_combo.setFixedHeight(22) + self.SymAxisChoice_combo.addItems(itemsList) + self.SymAxisChoice_combo.setCurrentIndex(AXIS) + self.SymAxisChoice_combo.currentIndexChanged.connect(self.set_SymAxisChoice) + Symmetry_Hlyt.addWidget(self.SymAxisChoice_combo) + + + + ###---------------------------------------------------- INSTANCE BTNcheckable + self.InstanceMode_btn = QtWidgets.QPushButton(" I N S T A N C E ") + self.InstanceMode_btn.setObjectName("StoreSet") + self.InstanceMode_btn.setFixedHeight(18) + if INSTANCE_MODE == 0: + self.InstanceMode_btn.setStyleSheet("color:#808080;") + else: + self.InstanceMode_btn.setStyleSheet("color:#29b1ea;") + + + + + if WIN_DISPLAY_SIZE == 1: #150 + self.InstanceMode_btn.setFont(QtGui.QFont('Calibri', 6)) + self.InstanceMode_btn.clicked.connect(self.set_InstanceMode) + Symmetry_Hlyt.addWidget(self.InstanceMode_btn) + + + + + + + + + Symmetry_Hlyt.addStretch() + SECTION_SETTING_LAYOUT.addSpacing(4) + + + + + + + + + + ###------------------------------------------------------------------------------------// TOOL + ###---------------------------------------------------- TITLE + Tool_Label = QtWidgets.QLabel(self) + Tool_Label.setText(" / T o o l ") + Tool_Label.setFont(QtGui.QFont('Candara', Title_Text_Size)) + SECTION_SETTING_LAYOUT.addWidget(Tool_Label) + + ###---------------------------------------------------- H LAYOUT + Tool_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(Tool_Hlyt) + + ###---------------------------------------------------- ICON + LocatorImg = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "Locator_cible_setting.png") + LocatorImg.setPixmap(pixmap) + Tool_Hlyt.addWidget(LocatorImg) + + ###---------------------------------------------------- SIZE MULTIPLICATEUR + Locator_label = QtWidgets.QLabel(self) + Locator_label.setText("Size Locators :") + if WIN_DISPLAY_SIZE == 1: # 125 + Locator_label.setFont(QtGui.QFont('Candara', Text_Size)) + Tool_Hlyt.addWidget(Locator_label) + + self.LocatorSpinBox = QtWidgets.QDoubleSpinBox() + self.LocatorSpinBox.setDecimals(1) + self.LocatorSpinBox.setFixedWidth(40) + self.LocatorSpinBox.setFixedHeight(23) + self.LocatorSpinBox.setRange(1, 1000) + self.LocatorSpinBox.setValue(LOCATOR_SIZE) + self.LocatorSpinBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons) + self.LocatorSpinBox.editingFinished.connect(self.set_LocatorSize) + Tool_Hlyt.addWidget(self.LocatorSpinBox) + + + SECTION_SETTING_LAYOUT.addSpacing(2) + Tool_Hlyt.addStretch() + Tool_Hlyt.setSpacing(6) + + + + + + + + + + + + + + + + + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B S H A D I N G + ##------------------------------------------------------------------------------------// + SECTION_SETTING_LAYOUT.addSpacing(5) + Shading_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(Shading_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Shading_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" S H A D I N G ") + MODELING_label.setFont(QtGui.QFont('Candara', Title_Text_Size)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + Shading_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Shading_Title_Hlyt.addWidget(separator) + + ###------------------------------------------------------------------------------------// Attributs PopUp + ###---------------------------------------------------- H LAYOUT + AE_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(AE_Hlyt) + + ###---------------------------------------------------- ICON + ShaderAttrib_img = QtWidgets.QLabel() + pixmap = QtGui.QPixmap(IconPath + "ShaderAttributs.png") + ShaderAttrib_img.setPixmap(pixmap) + AE_Hlyt.addWidget(ShaderAttrib_img) + + ###---------------------------------------------------- MODE LABEL + ShaderAttrib_label = QtWidgets.QLabel(self) + ShaderAttrib_label.setText("Shader Attributs in Floating Window") + if WIN_DISPLAY_SIZE == 1: # 125 + ShaderAttrib_label.setFont(QtGui.QFont('Candara', Text_Size)) + #ShaderAttrib_label.setFixedHeight(19) + AE_Hlyt.addWidget(ShaderAttrib_label) + + ###---------------------------------------------------- CHECKBOX + self.ShaderAttrib_Cbx = QtWidgets.QCheckBox() + self.ShaderAttrib_Cbx.setFixedSize(20, 20) + self.ShaderAttrib_Cbx.toggled.connect(self.ShaderAttributs_mode) + if SHADER_ATTRIBUTS == 0: + self.ShaderAttrib_Cbx.setChecked(0) + else: + self.ShaderAttrib_Cbx.setChecked(1) + AE_Hlyt.addWidget(self.ShaderAttrib_Cbx) + + + AE_Hlyt.addStretch() + + + + ###------------------------------------------------------------------------------------// LINKS + SECTION_SETTING_LAYOUT.addSpacing(4) + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + SECTION_SETTING_LAYOUT.addWidget(separator) + SECTION_SETTING_LAYOUT.addSpacing(4) + ###---------------------------------------------------- H LAYOUT + Link_HLyt = QtWidgets.QHBoxLayout() + SECTION_SETTING_LAYOUT.addLayout(Link_HLyt) + + icoSize = 26 + + + DiscordBtn = QtWidgets.QPushButton() + DiscordBtn.setFixedSize(icoSize, icoSize) + DiscordBtn.setIconSize(QtCore.QSize(icoSize, icoSize)) + DiscordBtn.setIcon(QtGui.QIcon(IconPath + "Discord_ico.png")) + DiscordBtn.setToolTip(" WZX Discord Link ") + DiscordBtn.clicked.connect(self.Link_Discord) + Link_HLyt.addWidget(DiscordBtn) + + + WzxStoreBtn = QtWidgets.QPushButton() + WzxStoreBtn.setFixedSize(icoSize, icoSize) + WzxStoreBtn.setIconSize(QtCore.QSize(icoSize, icoSize)) + WzxStoreBtn.setIcon(QtGui.QIcon(IconPath + "WzxStore_ico.png")) + WzxStoreBtn.setToolTip(" WZXStore Link ") + WzxStoreBtn.clicked.connect(self.Link_WzxStore) + Link_HLyt.addWidget(WzxStoreBtn) + + + + + + + + + + + + + + + + #------------------------------------------------ + ##---------------------------------------------------- D E F I N I T I O N + #------------------------------------------------ + def Link_Discord(self): + QtGui.QDesktopServices.openUrl( + QtCore.QUrl("https://discord.com/invite/KpkrvrU")) + + def Link_WzxStore(self): + QtGui.QDesktopServices.openUrl( + QtCore.QUrl("https://www.wzxstore.com/")) + + + + + def set_SymAxisChoice(self): + AxisChoice = self.SymAxisChoice_combo.currentIndex() + print(AxisChoice) + + + self.SymAxisChoice_combo.clearFocus() + open(PreferencePath + 'Pref_SymAxis.json', "w").write(json.dumps({"VALUE": AxisChoice})) + + + def set_MultiSize(self): + getSpinValue = self.SizeSpinBox.value() + self.SizeSpinBox.clearFocus() + open(PreferencePath + 'Setting_Primitives_Size.json', "w").write(json.dumps({"PRIM_SIZE": getSpinValue})) + + def set_LocatorSize(self): + getSpinValue = self.LocatorSpinBox.value() + self.LocatorSpinBox.clearFocus() + open(PreferencePath + 'Locator_Size.json', "w").write(json.dumps({"VALUE": getSpinValue})) + + def set_WinSize100(self): + open(PreferencePath + 'WinSize.json', "w").write(json.dumps({"VALUE": 0})) + from .. import ModIt_LAUNCH + import importlib + importlib.reload(ModIt_LAUNCH) + + + def set_WinSize150(self): + open(PreferencePath + 'WinSize.json', "w").write(json.dumps({"VALUE": 1})) + from .. import ModIt_LAUNCH + import importlib + importlib.reload(ModIt_LAUNCH) + + + def set_Floating(self): + open(PreferencePath + 'Dockable.json', "w").write(json.dumps({"VALUE": 0})) + from .. import ModIt_LAUNCH + import importlib + importlib.reload(ModIt_LAUNCH) + + + def set_Dockable(self): + open(PreferencePath + 'Dockable.json', "w").write(json.dumps({"VALUE": 1})) + from .. import ModIt_LAUNCH + import importlib + importlib.reload(ModIt_LAUNCH) + + def set_InstanceMode(self): + INSTANCE_MODE = (json.load(open(PreferencePath + 'InstanceMode.json', "r"))['VALUE']) + + if INSTANCE_MODE ==0: + open(PreferencePath + 'InstanceMode.json', "w").write(json.dumps({"VALUE": 1})) + self.InstanceMode_btn.setStyleSheet("color:#29b1ea;") + else: + open(PreferencePath + 'InstanceMode.json', "w").write(json.dumps({"VALUE": 0})) + self.InstanceMode_btn.setStyleSheet("color:#606060;") + + + #------------------------------------------------PRIM MODE + + def PrimMode_Interactive(self, checked): + if checked == True: + open(PreferencePath + 'Setting_Primitives_Placement.json', "w").write(json.dumps({"PRIM_MODE": 1})) + else: + open(PreferencePath + 'Setting_Primitives_Placement.json', "w").write(json.dumps({"PRIM_MODE": 0})) + if mc.optionVar(q="createPolyPrimitiveAsTool") == 1: + mc.ToggleCreatePolyPrimitivesAsTool() + if mc.optionVar(q="polyPrimitiveAsToolExitOnComplete") == 1: + mc.TogglePolyPrimitivesAsToolExitOnComplete() + + def Prim_TopOF(self, checked): + if checked == True: + open(PreferencePath + 'Setting_Primitives_OnTopOf.json', "w").write(json.dumps({"VALUE": 1})) + else: + open(PreferencePath + 'Setting_Primitives_OnTopOf.json', "w").write(json.dumps({"VALUE": 0})) + + + + + + def ShaderAttributs_mode(self, checked): + if checked == True: + open(PreferencePath + 'ShaderAttributs.json', "w").write(json.dumps({"VALUE": 1})) + else: + open(PreferencePath + 'ShaderAttributs.json', "w").write(json.dumps({"VALUE": 0})) + + + + + + def Autoload_ON_OFF(self, checked): + if checked == True: + open(PreferencePath + 'Autoload.json', "w").write(json.dumps({"VALUE": 1})) + + UserSetupPath = ModIt_Global.UserScriptFolder + "/userSetup.py" + + # Open a file with access mode 'a' + file_object = open(UserSetupPath, 'a') + # Append 'hello' at the end of file + file_object.write(""" +import maya.cmds as cmds +def ModItAutoLoad (): + from ModIt import ModIt_UI + import importlib + importlib.reload(ModIt_UI) + ModIt_UI + +cmds.evalDeferred(ModItAutoLoad, lowestPriority=True)""") + # Close the file + file_object.close() + + else: + open(PreferencePath + 'Autoload.json', "w").write(json.dumps({"VALUE": 0})) + + UserSetupPath = ModIt_Global.UserScriptFolder + "/userSetup.py" + TempFilePAth = ModIt_Global.UserScriptFolder + "/modItTemp.py" + import os + + with open(UserSetupPath, "r") as input: + with open(TempFilePAth, "w") as output: + # iterate all lines from file + for line in input: + # if text matches then don't write it + if line.strip("\n") != "def ModItAutoLoad ():": + output.write(line) + # replace file with original name + os.replace(TempFilePAth, UserSetupPath) + + + with open(UserSetupPath, "r") as input: + with open(TempFilePAth, "w") as output: + # iterate all lines from file + for line in input: + # if text matches then don't write it + if line.strip("\n") != "cmds.evalDeferred(ModItAutoLoad, lowestPriority=True)": + output.write(line) + # replace file with original name + os.replace(TempFilePAth, UserSetupPath) + + + with open(UserSetupPath, "r") as input: + with open(TempFilePAth, "w") as output: + # iterate all lines from file + for line in input: + # if text matches then don't write it + if line.strip("\n") != " from ModIt import ModIt_UI": + output.write(line) + # replace file with original name + os.replace(TempFilePAth, UserSetupPath) + + + + with open(UserSetupPath, "r") as input: + with open(TempFilePAth, "w") as output: + # iterate all lines from file + for line in input: + # if text matches then don't write it + if line.strip("\n") != " import importlib": + output.write(line) + # replace file with original name + os.replace(TempFilePAth, UserSetupPath) + + + with open(UserSetupPath, "r") as input: + with open(TempFilePAth, "w") as output: + # iterate all lines from file + for line in input: + # if text matches then don't write it + if line.strip("\n") != " ModIt_UI": + output.write(line) + # replace file with original name + os.replace(TempFilePAth, UserSetupPath) + + + with open(UserSetupPath, "r") as input: + with open(TempFilePAth, "w") as output: + # iterate all lines from file + for line in input: + # if text matches then don't write it + if line.strip("\n") != " importlib.reload(ModIt_UI)": + output.write(line) + # replace file with original name + os.replace(TempFilePAth, UserSetupPath) + diff --git a/Scripts/Modeling/Edit/ModIt/Shading/Layout_SHADING.py b/Scripts/Modeling/Edit/ModIt/Shading/Layout_SHADING.py new file mode 100644 index 0000000..775dc8d --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Shading/Layout_SHADING.py @@ -0,0 +1,747 @@ +##-------------------------------------------------------------------------- +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from ..Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui +import mtoa.core as core +from functools import partial + +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget + +import importlib +from .. import ModIt_Global + +importlib.reload(ModIt_Global) + +from .. import ModIt_CSS +importlib.reload(ModIt_CSS) + + +##______________________GLOBAL VAR +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath +RessourcePath = ModIt_Global.RessourcePath + +WIN_DISPLAY_SIZE =(json.load(open(PreferencePath + 'WinSize.json',"r"))['VALUE']) + + +# ****************************************** +# PARAMS +# ****************************************** +iconFixeSize = 32 +iconButtonSize = 30 +class MyCustomBtn_Widget(QtWidgets.QPushButton): + def __init__(self): + super().__init__() + self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + def mousePressEvent(self, event): + super().mousePressEvent(event) + if event.button() == QtCore.Qt.RightButton: + # emit the signal, we can grab the pos directly from the event, no need to get cursor position anymore + self.customContextMenuRequested.emit(event.pos()) + # make a call to mouseRelease event to restore button back to its original state + self.mouseReleaseEvent(event) + + + +class SHADING_LAYOUT(QtWidgets.QWidget): + def __init__(self, parent=None): + super().__init__(parent=parent) + + + SECTION_SHADING_LAYOUT = QtWidgets.QVBoxLayout() #_______ MAIN + SECTION_SHADING_LAYOUT.setContentsMargins(0, 0, 0, 0) + SECTION_SHADING_LAYOUT.setSpacing(0) + self.setLayout(SECTION_SHADING_LAYOUT) + + TOOLBAR_Hlyt = QtWidgets.QHBoxLayout() #_______ TOOLBAR + TOOLBAR_Hlyt.setContentsMargins(0,0,0,0) + TOOLBAR_Hlyt.setSpacing(0) + SECTION_SHADING_LAYOUT.addLayout(TOOLBAR_Hlyt) + + + + ##---------------------------------------------------------------------------------------- T O O L B A R + ##----------------------------------------------------------------------- LIGHTING + TOOLBAR_Hlyt.addSpacing(5) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,26) + self.Separator.setStyleSheet("background-color:#fba636;") + TOOLBAR_Hlyt.addWidget(self.Separator) + TOOLBAR_Hlyt.addSpacing(5) + + + self.Hdri_btn = MyCustomBtn_Widget() + self.Hdri_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.Hdri_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.Hdri_btn.setIcon(QtGui.QIcon(IconPath + "VP_Hdri.png")) + self.Hdri_btn.setToolTip(" Import an HDR Viewport Lighting Preset / Shift+Click : Select HDR ") + self.Hdri_btn.clicked.connect(partial(self.loadHDR, 1)) + TOOLBAR_Hlyt.addWidget(self.Hdri_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.Hdri_btn.customContextMenuRequested.connect(self.showPopupHDR) + # CUBE M E N U I T E M S + self.popupMenuHDR = QtWidgets.QMenu() + HDRI_1 = self.popupMenuHDR.addAction("HDR 1 - LookDev") + HDRI_1.triggered.connect(partial(self.loadHDR, 1)) + HDRI_2 = self.popupMenuHDR.addAction("HDR 2 - Studio") + HDRI_2.triggered.connect(partial(self.loadHDR, 2)) + HDRI_3 = self.popupMenuHDR.addAction("HDR 3 - Studio SpotLights") + HDRI_3.triggered.connect(partial(self.loadHDR, 3)) + HDRI_4 = self.popupMenuHDR.addAction("HDR 4 - Garden") + HDRI_4.triggered.connect(partial(self.loadHDR, 4)) + HDRI_5 = self.popupMenuHDR.addAction("HDR 5 - Parking") + HDRI_5.triggered.connect(partial(self.loadHDR, 5)) + HDRI_6 = self.popupMenuHDR.addAction("HDR 6 - Exterior") + HDRI_6.triggered.connect(partial(self.loadHDR, 6)) + + + + + + self.LightsOff_btn = MyCustomBtn_Widget() + self.LightsOff_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.LightsOff_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.LightsOff_btn.setIcon(QtGui.QIcon(IconPath + "VP_Lights.png")) + self.LightsOff_btn.setToolTip(" Turn ON / OFF Viewport Lighting ") + self.LightsOff_btn.clicked.connect(self.lightONOFF) + TOOLBAR_Hlyt.addWidget(self.LightsOff_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.LightsOff_btn.customContextMenuRequested.connect(self.showPopupLight) + # CUBE M E N U I T E M S + self.popupMenuLight = QtWidgets.QMenu() + GroundShadow = self.popupMenuLight.addAction(" Import Ground Shadow") + GroundShadow.triggered.connect(self.importShadowsGround) + + + ##----------------------------------------------------------------------- UVS + TOOLBAR_Hlyt.addSpacing(5) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,26) + self.Separator.setStyleSheet("background-color:#53c48d;") + TOOLBAR_Hlyt.addWidget(self.Separator) + TOOLBAR_Hlyt.addSpacing(5) + + self.UvShader_btn = QtWidgets.QPushButton() + self.UvShader_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.UvShader_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.UvShader_btn.setIcon(QtGui.QIcon(IconPath + "VP_UvShader.png")) + self.UvShader_btn.setToolTip(" UVs Shader / Shift+Click = Tiled Attributs ") + self.UvShader_btn.clicked.connect(self.UVShader) + TOOLBAR_Hlyt.addWidget(self.UvShader_btn) + + + + self.UvAuto_btn = QtWidgets.QPushButton() + self.UvAuto_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.UvAuto_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.UvAuto_btn.setIcon(QtGui.QIcon(IconPath + "VP_Auto.png")) + self.UvAuto_btn.setToolTip(" Automatic UVs on selected meshes ") + self.UvAuto_btn.clicked.connect(self.AutoUv) + TOOLBAR_Hlyt.addWidget(self.UvAuto_btn) + + self.UvPlanar_btn = MyCustomBtn_Widget() + self.UvPlanar_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.UvPlanar_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.UvPlanar_btn.setIcon(QtGui.QIcon(IconPath + "VP_Planar.png")) + self.UvPlanar_btn.setToolTip(" Planar UV Projection - Camera ") + self.UvPlanar_btn.clicked.connect(partial(self.PlanarUV, 0)) + TOOLBAR_Hlyt.addWidget(self.UvPlanar_btn) + # C O N N E C T P O P U P M E N U T O O U R B U T T O N + self.UvPlanar_btn.customContextMenuRequested.connect(self.showPopupPlanar) + # CUBE M E N U I T E M S + self.popupMenuPlanar = QtWidgets.QMenu() + Planar_Entry_X = self.popupMenuPlanar.addAction(" Planar Proj - X") + Planar_Entry_X.triggered.connect(partial(self.PlanarUV, 1)) + Planar_Entry_Y = self.popupMenuPlanar.addAction(" Planar Proj - Y") + Planar_Entry_Y.triggered.connect(partial(self.PlanarUV, 2)) + Planar_Entry_Z = self.popupMenuPlanar.addAction(" Planar Proj - Z") + Planar_Entry_Z.triggered.connect(partial(self.PlanarUV, 3)) + + + + + ##----------------------------------------------------------------------- SHADER + TOOLBAR_Hlyt.addSpacing(5) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(1,26) + self.Separator.setStyleSheet("background-color:#3fa6c5;") + TOOLBAR_Hlyt.addWidget(self.Separator) + TOOLBAR_Hlyt.addSpacing(5) + + + self.ShaderAttribut_btn = QtWidgets.QPushButton() + self.ShaderAttribut_btn.setFixedSize(iconFixeSize, iconFixeSize) + self.ShaderAttribut_btn.setIconSize(QtCore.QSize(iconButtonSize, iconButtonSize)) + self.ShaderAttribut_btn.setIcon(QtGui.QIcon(IconPath + "VP_GetShader.png")) + self.ShaderAttribut_btn.setToolTip(" Get Shader Attributs from Selected Mesh ") + self.ShaderAttribut_btn.clicked.connect(self.Get_ShaderAttributs) + TOOLBAR_Hlyt.addWidget(self.ShaderAttribut_btn) + + + + + + + + + ##-------------------------------------------------------------------------------------------------- S H A D E R S + ##----------------------------------------------------------------------- S I M P L E - Title + SECTION_SHADING_LAYOUT.addSpacing(8) + Simple_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SHADING_LAYOUT.addLayout(Simple_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Simple_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" S I M P L E ") + if WIN_DISPLAY_SIZE == 0: # 125 + MODELING_label.setFont(QtGui.QFont('Candara', 8)) + else: + MODELING_label.setFont(QtGui.QFont('Candara', 7)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + Simple_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Simple_Title_Hlyt.addWidget(separator) + SECTION_SHADING_LAYOUT.addSpacing(6) + + ##----------------------------------------------------------------------- S I M P L E - Shaders + Simple_PNGList = [] + gridIconContainerSize = 44 + gridIconSize = 46 + + Simple_Base_path = RessourcePath + "Shader/Simple" + listAllInFolder = os.listdir(Simple_Base_path) + + for each in listAllInFolder: + full_Simple_filePath = Simple_Base_path + "/" + each + #Find and keep only .png files + if full_Simple_filePath.endswith(".png"): + Simple_PNGList.append(full_Simple_filePath) + + grid_Lyt = QtWidgets.QGridLayout() + grid_Lyt.setSpacing(0) + SECTION_SHADING_LAYOUT.addLayout(grid_Lyt) + + + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Simple_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Simple_PNGList.index(each)] + yPos = positions[Simple_PNGList.index(each)] + self.SimpleShd_btn = QtWidgets.QPushButton() + self.SimpleShd_btn.setFixedSize(gridIconContainerSize, gridIconContainerSize) + self.SimpleShd_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.SimpleShd_btn.setIcon(QtGui.QIcon(each)) + self.SimpleShd_btn.setToolTip(" Shift + Click : Shader Attibuts") + self.SimpleShd_btn.clicked.connect(partial(self.Import_Shader, Asset_ma_path)) + + grid_Lyt.addWidget(self.SimpleShd_btn, xPos[0], yPos[1]) + + + ##----------------------------------------------------------------------- P L A S T I C - Title + SECTION_SHADING_LAYOUT.addSpacing(8) + Plastic_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SHADING_LAYOUT.addLayout(Plastic_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Plastic_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" P L A S T I C ") + if WIN_DISPLAY_SIZE == 0: # 125 + MODELING_label.setFont(QtGui.QFont('Candara', 8)) + else: + MODELING_label.setFont(QtGui.QFont('Candara', 7)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + Plastic_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Plastic_Title_Hlyt.addWidget(separator) + SECTION_SHADING_LAYOUT.addSpacing(6) + ##----------------------------------------------------------------------- P L A S T I C - Shaders + gridIconContainerSize = 44 + gridIconSize = 46 + + Plastic_PNGList = [] + Plastic_Base_path = RessourcePath + "Shader/Plastic" + listAllInFolder = os.listdir(Plastic_Base_path) + + for each in listAllInFolder: + full_Plastic_filePath = Plastic_Base_path + "/" + each + #Find and keep only .png files + if full_Plastic_filePath.endswith(".png"): + Plastic_PNGList.append(full_Plastic_filePath) + + Simple_Grid_Lyt = QtWidgets.QGridLayout() + Simple_Grid_Lyt.setSpacing(0) + SECTION_SHADING_LAYOUT.addLayout(Simple_Grid_Lyt) + + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Plastic_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Plastic_PNGList.index(each)] + yPos = positions[Plastic_PNGList.index(each)] + self.Asset_btn = QtWidgets.QPushButton() + self.Asset_btn.setFixedSize(gridIconContainerSize, gridIconContainerSize) + self.Asset_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.Asset_btn.setIcon(QtGui.QIcon(each)) + self.Asset_btn.setToolTip(" Shift + Click : Shader Attibuts") + self.Asset_btn.clicked.connect(partial(self.Import_Shader, Asset_ma_path)) + Simple_Grid_Lyt.addWidget(self.Asset_btn, xPos[0], yPos[1]) + + + + + ##----------------------------------------------------------------------- M E T A L - Title + SECTION_SHADING_LAYOUT.addSpacing(8) + Metal_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SHADING_LAYOUT.addLayout(Metal_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Metal_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" M E T A L ") + if WIN_DISPLAY_SIZE == 0: # 125 + MODELING_label.setFont(QtGui.QFont('Candara', 8)) + else: + MODELING_label.setFont(QtGui.QFont('Candara', 7)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + Metal_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Metal_Title_Hlyt.addWidget(separator) + SECTION_SHADING_LAYOUT.addSpacing(6) + ##----------------------------------------------------------------------- M E T A L - Shaders + Metal_PNGList = [] + + Metal_Base_path = RessourcePath + "Shader/Metal" + listAllInFolder = os.listdir(Metal_Base_path) + + for each in listAllInFolder: + full_Metal_filePath = Metal_Base_path + "/" + each + #Find and keep only .png files + if full_Metal_filePath.endswith(".png"): + Metal_PNGList.append(full_Metal_filePath) + + Metal_Grid_Lyt = QtWidgets.QGridLayout() + Metal_Grid_Lyt.setSpacing(0) + SECTION_SHADING_LAYOUT.addLayout(Metal_Grid_Lyt) + + + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Metal_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Metal_PNGList.index(each)] + yPos = positions[Metal_PNGList.index(each)] + self.MetalShd_btn = QtWidgets.QPushButton() + self.MetalShd_btn.setFixedSize(gridIconContainerSize, gridIconContainerSize) + self.MetalShd_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.MetalShd_btn.setIcon(QtGui.QIcon(each)) + self.MetalShd_btn.setToolTip(" Shift + Click : Shader Attibuts") + self.MetalShd_btn.clicked.connect(partial(self.Import_Shader, Asset_ma_path)) + + Metal_Grid_Lyt.addWidget(self.MetalShd_btn, xPos[0], yPos[1]) + + + + ##----------------------------------------------------------------------- G L A S S - Title + SECTION_SHADING_LAYOUT.addSpacing(8) + Glass_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SHADING_LAYOUT.addLayout(Glass_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Glass_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" G L A S S ") + if WIN_DISPLAY_SIZE == 0: # 125 + MODELING_label.setFont(QtGui.QFont('Candara', 8)) + else: + MODELING_label.setFont(QtGui.QFont('Candara', 7)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + Glass_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Glass_Title_Hlyt.addWidget(separator) + SECTION_SHADING_LAYOUT.addSpacing(6) + + ##----------------------------------------------------------------------- G L A S S - Shaders + Glass_PNGList = [] + + Glass_Base_path = RessourcePath + "Shader/Glass" + listAllInFolder = os.listdir(Glass_Base_path) + + for each in listAllInFolder: + full_Glass_filePath = Glass_Base_path + "/" + each + #Find and keep only .png files + if full_Glass_filePath.endswith(".png"): + Glass_PNGList.append(full_Glass_filePath) + + Glass_Grid_Lyt = QtWidgets.QGridLayout() + Glass_Grid_Lyt.setSpacing(0) + SECTION_SHADING_LAYOUT.addLayout(Glass_Grid_Lyt) + + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Glass_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Glass_PNGList.index(each)] + yPos = positions[Glass_PNGList.index(each)] + self.GlassShd_btn = QtWidgets.QPushButton() + self.GlassShd_btn.setFixedSize(gridIconContainerSize, gridIconContainerSize) + self.GlassShd_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.GlassShd_btn.setIcon(QtGui.QIcon(each)) + self.GlassShd_btn.setToolTip(" Shift + Click : Shader Attibuts") + self.GlassShd_btn.clicked.connect(partial(self.Import_Shader, Asset_ma_path)) + Glass_Grid_Lyt.addWidget(self.GlassShd_btn, xPos[0], yPos[1]) + + + ##----------------------------------------------------------------------- P L A T E - Title + SECTION_SHADING_LAYOUT.addSpacing(8) + Plate_Title_Hlyt = QtWidgets.QHBoxLayout() + SECTION_SHADING_LAYOUT.addLayout(Plate_Title_Hlyt) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Plate_Title_Hlyt.addWidget(separator) + + MODELING_label = QtWidgets.QLabel(self) + MODELING_label.setText(" P L A T E ") + if WIN_DISPLAY_SIZE == 0: # 125 + MODELING_label.setFont(QtGui.QFont('Candara', 8)) + else: + MODELING_label.setFont(QtGui.QFont('Candara', 7)) + MODELING_label.setAlignment(QtCore.Qt.AlignCenter) + Plate_Title_Hlyt.addWidget(MODELING_label) + + separator = QtWidgets.QLabel('') + separator.setStyleSheet( "QLabel {background-color: #3e3e3e; padding: 0; margin: 0; border-bottom: 1 solid #848484; border-top: 1 solid #2a2a2a;}") + separator.setMaximumHeight(2) + Plate_Title_Hlyt.addWidget(separator) + SECTION_SHADING_LAYOUT.addSpacing(6) + ##----------------------------------------------------------------------- P L A T E - Shaders + Plate_PNGList = [] + + Plate_Base_path = RessourcePath + "Shader/Plate" + listAllInFolder = os.listdir(Plate_Base_path) + + for each in listAllInFolder: + full_Plate_filePath = Plate_Base_path + "/" + each + #Find and keep only .png files + if full_Plate_filePath.endswith(".png"): + Plate_PNGList.append(full_Plate_filePath) + + Plate_Grid_Lyt = QtWidgets.QGridLayout() + Plate_Grid_Lyt.setSpacing(0) + SECTION_SHADING_LAYOUT.addLayout(Plate_Grid_Lyt) + + + positions = [(x, y) for x in range(10) for y in range(6)] + for each in Plate_PNGList: + Asset_ma_path = each.replace(".png", ".ma") + xPos = positions[Plate_PNGList.index(each)] + yPos = positions[Plate_PNGList.index(each)] + self.PlateShd_btn = QtWidgets.QPushButton() + self.PlateShd_btn.setFixedSize(gridIconContainerSize, gridIconContainerSize) + self.PlateShd_btn.setIconSize(QtCore.QSize(gridIconSize, gridIconSize)) + self.PlateShd_btn.setIcon(QtGui.QIcon(each)) + self.PlateShd_btn.setToolTip( " Shift + Click : Shader Attibuts") + self.PlateShd_btn.clicked.connect(partial(self.Import_Shader, Asset_ma_path)) + + Plate_Grid_Lyt.addWidget(self.PlateShd_btn, xPos[0], yPos[1]) + + #---------------------------------------------------------------- + ##------------------------------------------------------------------------------------ D E F I N I T I O N + #---------------------------------------------------------------- + + + def BAM(self, name): + print("BAMMM " + name) + + + def Import_Shader(self, shdPath): + shaderName = str(shdPath.split("/")[-1].replace(".ma", "")) + selection = mc.ls(sl = True) + modifiers = QtWidgets.QApplication.keyboardModifiers() + shaderAttributPopUp = (json.load(open(PreferencePath + 'ShaderAttributs.json', "r"))['VALUE']) + + # Turn ON Texture VP + panel = cmds.getPanel(withFocus=True) + # This happens when last focus was on panel + # that got deleted (e.g. `capture()` then `parse_active_view()`) + if not panel or "modelPanel" not in panel: + raise RuntimeError("No active model panel found") + mc.modelEditor(panel, e=1, displayTextures=1) + mc.modelEditor(panel, e=1, udm=0) + + if selection == []: + if mc.objExists(shaderName): + #mc.select(shaderName) + mel.eval('commitAENotes($gAECurrentTab);showEditorExact"' + shaderName + '";') + if shaderAttributPopUp == 1: + mel.eval("commitAENotes($gAECurrentTab);copyAEWindow;") + else: + ModIt_Global.WarningWindow(" You should select a Mesh first.", 300) + return + else: + if modifiers == QtCore.Qt.ShiftModifier: + if mc.objExists(shaderName): + # mc.select(shaderName) + mel.eval('commitAENotes($gAECurrentTab);showEditorExact"' + shaderName + '";') + if shaderAttributPopUp == 1: + mel.eval("commitAENotes($gAECurrentTab);copyAEWindow;") + else: + mc.file(shdPath, i=True) + mc.select(selection) + mc.hyperShade(a=shaderName) + mel.eval('commitAENotes($gAECurrentTab);showEditorExact"' + shaderName + '";') + if shaderAttributPopUp == 1: + mel.eval("commitAENotes($gAECurrentTab);copyAEWindow;") + else: + if mc.objExists(shaderName): + mc.hyperShade(a= shaderName) + + else: + mc.file(shdPath, i=True) + mc.select(selection) + mc.hyperShade(a=shaderName) + + + def Get_ShaderAttributs(self): + theNodes = mc.ls(sl=True, dag=True, s=True) + if theNodes == []: + ModIt_Global.WarningWindow(" You should select a Mesh first.", 300) + return + else: + shadeEng = mc.listConnections(theNodes, type="shadingEngine") + materials = mc.ls(mc.listConnections(shadeEng), materials=True, hd=1) + mc.select(materials) + print("MATERAIL = " + str(materials)) + mel.eval('commitAENotes($gAECurrentTab);showEditorExact"' + str(materials[0]) + '";') + shaderAttributPopUp = (json.load(open(PreferencePath + 'ShaderAttributs.json', "r"))['VALUE']) + if shaderAttributPopUp == 1: + mel.eval("commitAENotes($gAECurrentTab);copyAEWindow;") + + + def UVShader(self): + shaderPath = RessourcePath + "/Shader/ModIt_UVs_shd.ma" + shaderName = "ModIt_Uvs_shd" + selection = mc.ls(sl=True, fl=True, dag=True) + modifiers = QtWidgets.QApplication.keyboardModifiers() + + # Turn ON Texture VP + panel = cmds.getPanel(withFocus=True) + # This happens when last focus was on panel + # that got deleted (e.g. `capture()` then `parse_active_view()`) + if not panel or "modelPanel" not in panel: + raise RuntimeError("No active model panel found") + mc.modelEditor(panel, e=1, displayTextures=1) + mc.modelEditor(panel, e=1, udm=0) + + if selection == []: + if mc.objExists(shaderName): + if mc.window("UvShader_Edit_FloatWindows", exists=True): + mc.deleteUI("UvShader_Edit_FloatWindows") + + get_U_value = mc.getAttr("ModIt_Uvs_scale.repeatU") + get_V_value = mc.getAttr("ModIt_Uvs_scale.repeatV") + + mc.window("UvShader_Edit_FloatWindows", title='UV Shader Tile', s=True, w=500) + mc.columnLayout(adj=True, w=400) + mc.separator(h=5, style='none') + mc.floatSliderGrp('Slider_U_Tile', l= " U Tile ", minValue=0.1, max=10, po=True, field=True, dc= self.set_U_value, v=get_U_value, adj=0, cat=[1, "left", 3], cw=[1, 45]) + mc.floatSliderGrp('Slider_V_Tile', l= " V Tile ", minValue=0.1, max=10, po=True, field=True, dc= self.set_V_value, v=get_V_value, adj=0, cat=[1, "left", 3], cw=[1, 45]) + mc.separator(h=5, style='none') + mc.showWindow() + + else: + ModIt_Global.WarningWindow(" You should select a Mesh first.", 300) + return + + else: + if modifiers == QtCore.Qt.ShiftModifier: + if mc.objExists(shaderName): + if mc.window("UvShader_Edit_FloatWindows", exists=True): + mc.deleteUI("UvShader_Edit_FloatWindows") + + get_U_value = mc.getAttr("ModIt_Uvs_scale.repeatU") + get_V_value = mc.getAttr("ModIt_Uvs_scale.repeatV") + + mc.window("UvShader_Edit_FloatWindows", title='UV Shader Tile', s=True, w=500) + mc.columnLayout(adj=True, w=400) + mc.separator(h=5, style='none') + mc.floatSliderGrp('Slider_U_Tile', l="- U Tile ", minValue=0.1, maxValue=10, po=True, field=True, dc=self.set_U_value, + v=get_U_value, adj=0, cat=[1, "left", 3], cw=[1, 45]) + mc.floatSliderGrp('Slider_V_Tile', l="- V Tile ", minValue=0.1, maxValue=10, po=True, field=True, dc=self.set_V_value, + v=get_V_value, adj=0, cat=[1, "left", 3], cw=[1, 45]) + mc.separator(h=5, style='none') + mc.showWindow() + else: + pass + else: + if mc.objExists(shaderName): + mc.hyperShade(a=shaderName) + else: + mc.file(shaderPath, i=True) + mc.select(selection) + mc.hyperShade(a=shaderName) + + + + def set_U_value(self, *args): + myValueWidght = mc.floatSliderGrp("Slider_U_Tile", q=True, value=True) + mc.setAttr("ModIt_Uvs_scale.repeatU", myValueWidght ) + + def set_V_value(self, *args): + myValueWidght = mc.floatSliderGrp("Slider_V_Tile", q=True, value=True) + mc.setAttr("ModIt_Uvs_scale.repeatV", myValueWidght) + + + + def AutoUv(self): + selection = mc.ls(sl=True, fl=True, dag=True) + mc.undoInfo(openChunk=True, infinity=True) + + if selection == []: + print("Warning : You should select a mesh.") + else: + + mc.FreezeTransformations() + mc.UVAutomaticProjection() + + mc.select(selection) + mc.DeleteHistory() + mc.SelectVertexMask() + mc.SelectToggleMode() + mc.setToolTo('moveSuperContext') + + mc.undoInfo(closeChunk=True) + + def PlanarUV(self, modeValue): + mc.undoInfo(openChunk=True, infinity=True) + + selection = mc.ls(sl=True, fl=True, dag=True, type='mesh') + + if modeValue == 0: + mode = "c" + if modeValue == 1: + mode = "x" + if modeValue == 2: + mode = "y" + if modeValue == 3: + mode = "z" + + + for each in selection: + mc.DeleteHistory() + mc.polyProjection(each + '.f[*]', ch=1, type="planar", ibd=True, kir=True, md= mode) + mc.polyEditUV(pu=0.5, pv=0.5, su=0.5, sv=0.5, u=-0.25, v=0.25) + mc.select(each) + mc.DeleteHistory() + print("Planar UV Done") + + mc.undoInfo(closeChunk=True) + + + def showPopupPlanar(self, position): + self.popupMenuPlanar.exec_(self.UvPlanar_btn.mapToGlobal(position)) + self.UvPlanar_btn.update() + + def showPopupHDR(self, position): + self.popupMenuHDR.exec_(self.Hdri_btn.mapToGlobal(position)) + self.Hdri_btn.update() + + def showPopupLight(self, position): + self.popupMenuLight.exec_(self.LightsOff_btn.mapToGlobal(position)) + self.LightsOff_btn.update() + + + def lightONOFF(self): + allPanels = mc.getPanel(type='modelPanel') + getLightVal = mc.modelEditor(allPanels[-1], q=True, lights=1) + for each in allPanels: + if getLightVal == True: + mc.modelEditor(each, e=1, lights=0) + else: + mc.modelEditor(each, e=1, lights=1) + + def importShadowsGround(self): + groundPath = RessourcePath + "/HDR/Ground_Shadows.ma" + mc.file(groundPath, i=True) + + # Turn ON Texture VP + panel = cmds.getPanel(withFocus=True) + # This happens when last focus was on panel + # that got deleted (e.g. `capture()` then `parse_active_view()`) + if not panel or "modelPanel" not in panel: + raise RuntimeError("No active model panel found") + mc.modelEditor(panel, e=1, displayTextures=1) + mc.modelEditor(panel, e=1, udm=0) + + + + def loadHDR(self, number): + modifiers = QtWidgets.QApplication.keyboardModifiers() + if modifiers == QtCore.Qt.ShiftModifier: + if mc.objExists('ModIt_HDR_*'): + mc.select('ModIt_HDR_*') + else: + #Turn ON Light and Shadows VP + panel = cmds.getPanel(withFocus=True) + # This happens when last focus was on panel + # that got deleted (e.g. `capture()` then `parse_active_view()`) + if not panel or "modelPanel" not in panel: + raise RuntimeError("No active model panel found") + mc.DisplayLight() + mc.modelEditor(panel, e=1, shadows=1) + + + if mc.objExists('ModIt_HDR_*'): + mc.delete("ModIt_HDR_*") + if number == 1: + hdrPath = RessourcePath + "/HDR/ModIt_HDR_1_LookDev.ma" + elif number == 2: + hdrPath = RessourcePath + "/HDR/ModIt_HDR_2_Studio.ma" + elif number == 3: + hdrPath = RessourcePath + "/HDR/ModIt_HDR_3_StudioSpotLights.ma" + elif number == 4: + hdrPath = RessourcePath + "/HDR/ModIt_HDR_4_Garden.ma" + elif number == 5: + hdrPath = RessourcePath + "/HDR/ModIt_HDR_5_Parking.ma" + elif number == 6: + hdrPath = RessourcePath + "/HDR/ModIt_HDR_6_Exterior.ma" + + + mc.file(hdrPath, i=True) + + +