Created
January 22, 2019 21:10
-
-
Save SatishGodaPearl/8a4c22af80d2bb7fa59f8699ebc8811d to your computer and use it in GitHub Desktop.
Lunaria Variant Workflow Prototypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.app.renderSetup.model.override as override | |
import maya.app.renderSetup.model.selector as selector | |
import maya.app.renderSetup.model.collection as collection | |
import maya.app.renderSetup.model.renderLayer as renderLayer | |
import maya.app.renderSetup.model.renderSetup as renderSetup | |
import maya.cmds as cmds | |
rs = renderSetup.instance() | |
defaultRenderLayer = rs.getDefaultRenderLayer() | |
defaultRenderLayer.getChildren() | |
defaultRenderLayer.name() | |
visibleRenderLayer = rs.getVisibleRenderLayer() | |
if visibleRenderLayer == defaultRenderLayer: | |
pass | |
renderLayers = rs.getRenderLayers() | |
if not renderLayers: | |
pass | |
variant_layers = {} | |
for variant in variants: | |
name = "variant {0}".format(variant) | |
rLayer = rs.createRenderLayer(name) | |
variant_layers[variant] = rLayer | |
assetNode = pm.PyNode(assetName) | |
shapes = assetNode.listRelatives(ad=True, type='shape') | |
assert not shapes, "There are no shapes" | |
geometry = [] | |
for shape in shapes: | |
geometry.append(shape.getParent()) | |
for name, variantLayer in variant_layers.iteritems(): | |
collection_name = "geometry_{0}".format(name) | |
collection = variantLayer.createCollection(collection_name) | |
selector = collection.getSelector() | |
selector | |
variant_name = variant | |
geometry_collection = variant_layers[variant].getCollectionByName("geometry_{0}".format(variant)) | |
selector = geometry_collection.getSelector() | |
# pm.select(geometry, replace=True) | |
geos = ','.join(map(lambda geo: geo.longName(),geometry)) | |
selector.setPattern(geos) | |
for dagPath in selector.paths(): | |
print dagPath.fullPathName() | |
selector.setPattern("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WorkFileData(object): | |
def __init__(self): | |
pass | |
assetNode = pm.PyNode(assetName) | |
shapes = assetNode.listRelatives(ad=True, type='shape') | |
assert not shapes, "There are no shapes" | |
geometry = [] | |
for shape in shapes: | |
geometry.append(shape.getParent()) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymel.core as pm | |
import sgtk | |
import re | |
sceneName = pm.sceneName() | |
tk = sgtk.sgtk_from_path(sceneName) | |
context = tk.context_from_path(sceneName) | |
assetName = context.entity['name'] | |
filters = [['project', 'is', context.project], | |
['id', 'is', context.entity['id']] | |
] | |
fields = ['sg_asset_variants', 'parents', 'assets'] | |
entity_asset = tk.shotgun.find_one('Asset', filters=filters, fields=fields) | |
entity_asset | |
# Result: {'assets': [], | |
# 'id': 2052, | |
# 'parents': [], | |
# 'sg_asset_variants': 'A, B, C', | |
# 'type': 'Asset'} # | |
def parse_variants(data): | |
# pattern_asset_variants = r"""""" | |
# re.match(pattern_asset_variants, entity_asset['sg_asset_variants']) | |
return data.split(', ') | |
variants = parse_variants(entity_asset['sg_asset_variants']) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment