Skip to content

Commit

Permalink
Merge pull request #9 from mottosso/master
Browse files Browse the repository at this point in the history
Implement #7 and #8
  • Loading branch information
mottosso authored Jan 17, 2017
2 parents 4495656 + a60d24e commit 1f7569b
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bin/maya.bat
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if Not exist %WORKDIR% (
mkdir %WORKDIR%\images
rem etc..

copy %PYBLISH%\etc\maya\workspace.mel %WORKDIR% >NUL
copy %PYBLISH_MINDBENDER%\res\workspace.mel %WORKDIR% >NUL
)

:: userSetup.py files
Expand Down
3 changes: 3 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Example

This directory represents a shared network location.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//Maya 2016 Project Definition

workspace -fr "shaders" "renderData/shaders";
workspace -fr "alembicCache" "cache/alembic";
workspace -fr "mayaAscii" "scenes";
workspace -fr "mayaBinary" "scenes";
workspace -fr "renderData" "renderData";
workspace -fr "fileCache" "cache/nCache";
workspace -fr "scene" "scenes";
workspace -fr "sourceImages" "sourceimages";
8 changes: 7 additions & 1 deletion mindbender/maya/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,13 @@ def apply_shaders(relationships):
assert shader, "Associated shader not part of asset, this is a bug"

for id_ in ids:
meshes = lsattr("mbID", value=id_)
mesh, faces = (id_.rsplit(".", 1) + [""])[:2]

# Find all meshes matching this particular ID
# Convert IDs to mesh + id, e.g. "nameOfNode.f[1:100]"
meshes = list(".".join([mesh, faces])
for mesh in lsattr("mbID", value=mesh))

if not meshes:
continue

Expand Down
2 changes: 1 addition & 1 deletion mindbender/plugins/validate_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ValidateMindbenderID(pyblish.api.InstancePlugin):
label = "Mindbender ID"
order = pyblish.api.ValidatorOrder
hosts = ["maya"]
families = ["mindbender.model"]
families = ["mindbender.model", "mindbender.lookdev"]

def process(self, instance):
from maya import cmds
Expand Down
40 changes: 40 additions & 0 deletions mindbender/plugins/validate_lookdev_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pyblish.api


class ValidateMindbenderLookdevSingleShape(pyblish.api.InstancePlugin):
"""One mesh per transform"""

label = "Lookdev Member Shapes"
order = pyblish.api.ValidatorOrder
hosts = ["maya"]
families = ["mindbender.lookdev"]

def process(self, instance):
from maya import cmds

has_multiple_shapes = list()
for node in instance:

children = cmds.listRelatives(node, allDescendents=True) or list()
shapes = cmds.listRelatives(node, shapes=True) or list()

# Ensure there is only one child; there could be many,
# including other transform nodes.
has_single_shape = len(children) == 1

# Ensure the one child is a shape
has_single_child = len(shapes) == 1

# Ensure the one child is of type "mesh"
has_single_mesh = cmds.nodeType(shapes[0]) == "mesh"

if not all([has_single_child,
has_single_shape,
has_single_mesh]):
has_multiple_shapes.append(node)

assert not has_multiple_shapes, (
"\"%s\" has transforms with multiple shapes: %s" % (
instance, ", ".join(
"\"" + member + "\"" for member in has_multiple_shapes))
)
23 changes: 23 additions & 0 deletions mindbender/plugins/validate_lookdev_member_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pyblish.api


class ValidateMindbenderLookdevMembers(pyblish.api.InstancePlugin):
"""A lookdev instance must only contain members of type 'transform'"""

label = "Lookdev Member Type"
order = pyblish.api.ValidatorOrder
hosts = ["maya"]
families = ["mindbender.lookdev"]

def process(self, instance):
from maya import cmds

has_wrong_type = list(
node for node in instance
if cmds.nodeType(node) != "transform"
)

assert not has_wrong_type, "\"%s\" is has_wrong_type members: %s" % (
instance, ", ".join("\"" + member + "\""
for member in has_wrong_type))

16 changes: 13 additions & 3 deletions mindbender/tools/creator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,25 @@ def __init__(self, parent=None):

create_btn.clicked.connect(self.on_create)
name.returnPressed.connect(self.on_create)
name.textChanged.connect(self.on_data_changed)
listing.currentItemChanged.connect(self.on_data_changed)
name.textChanged.connect(self.on_name_changed)
listing.currentItemChanged.connect(self.on_selection_changed)

# Defaults
self.resize(220, 250)
name.setFocus()
create_btn.setEnabled(False)

def on_data_changed(self, *args):
def on_name_changed(self, *args):
button = self.findChild(QtWidgets.QPushButton, "Create Button")
name = self.findChild(QtWidgets.QWidget, "Name")
item = self.findChild(QtWidgets.QWidget, "Listing").currentItem()

button.setEnabled(
name.text().strip() != "" and
item.data(QtCore.Qt.ItemIsEnabled)
)

def on_selection_changed(self, *args):
button = self.findChild(QtWidgets.QPushButton, "Create Button")
name = self.findChild(QtWidgets.QWidget, "Name")
item = self.findChild(QtWidgets.QWidget, "Listing").currentItem()
Expand Down
42 changes: 23 additions & 19 deletions mindbender/tools/loader/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def __init__(self, parent=None):
assets = QtWidgets.QListWidget()
subsets = QtWidgets.QListWidget()

# Enable loading many subsets at once
subsets.setSelectionMode(subsets.ExtendedSelection)

layout = QtWidgets.QHBoxLayout(container)
layout.addWidget(assets)
layout.addWidget(subsets)
Expand Down Expand Up @@ -255,31 +258,32 @@ def on_load_pressed(self):
autoclose_checkbox = self.data["button"]["autoclose"]

asset_item = assets_model.currentItem()
subset_item = subsets_model.currentItem()

if subset_item is None:
return
for subset_item in subsets_model.selectedItems():

asset = asset_item.data(AssetRole)
subset = subset_item.data(SubsetRole)
assert asset
assert subset
if subset_item is None:
return

try:
api.registered_host().load(asset, subset)
asset = asset_item.data(AssetRole)
subset = subset_item.data(SubsetRole)
assert asset
assert subset

try:
api.registered_host().load(asset, subset)

except ValueError as e:
self.echo(e)
raise
except ValueError as e:
self.echo(e)
raise

except NameError as e:
self.echo(e)
raise
except NameError as e:
self.echo(e)
raise

# Catch-all
except Exception as e:
self.echo("Program error: %s" % str(e))
raise
# Catch-all
except Exception as e:
self.echo("Program error: %s" % str(e))
raise

if autoclose_checkbox.checkState():
self.close()
Expand Down
3 changes: 3 additions & 0 deletions res/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Resources

Native files for various applications, including thumbnails, icons and data files.
10 changes: 10 additions & 0 deletions res/workspace.mel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//Maya 2016 Project Definition

workspace -fr "shaders" "renderData/shaders";
workspace -fr "alembicCache" "cache/alembic";
workspace -fr "mayaAscii" "scenes";
workspace -fr "mayaBinary" "scenes";
workspace -fr "renderData" "renderData";
workspace -fr "fileCache" "cache/nCache";
workspace -fr "scene" "scenes";
workspace -fr "sourceImages" "sourceimages";

0 comments on commit 1f7569b

Please sign in to comment.