Skip to content

Commit f0def58

Browse files
authored
Add files via upload
v1.3.0 : Updating window.py to support PySide6, adding 'Reset Preferences' button to the 'Extras' tab.
1 parent 39b8773 commit f0def58

File tree

4 files changed

+83
-50
lines changed

4 files changed

+83
-50
lines changed

skinner/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@
7676
'g' (global) arg set True.
7777
2024-10-02 : v1.2.1 : Bufixing core.importSkinChunks if multiple were imported
7878
at once : could have been duplicating them up / confusing itself.
79+
2024-10-26 : v1.3.0 : Updating window.py to support PySide6, adding 'Reset Preferences'
80+
button to the 'Extras' tab.
81+
7982
"""
8083
__author__ = "Eric Pavey"
81-
__version__ = "1.2.1"
84+
__version__ = "1.3.0"
8285
__source__ = "https://github.com/AKEric/skinner"
8386
__documentation__ = "https://github.com/AKEric/skinner/blob/main/README.md"
8487
__licence__ = "https://github.com/AKEric/skinner/blob/main/LICENSE.md"

skinner/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,22 @@
151151
import maya.api.OpenMaya as om2
152152

153153
# See notes above for install
154+
from skinner import __documentation__
154155
try:
155156
import numpy as np
156157
except ImportError:
158+
#om2.MGlobal.displayError(f"skinner.core : NumPy isn't installed, skinner won't function, see the docs: {__documentation__}")
157159
np = None
158160
try:
159161
from scipy.spatial import KDTree
160162
except ImportError:
163+
#om2.MGlobal.displayError(f"skinner.core : SciPy isn't installed, skinner won't function, see the docs: {__documentation__}")
161164
KDTree = None
162165

163166
from . import utils
167+
if not np or not KDTree or not str(sys.version).startswith("3"):
168+
utils.confirmDependencies()
169+
164170
from . import __version__
165171

166172
#---------------------------
@@ -3248,5 +3254,3 @@ def test() -> bool:
32483254

32493255
#------------
32503256

3251-
if not np or not KDTree or not str(sys.version).startswith("3"):
3252-
utils.confirmDependencies()

skinner/utils.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,47 +142,52 @@ def confirmDependencies():
142142
"""
143143
missingInfo = r"""----------------------------------------------------------------------------
144144
Skinner tool requires numpy & scipy to run in Python 3. To install them for
145-
your version of Maya, you can follow these steps, using Python 3.7 and
146-
Maya 2022+ as an example:
145+
your version of Maya, you can follow this Windows example, using Python 3.7 and
146+
Maya 2022+.
147147
148-
Open cmd shell **as admin**.
149-
Then line by line (using Windows as an example):
148+
* Close Maya if it is open.
149+
* Open a Windows Command Prompt **as administrator**.
150+
* Install the scipy & numpy packages, one at a time, but if you install scipy
151+
first, it should bring the numpy depdendencies along for the ride:
150152
151-
Install the numpy & scipy packages, one at a time:
152-
> C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe -m pip install numpy
153153
> C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe -m pip install scipy
154+
> C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe -m pip install numpy
154155
155-
You can optionally provide a '--target C:\some\path\to\target\dur' at the end of
156-
the above lines if you want to install them to a custom location that Maya sees.
156+
* You can optionally provide a '--target C:\some\path\to\target\dur' at the end of
157+
the above lines if you want to install them to a custom location that Maya sees.
158+
* In either case, if presuming one of them worked, you should see (using numpy
159+
as an example):
157160
158-
In either case, if presuming one of them worked, you should see (using numpy
159-
as an example):
160161
> Downloading numpy-1.19.5-cp37-cp37m-win_amd64.whl (13.2 MB)
161162
> Successfully installed numpy-1.19.5
162163
163-
They should install here by default, unless overridden by the --target arg:
164-
C:\Program Files\Autodesk\Maya2022\Python37\Lib\site-packages
164+
* They should install here by default, unless overridden by the --target arg:
165+
* C:\Program Files\Autodesk\Maya2022\Python37\Lib\site-packages
166+
167+
* Restart Maya.
168+
* In Maya's Script Editor, confirm the install:
165169
166-
Then in Maya's Script Editor, confirm the install:
167170
import numpy as np
168171
import scipy as sp
169172
print(np.__file__)
170173
print(sp.__file__)
171174
# C:\Program Files\Autodesk\Maya2022\Python37\lib\site-packages\numpy\__init__.py
172175
# C:\Program Files\Autodesk\Maya2022\Python37\lib\site-packages\scipy\__init__.py
176+
173177
----------------------------------------------------------------------------"""
174-
missingModule = False
178+
errors = []
175179
if not np:
176-
om2.MGlobal.displayError("Missing numpy install.")
177-
missingModule = True
180+
errors.append("Missing numpy install")
178181
if not KDTree:
179-
om2.MGlobal.displayError("Missing scipy install.")
180-
missingModule = True
182+
errors.append("Missing scipy install")
181183
if not str(sys.version).startswith("3"):
182-
om2.MGlobal.displayError("Not running in Python 3+, current version is: %s"%sys.version)
183-
missingModule = True
184+
errors.append(f"Not running in Python 3+, current version is: {sys.version}")
184185

185-
if missingModule:
186+
if errors:
187+
print("----------------------------------------------------------------------------")
188+
print("Skinner is missing required depedencies:")
189+
for err in errors:
190+
print(f" {err}")
186191
print(missingInfo)
187192

188193
def loadPlugin():

skinner/window.py

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
2024-06-10 : v1.2.0 : Rearranging some of the App import UI elements. Bugfixing
4040
App.importSkin : It wasn't closing the undoChunk. Adding the 'Auto-Fix Broken
4141
skinCluster' to the 'Extras' tab. Updating tooltips, making multi-line.
42+
2024-10-26 : v1.3.0 : Updating to support PySide6, adding 'Reset Preferences'
43+
button to the 'Extras' tab.
4244
4345
Examples:
4446
@@ -54,10 +56,13 @@
5456

5557
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin
5658

57-
from PySide2 import QtWidgets, QtCore, QtGui
58-
59-
from . import core, utils
59+
try:
60+
from PySide6 import QtWidgets, QtCore, QtGui
61+
except:
62+
from PySide2 import QtWidgets, QtCore, QtGui
6063

64+
from . import utils
65+
from . import core
6166
from . import __version__, __documentation__, __source__
6267

6368
#-----------------------
@@ -168,6 +173,7 @@ def __init__(self, vcExecCmd=None, vcDepotRoot=None, autoFillSubdir=None, docsOv
168173
iconPath = utils.getIconPath()
169174
if iconPath:
170175
self.setWindowIcon(QtGui.QIcon(iconPath))
176+
utils.confirmDependencies()
171177

172178
self.nnOptions = []
173179
self.weightPaths = []
@@ -382,7 +388,7 @@ def populate(self):
382388
self.widget_unbindFirst = QtWidgets.QCheckBox("Unbind First?")
383389
layout_moreOptions.addWidget(self.widget_unbindFirst)
384390
self.widget_unbindFirst.setToolTip("If any mesh is currently skinned, unbind it before import?\nThis will set the mesh back to the bindpose before the import.\nOtherwise the old/new skinning is merged together.")
385-
if self.settings.value(SETTING_UNBIND_FIRST, True):
391+
if self.settings.value(SETTING_UNBIND_FIRST, False):
386392
self.widget_unbindFirst.setChecked(True)
387393
self.widget_unbindFirst.clicked.connect(self.cbUnbindFirst)
388394
layout_import.addWidget(makeSeparator())
@@ -619,12 +625,21 @@ def populate(self):
619625
layout_docs.addWidget(widget_docs)
620626
widget_docs.clicked.connect(self.cbShowDocs)
621627

622-
self.widget_verboseLogging = QtWidgets.QCheckBox("Verbose Logging?")
623-
layout_extrasGrid.addWidget(self.widget_verboseLogging, 1,0)
624-
self.widget_verboseLogging.setToolTip("Print verbose results of the import/export operations to the Maya Script Editor?\nIf this is unchecked, nothing (unless errors) will be printed to the Script Editor.")
625-
if self.settings.value(SETTING_VERBOSE_LOG, True):
626-
self.widget_verboseLogging.setChecked(True)
627-
self.widget_verboseLogging.clicked.connect(self.cbVerboseLog)
628+
layout_loggingResetPrefs = QtWidgets.QHBoxLayout()
629+
layout_extrasGrid.addLayout(layout_loggingResetPrefs, 1,0)
630+
if layout_loggingResetPrefs:
631+
632+
self.widget_verboseLogging = QtWidgets.QCheckBox("Verbose Logging?")
633+
layout_loggingResetPrefs.addWidget(self.widget_verboseLogging)
634+
self.widget_verboseLogging.setToolTip("Print verbose results of the import/export operations to the Maya Script Editor?\nIf this is unchecked, nothing (unless errors) will be printed to the Script Editor.")
635+
if self.settings.value(SETTING_VERBOSE_LOG, True):
636+
self.widget_verboseLogging.setChecked(True)
637+
self.widget_verboseLogging.clicked.connect(self.cbVerboseLog)
638+
639+
widget_resetBut = QtWidgets.QPushButton("Reset Preferences")
640+
widget_resetBut.setToolTip("Reset all user changed values back to defaults.")
641+
layout_loggingResetPrefs.addWidget(widget_resetBut)
642+
widget_resetBut.clicked.connect(self.cbResetSettings)
628643

629644
layout_autoFill = QtWidgets.QHBoxLayout()
630645
layout_extrasGrid.addLayout(layout_autoFill, 1,1)
@@ -881,7 +896,7 @@ def cbMissingInfs(self):
881896
Callback executed to save the state of the 'Build Missing Influences?'
882897
checkbox.
883898
"""
884-
if self.widget_buildMissingInfs.checkState():
899+
if self.widget_buildMissingInfs.isChecked():
885900
self.settings.setValue(SETTING_BUILD_MISSING_INFS, 1)
886901
else:
887902
self.settings.setValue(SETTING_BUILD_MISSING_INFS, 0)
@@ -891,7 +906,7 @@ def cbForceUberChunk(self):
891906
Callback executed to save the state of the 'Force Import From UberChunk?'
892907
checkbox.
893908
"""
894-
if self.widget_forceUberChunk.checkState():
909+
if self.widget_forceUberChunk.isChecked():
895910
self.settings.setValue(SETTING_FORCE_UBERCHUNK, 1)
896911
else:
897912
self.settings.setValue(SETTING_FORCE_UBERCHUNK, 0)
@@ -902,7 +917,7 @@ def cbSelInstead(self):
902917
"""
903918
Callback executed to save the state of the 'Select instead of skin' checkbox.
904919
"""
905-
if self.widget_selectInstead.checkState():
920+
if self.widget_selectInstead.isChecked():
906921
self.settings.setValue(SETTING_SELECT_INSTEAD, 1)
907922
else:
908923
self.settings.setValue(SETTING_SELECT_INSTEAD, 0)
@@ -911,7 +926,7 @@ def cbVerboseLog(self):
911926
"""
912927
Callback executed to save the state of the 'Verbose Logging?'checkbox.
913928
"""
914-
if self.widget_verboseLogging.checkState():
929+
if self.widget_verboseLogging.isChecked():
915930
self.settings.setValue(SETTING_VERBOSE_LOG, 1)
916931
else:
917932
self.settings.setValue(SETTING_VERBOSE_LOG, 0)
@@ -1036,7 +1051,7 @@ def cbExportSetToBindpose(self):
10361051
Callback executed to save the state of the 'Set To Bindpose?' checkbox in the
10371052
export tab.
10381053
"""
1039-
if self.widget_exportSetBindpose.checkState():
1054+
if self.widget_exportSetBindpose.isChecked():
10401055
self.settings.setValue(SETTING_EXPORT_SET_TO_BINDPOSE, 1)
10411056
else:
10421057
self.settings.setValue(SETTING_EXPORT_SET_TO_BINDPOSE, 0)
@@ -1048,7 +1063,7 @@ def cbImpoprtUsingPreDeformedShapePos(self):
10481063
Positions?' checkbox in the import tab. It also unchecks 'Set To Bindpose'
10491064
and 'Unbind First'.
10501065
"""
1051-
if self.widget_usePreDeformedShape.checkState():
1066+
if self.widget_usePreDeformedShape.isChecked():
10521067
self.settings.setValue(SETTINGS_IMPORT_USE_PRE_DEFORMED_SHAPE, 1)
10531068

10541069
self.widget_importSetBindpose.setChecked(False)
@@ -1063,7 +1078,7 @@ def cbImportSetToBindpose(self):
10631078
Callback executed to save the state of the 'Set To Bindpose?' checkbox in the
10641079
import tab. This also unchecks 'Import Using Pre-Deformed Shape Positions?'.
10651080
"""
1066-
if self.widget_importSetBindpose.checkState():
1081+
if self.widget_importSetBindpose.isChecked():
10671082
self.settings.setValue(SETTING_IMPORT_SET_TO_BINDPOSE, 1)
10681083

10691084
self.widget_usePreDeformedShape.setChecked(False)
@@ -1077,7 +1092,7 @@ def cbUnbindFirst(self):
10771092
It also unchecks 'Import Using Pre-Deformed Shape Positions?' and enables
10781093
'Set To Bindpose'.
10791094
"""
1080-
if self.widget_unbindFirst.checkState():
1095+
if self.widget_unbindFirst.isChecked():
10811096
self.settings.setValue(SETTING_UNBIND_FIRST, 1)
10821097

10831098
self.widget_importSetBindpose.setChecked(True)
@@ -1088,6 +1103,12 @@ def cbUnbindFirst(self):
10881103
else:
10891104
self.settings.setValue(SETTING_UNBIND_FIRST, 0)
10901105

1106+
def cbResetSettings(self):
1107+
"""
1108+
Reset any user=based settings.
1109+
"""
1110+
self.settings.clear()
1111+
App()
10911112

10921113
#------------------
10931114
# Actions
@@ -1105,7 +1126,7 @@ def printSkinInfo(self):
11051126
printArgs = {}
11061127
for checkbox in self.widgets_printerCheckBoxes:
11071128
text = checkbox.text()
1108-
checked = int(checkbox.checkState())
1129+
checked = int(checkbox.isChecked())
11091130
if checked:
11101131
printArgs[text] = True
11111132
else:
@@ -1165,13 +1186,13 @@ def importSkin(self, mode="browser"):
11651186
fallbackSkinningMethod = "closestNeighbors"
11661187
elif uiFallbackSkinMethod == "Closest Point":
11671188
fallbackSkinningMethod = "closestPoint"
1168-
buildMissingInfs = True if int(self.widget_buildMissingInfs.checkState()) else False
1189+
buildMissingInfs = True if int(self.widget_buildMissingInfs.isChecked()) else False
11691190
setToBindpose = self.widget_importSetBindpose.isChecked()
1170-
forceUberChunk = True if int(self.widget_forceUberChunk.checkState()) else False
1171-
importUsingPreDeformedPoints = True if int(self.widget_usePreDeformedShape.checkState()) else False
1172-
unbindFirst = True if int(self.widget_unbindFirst.checkState()) else False
1173-
selInsteadOfSkin = True if int(self.widget_selectInstead.checkState()) else False
1174-
verbose = True if int(self.widget_verboseLogging.checkState()) else False #!!! NEED TO FIX
1191+
forceUberChunk = True if int(self.widget_forceUberChunk.isChecked()) else False
1192+
importUsingPreDeformedPoints = True if int(self.widget_usePreDeformedShape.isChecked()) else False
1193+
unbindFirst = True if int(self.widget_unbindFirst.isChecked()) else False
1194+
selInsteadOfSkin = True if int(self.widget_selectInstead.isChecked()) else False
1195+
verbose = True if int(self.widget_verboseLogging.isChecked()) else False #!!! NEED TO FIX
11751196
printOverview = False
11761197
printOverviewMode = "byImportType"
11771198
checkedButWidget = self.widget_importOvererviewGroup.checkedButton()
@@ -1270,7 +1291,7 @@ def exportSkin(self, mode="browser"):
12701291
elif mode == "temp":
12711292
path = core.TEMP_FILE_PATH
12721293

1273-
verbose = True if int(self.widget_verboseLogging.checkState()) else False
1294+
verbose = True if int(self.widget_verboseLogging.isChecked()) else False
12741295

12751296
setToBindPose = self.widget_exportSetBindpose.isChecked()
12761297

0 commit comments

Comments
 (0)