Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.pyc
.venv/*
*venv/*
*.egg-info/*
8 changes: 3 additions & 5 deletions rigsys/api/api_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

import maya.cmds as cmds

import rigsys.modules.motion as motion
import rigsys.modules.utility as utility
import rigsys.modules.deformer as deformer
from ..modules import motion, utility

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -84,7 +82,7 @@ def preBuild(self) -> list:

# Sort by build order
allModules.sort(key=lambda x: x.buildOrder)

return allModules

def build(self, buildLevel: int = -1, buildProxiesOnly: bool = False, usedSavedProxyData: bool = False,
Expand Down Expand Up @@ -131,7 +129,7 @@ def build(self, buildLevel: int = -1, buildProxiesOnly: bool = False, usedSavedP

if module.isMuted:
continue

if buildProxiesOnly:
if not module.bypassProxiesOnly and not isinstance(module, motion.MotionModuleBase):
logger.info(f"Skipping module {module.getFullName()} for buildProxiesOnly flag...")
Expand Down
4 changes: 3 additions & 1 deletion rigsys/lib/joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ def axisToVector(axis):
vec = [0, 0, -1]
return vec

# Function that takes a string vector and returns the proper numerical vector.

def axisFlip(axis):
"""Function that takes a string vector and returns the proper numerical vector."""
newAxis = None
if axis == "+x":
newAxis = "-x"
Expand All @@ -217,6 +218,7 @@ def axisFlip(axis):
newAxis = "+z"
return newAxis


def getCrossAxis(aim, up):
axies = [aim, up]
crossAxis = "+y"
Expand Down
4 changes: 1 addition & 3 deletions rigsys/lib/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def build(self):

def buildProxyModule(self):
if cmds.objExists("{}_{}_proxyMODULE".format(self.side, self.label)):
self.proxyModuleNode = "{}_{}_proxyMODULE".format(self.side, self.label)
self.proxyModuleNode = "{}_{}_proxyMODULE".format(self.side, self.label)
else:
self.proxyModuleNode = cmds.createNode("transform", n="{}_{}_proxyMODULE".format(self.side, self.label))
cmds.parent(self.proxyModuleNode, "proxies")


24 changes: 14 additions & 10 deletions rigsys/lib/skinning.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@

logger = logging.getLogger(__name__)

def writeSCLS(objects:list=[], path:str = "", suffix:str = "scls"):

def writeSCLS(objects: list = [], path: str = "", suffix: str = "scls"):
if len(objects) == 0:
objects = cmds.ls(sl=1)
if len(objects) == 0:
cmds.error("No Objects provided or selected.")
if path == "":
cmds.error("Path is empty")

for obj in objects:
cmds.deformerWeights(f"{obj}_{suffix}.json",
cmds.deformerWeights(f"{obj}_{suffix}.json",
ex=True,
p=path,
deformer=f"{obj}_{suffix}",
Expand All @@ -56,16 +57,17 @@ def writeSCLS(objects:list=[], path:str = "", suffix:str = "scls"):
dv=1.0
)

def readSCLS(objects:list=[], path:str = "", suffix:str = "scls"):

def readSCLS(objects: list = [], path: str = "", suffix: str = "scls"):
if len(objects) == 0:
objects = cmds.ls(sl=1)
if len(objects) == 0:
cmds.error("No Objects provided or selected.")
if path == "":
cmds.error("Path is empty")

for obj in objects:
cmds.deformerWeights(f"{obj}_{suffix}.json",
cmds.deformerWeights(f"{obj}_{suffix}.json",
im=True,
p=path,
deformer=f"{obj}_{suffix}",
Expand All @@ -75,7 +77,8 @@ def readSCLS(objects:list=[], path:str = "", suffix:str = "scls"):
dv=1.0
)

def createSCLS(object:str = "", joints:list = [], suffix:str = "scls", maxInfluences=4):

def createSCLS(object: str = "", joints: list = [], suffix: str = "scls", maxInfluences=4):
if object == "":
object = cmds.ls(sl=1)[-1]
if len(object) == 0:
Expand All @@ -86,12 +89,13 @@ def createSCLS(object:str = "", joints:list = [], suffix:str = "scls", maxInflue
if len(joints) == 0:
cmds.error("Mo Joints Provided")

cmds.skinCluster(joints,
object,
cmds.skinCluster(joints,
object,
n=f"{object}_{suffix}",
tsb=True,
mi=maxInfluences)



def getSelectedJoints():
print(cmds.ls(sl=1))

Expand Down
6 changes: 1 addition & 5 deletions rigsys/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@
import rigsys.modules.export as export


allModuleTypes = {}
allModuleTypes.update(motion.moduleTypes)
allModuleTypes.update(deformer.moduleTypes)
allModuleTypes.update(utility.moduleTypes)
allModuleTypes.update(export.moduleTypes)
__all__ = ["motion", "deformer", "utility", "export"]
41 changes: 7 additions & 34 deletions rigsys/modules/deformer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,9 @@
"""Deformer modules.
"""Deformer modules."""

The following code dynamically imports all subclasses of DeformerModuleBase present in this directory. That way, you can
import any module in this directory and it will automatically be available in the rigging system.
"""
from .deformerBase import DeformerModuleBase
from .skinClusterImportExport import skinClusterImportExport

from os.path import dirname, basename, isfile, join
import glob
import importlib
import inspect

# This is the only line that needs to be changed per __init__.py file. Make sure to keep "as baseModule" at the end
from .deformerBase import DeformerModuleBase as baseModule

# Import all modules in the current directory
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
for module in __all__:
importlib.import_module('.' + module, package=str(__name__))

# Get all the classes that inherit from baseModule
classes = {str(baseModule.__name__): baseModule}
for cls in baseModule.__subclasses__():
classes[cls.__name__] = cls
for subClass in cls.__subclasses__():
classes[subClass.__name__] = subClass

# Import all the classes that inherit from baseModule
for cls in classes.values():
classFilePath = inspect.getfile(cls)
importStatement = f"from .{basename(classFilePath)[:-3]} import {cls.__name__}"
exec(importStatement)

__all__ = list(classes.keys())

moduleTypes = classes.copy()
__all__ = [
"DeformerModuleBase",
"skinClusterImportExport",
]
31 changes: 17 additions & 14 deletions rigsys/modules/deformer/skinClusterImportExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

logger = logging.getLogger(__name__)


class skinClusterImportExport(deformerBase.DeformerModuleBase):
"""Build bind joints utility module."""

Expand Down Expand Up @@ -37,7 +38,7 @@ def run(self) -> None:
cmds.error(f"Missing the following joints {gatherMissing}; for {self.obj}_scls")
if self.path is None or self.path == "":
cmds.error(f"Path is incorrect {self.path}")

if self.createSCLS:
self.createSkinCluster()
if self.importSCLS:
Expand All @@ -46,31 +47,33 @@ def run(self) -> None:
self.writeWeights()

def createSkinCluster(self):
cmds.skinCluster(self.joints,
self.obj,
cmds.skinCluster(self.joints,
self.obj,
n=f"{self.obj}_scls",
tsb=True,
mi=self.maxInfluences)

def writeWeights(self):
print(f"Exporting {self.obj}_scls. . .")
cmds.deformerWeights(f"{self.obj}_scls.json",
cmds.deformerWeights(f"{self.obj}_scls.json",
ex=True,
p=self.path,
deformer=f"{self.obj}_scls",
m="index",
at=["maintainMaxInfluences", "maxInfluences"],
format="JSON",
dv=1.0
dv=1.0,
)

def readWeights(self):
print(f"Importing {self.obj}_scls. . .")
cmds.deformerWeights(f"{self.obj}_scls.json",
im=True,
p=self.path,
deformer=f"{self.obj}_scls",
m="index",
at=["maintainMaxInfluences", "maxInfluences"],
format="JSON",
dv=1.0
)
cmds.deformerWeights(
f"{self.obj}_scls.json",
im=True,
p=self.path,
deformer=f"{self.obj}_scls",
m="index",
at=["maintainMaxInfluences", "maxInfluences"],
format="JSON",
dv=1.0
)
43 changes: 9 additions & 34 deletions rigsys/modules/export/__init__.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
"""Export modules.
"""Export modules."""

The following code dynamically imports all subclasses of ExportModuleBase present in this directory. That way, you can
import any module in this directory and it will automatically be available in the rigging system.
"""
from .exportBase import ExportModuleBase
from .fbxExport import FBXExport
from .mbExport import MBExport

from os.path import dirname, basename, isfile, join
import glob
import importlib
import inspect

# This is the only line that needs to be changed per __init__.py file. Make sure to keep "as baseModule" at the end
from .exportBase import ExportModuleBase as baseModule

# Import all modules in the current directory
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
for module in __all__:
importlib.import_module('.' + module, package=str(__name__))

# Get all the classes that inherit from baseModule
classes = {str(baseModule.__name__): baseModule}
for cls in baseModule.__subclasses__():
classes[cls.__name__] = cls
for subClass in cls.__subclasses__():
classes[subClass.__name__] = subClass

# Import all the classes that inherit from baseModule
for cls in classes.values():
classFilePath = inspect.getfile(cls)
importStatement = f"from .{basename(classFilePath)[:-3]} import {cls.__name__}"
exec(importStatement)

__all__ = list(classes.keys())

moduleTypes = classes.copy()
__all__ = [
"ExportModuleBase",
"FBXExport",
"MBExport",
]
28 changes: 14 additions & 14 deletions rigsys/modules/motion/FK.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def __init__(self, rig, side="", label="", ctrlShapes="circle", ctrlScale=None,
mirror: bool = False, bypassProxiesOnly: bool = True, selectedPlug: str = "", selectedSocket: str = "",
aimAxis: str = "+x", upAxis: str = "-z") -> None:
"""Initialize the module."""
super().__init__(rig, side, label, buildOrder, isMuted,
parent, mirror, bypassProxiesOnly, selectedPlug,
super().__init__(rig, side, label, buildOrder, isMuted,
parent, mirror, bypassProxiesOnly, selectedPlug,
selectedSocket, aimAxis, upAxis)

self.addOffsets = addOffsets
self.ctrlShapes = ctrlShapes
self.ctrlScale = ctrlScale
if self.ctrlScale == None:
if self.ctrlScale is None:
self.ctrlScale = [1.0, 1.0, 1.0]
self.segments = segments

Expand Down Expand Up @@ -147,12 +147,12 @@ def buildModule(self):
FKGrps.append(grp)
FKCtrls.append(ctrl)
ctrlObject = ctrlCrv.Ctrl(
node=ctrl,
shape="circle",
scale=[self.ctrlScale[0], self.ctrlScale[1], self.ctrlScale[2]],
offset=[0, 0, 0],
orient=[0, 90, 0]
)
node=ctrl,
shape="circle",
scale=[self.ctrlScale[0], self.ctrlScale[1], self.ctrlScale[2]],
offset=[0, 0, 0],
orient=[0, 90, 0]
)
ctrlObject.giveCtrlShape()

if self.addOffsets:
Expand All @@ -163,7 +163,7 @@ def buildModule(self):
ctrlObject = ctrlCrv.Ctrl(
node=ctrl,
shape="square",
scale=[self.ctrlScale[0]*0.85, self.ctrlScale[1]*0.85, self.ctrlScale[2]*0.85],
scale=[self.ctrlScale[0] * 0.85, self.ctrlScale[1] * 0.85, self.ctrlScale[2] * 0.85],
offset=[0, 0, 0],
orient=[0, 90, 0]
)
Expand Down Expand Up @@ -191,13 +191,13 @@ def buildModule(self):
sc = cmds.scaleConstraint(ctrl, fJnt, n=f"{fJnt}_sc", mo=0)
if self.addOffsets:
for og in oGrps:
cmds.parent(og, FKCtrls[index])
index+=1
cmds.parent(og, FKCtrls[index])
index += 1
index = 0
for fg in FKGrps:
if fg != FKGrps[-1]:
cmds.parent(FKGrps[index+1], FKCtrls[index])
index+=1
cmds.parent(FKGrps[index + 1], FKCtrls[index])
index += 1

cmds.parent([FKGrps[0], FKJoints[0]], self.plugParent)
self.addSocketMetaData()
4 changes: 2 additions & 2 deletions rigsys/modules/motion/FKRail.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def __init__(self, rig, side="", label="", ctrlShapes="circle", ctrlScale=None,
mirror: bool = False, bypassProxiesOnly: bool = True, selectedPlug: str = "", selectedSocket: str = "",
aimAxis: str = "+x", upAxis: str = "-z") -> None:
"""Initialize the module."""
super().__init__(rig, side, label, buildOrder, isMuted,
parent, mirror, bypassProxiesOnly, selectedPlug,
super().__init__(rig, side, label, buildOrder, isMuted,
parent, mirror, bypassProxiesOnly, selectedPlug,
selectedSocket, aimAxis, upAxis)

if ctrlScale is None:
Expand Down
4 changes: 2 additions & 2 deletions rigsys/modules/motion/Root.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def __init__(self, rig, side="", label="", ctrlShapes="circle", ctrlScale=None,
bypassProxiesOnly: bool = True, selectedPlug: str = "", selectedSocket: str = "",
aimAxis: str = "+x", upAxis: str = "-z") -> None:
"""Initialize the module."""
super().__init__(rig, side, label, buildOrder, isMuted,
parent, mirror, bypassProxiesOnly, selectedPlug,
super().__init__(rig, side, label, buildOrder, isMuted,
parent, mirror, bypassProxiesOnly, selectedPlug,
selectedSocket, aimAxis, upAxis)

if ctrlScale is None:
Expand Down
Loading