Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
v1.3.0 : Updating window.py to support PySide6, adding 'Reset Preferences' button to the 'Extras' tab.
  • Loading branch information
AKEric authored Oct 26, 2024
1 parent 39b8773 commit f0def58
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 50 deletions.
5 changes: 4 additions & 1 deletion skinner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@
'g' (global) arg set True.
2024-10-02 : v1.2.1 : Bufixing core.importSkinChunks if multiple were imported
at once : could have been duplicating them up / confusing itself.
2024-10-26 : v1.3.0 : Updating window.py to support PySide6, adding 'Reset Preferences'
button to the 'Extras' tab.
"""
__author__ = "Eric Pavey"
__version__ = "1.2.1"
__version__ = "1.3.0"
__source__ = "https://github.com/AKEric/skinner"
__documentation__ = "https://github.com/AKEric/skinner/blob/main/README.md"
__licence__ = "https://github.com/AKEric/skinner/blob/main/LICENSE.md"
8 changes: 6 additions & 2 deletions skinner/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,22 @@
import maya.api.OpenMaya as om2

# See notes above for install
from skinner import __documentation__
try:
import numpy as np
except ImportError:
#om2.MGlobal.displayError(f"skinner.core : NumPy isn't installed, skinner won't function, see the docs: {__documentation__}")
np = None
try:
from scipy.spatial import KDTree
except ImportError:
#om2.MGlobal.displayError(f"skinner.core : SciPy isn't installed, skinner won't function, see the docs: {__documentation__}")
KDTree = None

from . import utils
if not np or not KDTree or not str(sys.version).startswith("3"):
utils.confirmDependencies()

from . import __version__

#---------------------------
Expand Down Expand Up @@ -3248,5 +3254,3 @@ def test() -> bool:

#------------

if not np or not KDTree or not str(sys.version).startswith("3"):
utils.confirmDependencies()
47 changes: 26 additions & 21 deletions skinner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,47 +142,52 @@ def confirmDependencies():
"""
missingInfo = r"""----------------------------------------------------------------------------
Skinner tool requires numpy & scipy to run in Python 3. To install them for
your version of Maya, you can follow these steps, using Python 3.7 and
Maya 2022+ as an example:
your version of Maya, you can follow this Windows example, using Python 3.7 and
Maya 2022+.
Open cmd shell **as admin**.
Then line by line (using Windows as an example):
* Close Maya if it is open.
* Open a Windows Command Prompt **as administrator**.
* Install the scipy & numpy packages, one at a time, but if you install scipy
first, it should bring the numpy depdendencies along for the ride:
Install the numpy & scipy packages, one at a time:
> C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe -m pip install numpy
> C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe -m pip install scipy
> C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe -m pip install numpy
You can optionally provide a '--target C:\some\path\to\target\dur' at the end of
the above lines if you want to install them to a custom location that Maya sees.
* You can optionally provide a '--target C:\some\path\to\target\dur' at the end of
the above lines if you want to install them to a custom location that Maya sees.
* In either case, if presuming one of them worked, you should see (using numpy
as an example):
In either case, if presuming one of them worked, you should see (using numpy
as an example):
> Downloading numpy-1.19.5-cp37-cp37m-win_amd64.whl (13.2 MB)
> Successfully installed numpy-1.19.5
They should install here by default, unless overridden by the --target arg:
C:\Program Files\Autodesk\Maya2022\Python37\Lib\site-packages
* They should install here by default, unless overridden by the --target arg:
* C:\Program Files\Autodesk\Maya2022\Python37\Lib\site-packages
* Restart Maya.
* In Maya's Script Editor, confirm the install:
Then in Maya's Script Editor, confirm the install:
import numpy as np
import scipy as sp
print(np.__file__)
print(sp.__file__)
# C:\Program Files\Autodesk\Maya2022\Python37\lib\site-packages\numpy\__init__.py
# C:\Program Files\Autodesk\Maya2022\Python37\lib\site-packages\scipy\__init__.py
----------------------------------------------------------------------------"""
missingModule = False
errors = []
if not np:
om2.MGlobal.displayError("Missing numpy install.")
missingModule = True
errors.append("Missing numpy install")
if not KDTree:
om2.MGlobal.displayError("Missing scipy install.")
missingModule = True
errors.append("Missing scipy install")
if not str(sys.version).startswith("3"):
om2.MGlobal.displayError("Not running in Python 3+, current version is: %s"%sys.version)
missingModule = True
errors.append(f"Not running in Python 3+, current version is: {sys.version}")

if missingModule:
if errors:
print("----------------------------------------------------------------------------")
print("Skinner is missing required depedencies:")
for err in errors:
print(f" {err}")
print(missingInfo)

def loadPlugin():
Expand Down
73 changes: 47 additions & 26 deletions skinner/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
2024-06-10 : v1.2.0 : Rearranging some of the App import UI elements. Bugfixing
App.importSkin : It wasn't closing the undoChunk. Adding the 'Auto-Fix Broken
skinCluster' to the 'Extras' tab. Updating tooltips, making multi-line.
2024-10-26 : v1.3.0 : Updating to support PySide6, adding 'Reset Preferences'
button to the 'Extras' tab.
Examples:
Expand All @@ -54,10 +56,13 @@

from maya.app.general.mayaMixin import MayaQWidgetBaseMixin

from PySide2 import QtWidgets, QtCore, QtGui

from . import core, utils
try:
from PySide6 import QtWidgets, QtCore, QtGui
except:
from PySide2 import QtWidgets, QtCore, QtGui

from . import utils
from . import core
from . import __version__, __documentation__, __source__

#-----------------------
Expand Down Expand Up @@ -168,6 +173,7 @@ def __init__(self, vcExecCmd=None, vcDepotRoot=None, autoFillSubdir=None, docsOv
iconPath = utils.getIconPath()
if iconPath:
self.setWindowIcon(QtGui.QIcon(iconPath))
utils.confirmDependencies()

self.nnOptions = []
self.weightPaths = []
Expand Down Expand Up @@ -382,7 +388,7 @@ def populate(self):
self.widget_unbindFirst = QtWidgets.QCheckBox("Unbind First?")
layout_moreOptions.addWidget(self.widget_unbindFirst)
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.")
if self.settings.value(SETTING_UNBIND_FIRST, True):
if self.settings.value(SETTING_UNBIND_FIRST, False):
self.widget_unbindFirst.setChecked(True)
self.widget_unbindFirst.clicked.connect(self.cbUnbindFirst)
layout_import.addWidget(makeSeparator())
Expand Down Expand Up @@ -619,12 +625,21 @@ def populate(self):
layout_docs.addWidget(widget_docs)
widget_docs.clicked.connect(self.cbShowDocs)

self.widget_verboseLogging = QtWidgets.QCheckBox("Verbose Logging?")
layout_extrasGrid.addWidget(self.widget_verboseLogging, 1,0)
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.")
if self.settings.value(SETTING_VERBOSE_LOG, True):
self.widget_verboseLogging.setChecked(True)
self.widget_verboseLogging.clicked.connect(self.cbVerboseLog)
layout_loggingResetPrefs = QtWidgets.QHBoxLayout()
layout_extrasGrid.addLayout(layout_loggingResetPrefs, 1,0)
if layout_loggingResetPrefs:

self.widget_verboseLogging = QtWidgets.QCheckBox("Verbose Logging?")
layout_loggingResetPrefs.addWidget(self.widget_verboseLogging)
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.")
if self.settings.value(SETTING_VERBOSE_LOG, True):
self.widget_verboseLogging.setChecked(True)
self.widget_verboseLogging.clicked.connect(self.cbVerboseLog)

widget_resetBut = QtWidgets.QPushButton("Reset Preferences")
widget_resetBut.setToolTip("Reset all user changed values back to defaults.")
layout_loggingResetPrefs.addWidget(widget_resetBut)
widget_resetBut.clicked.connect(self.cbResetSettings)

layout_autoFill = QtWidgets.QHBoxLayout()
layout_extrasGrid.addLayout(layout_autoFill, 1,1)
Expand Down Expand Up @@ -881,7 +896,7 @@ def cbMissingInfs(self):
Callback executed to save the state of the 'Build Missing Influences?'
checkbox.
"""
if self.widget_buildMissingInfs.checkState():
if self.widget_buildMissingInfs.isChecked():
self.settings.setValue(SETTING_BUILD_MISSING_INFS, 1)
else:
self.settings.setValue(SETTING_BUILD_MISSING_INFS, 0)
Expand All @@ -891,7 +906,7 @@ def cbForceUberChunk(self):
Callback executed to save the state of the 'Force Import From UberChunk?'
checkbox.
"""
if self.widget_forceUberChunk.checkState():
if self.widget_forceUberChunk.isChecked():
self.settings.setValue(SETTING_FORCE_UBERCHUNK, 1)
else:
self.settings.setValue(SETTING_FORCE_UBERCHUNK, 0)
Expand All @@ -902,7 +917,7 @@ def cbSelInstead(self):
"""
Callback executed to save the state of the 'Select instead of skin' checkbox.
"""
if self.widget_selectInstead.checkState():
if self.widget_selectInstead.isChecked():
self.settings.setValue(SETTING_SELECT_INSTEAD, 1)
else:
self.settings.setValue(SETTING_SELECT_INSTEAD, 0)
Expand All @@ -911,7 +926,7 @@ def cbVerboseLog(self):
"""
Callback executed to save the state of the 'Verbose Logging?'checkbox.
"""
if self.widget_verboseLogging.checkState():
if self.widget_verboseLogging.isChecked():
self.settings.setValue(SETTING_VERBOSE_LOG, 1)
else:
self.settings.setValue(SETTING_VERBOSE_LOG, 0)
Expand Down Expand Up @@ -1036,7 +1051,7 @@ def cbExportSetToBindpose(self):
Callback executed to save the state of the 'Set To Bindpose?' checkbox in the
export tab.
"""
if self.widget_exportSetBindpose.checkState():
if self.widget_exportSetBindpose.isChecked():
self.settings.setValue(SETTING_EXPORT_SET_TO_BINDPOSE, 1)
else:
self.settings.setValue(SETTING_EXPORT_SET_TO_BINDPOSE, 0)
Expand All @@ -1048,7 +1063,7 @@ def cbImpoprtUsingPreDeformedShapePos(self):
Positions?' checkbox in the import tab. It also unchecks 'Set To Bindpose'
and 'Unbind First'.
"""
if self.widget_usePreDeformedShape.checkState():
if self.widget_usePreDeformedShape.isChecked():
self.settings.setValue(SETTINGS_IMPORT_USE_PRE_DEFORMED_SHAPE, 1)

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

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

self.widget_importSetBindpose.setChecked(True)
Expand All @@ -1088,6 +1103,12 @@ def cbUnbindFirst(self):
else:
self.settings.setValue(SETTING_UNBIND_FIRST, 0)

def cbResetSettings(self):
"""
Reset any user=based settings.
"""
self.settings.clear()
App()

#------------------
# Actions
Expand All @@ -1105,7 +1126,7 @@ def printSkinInfo(self):
printArgs = {}
for checkbox in self.widgets_printerCheckBoxes:
text = checkbox.text()
checked = int(checkbox.checkState())
checked = int(checkbox.isChecked())
if checked:
printArgs[text] = True
else:
Expand Down Expand Up @@ -1165,13 +1186,13 @@ def importSkin(self, mode="browser"):
fallbackSkinningMethod = "closestNeighbors"
elif uiFallbackSkinMethod == "Closest Point":
fallbackSkinningMethod = "closestPoint"
buildMissingInfs = True if int(self.widget_buildMissingInfs.checkState()) else False
buildMissingInfs = True if int(self.widget_buildMissingInfs.isChecked()) else False
setToBindpose = self.widget_importSetBindpose.isChecked()
forceUberChunk = True if int(self.widget_forceUberChunk.checkState()) else False
importUsingPreDeformedPoints = True if int(self.widget_usePreDeformedShape.checkState()) else False
unbindFirst = True if int(self.widget_unbindFirst.checkState()) else False
selInsteadOfSkin = True if int(self.widget_selectInstead.checkState()) else False
verbose = True if int(self.widget_verboseLogging.checkState()) else False #!!! NEED TO FIX
forceUberChunk = True if int(self.widget_forceUberChunk.isChecked()) else False
importUsingPreDeformedPoints = True if int(self.widget_usePreDeformedShape.isChecked()) else False
unbindFirst = True if int(self.widget_unbindFirst.isChecked()) else False
selInsteadOfSkin = True if int(self.widget_selectInstead.isChecked()) else False
verbose = True if int(self.widget_verboseLogging.isChecked()) else False #!!! NEED TO FIX
printOverview = False
printOverviewMode = "byImportType"
checkedButWidget = self.widget_importOvererviewGroup.checkedButton()
Expand Down Expand Up @@ -1270,7 +1291,7 @@ def exportSkin(self, mode="browser"):
elif mode == "temp":
path = core.TEMP_FILE_PATH

verbose = True if int(self.widget_verboseLogging.checkState()) else False
verbose = True if int(self.widget_verboseLogging.isChecked()) else False

setToBindPose = self.widget_exportSetBindpose.isChecked()

Expand Down

0 comments on commit f0def58

Please sign in to comment.