def refresh(self, *args): self.pools.blockSignals(True) self.groups.blockSignals(True) self.pools.clear() self.groups.clear() self.pools.blockSignals(False) self.groups.blockSignals(False) exists = maya.lsattr("id", "avalon.renderglobals") assert len(exists) <= 1, ( "More than one renderglobal exists, this is a bug") if exists: render_globals = exists[0] else: render_globals = maya.create( "renderGlobals", api.Session["AVALON_ASSET"], "mindbender.renderglobals" ) # Store reference for editing self.render_globals = render_globals render_globals = maya.read(render_globals) current_pool = render_globals["pool"] or "none" current_group = render_globals["group"] or "none" url = api.Session["AVALON_DEADLINE"] + "/api/pools" module.log.debug("Requesting pools from %s.." % url) response = requests.get(url) pools = response.json() url = api.Session["AVALON_DEADLINE"] + "/api/groups" module.log.debug("Requesting groups from %s.." % url) response = requests.get(url) groups = response.json() valid_pool = False for index, pool in enumerate(pools): self.pools.insertItem(index, pool) if pool == current_pool: self.pools.setCurrentIndex(index) valid_pool = True valid_group = False for index, group in enumerate(groups): self.groups.insertItem(index, group) if group == current_group: self.groups.setCurrentIndex(index) valid_group = True if not valid_pool: cmds.warning("%s is not a valid pool" % current_pool) if not valid_group: cmds.warning("%s is not a valid pool" % current_group)
def parse_options(self, render_globals): """Get all overrides with a value, skip those without Here's the kicker. These globals override defaults in the submission integrator, but an empty value means no overriding is made. Otherwise, Frames would override the default frames set under globals. Args: render_globals (str): collection of render globals Returns: dict: only overrides with values """ attributes = maya.read(render_globals) options = {"renderGlobals": {}} options["renderGlobals"]["Priority"] = attributes["priority"] # Check for specific pools pool_a, pool_b = self._discover_pools(attributes) options["renderGlobals"].update({"Pool": pool_a}) if pool_b: options["renderGlobals"].update({"SecondaryPool": pool_b}) legacy = attributes["useLegacyRenderLayers"] options["renderGlobals"]["UseLegacyRenderLayers"] = legacy # Machine list machine_list = attributes["machineList"] if machine_list: key = "Whitelist" if attributes["whitelist"] else "Blacklist" options['renderGlobals'][key] = machine_list # Suspend publish job state = "Suspended" if attributes["suspendPublishJob"] else "Active" options["publishJobState"] = state chunksize = attributes.get("framesPerTask", 1) options["renderGlobals"]["ChunkSize"] = chunksize # Override frames should be False if extendFrames is False. This is # to ensure it doesn't go off doing crazy unpredictable things override_frames = False extend_frames = attributes.get("extendFrames", False) if extend_frames: override_frames = attributes.get("overrideExistingFrame", False) options["extendFrames"] = extend_frames options["overrideExistingFrame"] = override_frames maya_render_plugin = "MayaBatch" if not attributes.get("useMayaBatch", True): maya_render_plugin = "MayaCmd" options["mayaRenderPlugin"] = maya_render_plugin return options
def process(self, context): from maya import cmds from avalon import maya, api def render_global(attr): return cmds.getAttr("defaultRenderGlobals." + attr) for layer in cmds.ls(type="renderLayer"): if layer.endswith("defaultRenderLayer"): continue data = { "family": "Render Layers", "families": ["mindbender.renderlayer"], "publish": cmds.getAttr(layer + ".renderable"), "startFrame": render_global("startFrame"), "endFrame": render_global("endFrame"), "byFrameStep": render_global("byFrameStep"), "renderer": render_global("currentRenderer"), "time": context.data["time"], "author": context.data["user"], "source": context.data["currentFile"].replace(api.registered_root(), "{root}").replace( "\\", "/"), } # Apply each user defined attribute as data for attr in cmds.listAttr(layer, userDefined=True) or list(): try: value = cmds.getAttr(layer + "." + attr) except Exception: # Some attributes cannot be read directly, # such as mesh and color attributes. These # are considered non-essential to this # particular publishing pipeline. value = None data[attr] = value # Include (optional) global settings # TODO(marcus): Take into account layer overrides try: avalon_globals = maya.lsattr("id", "avalon.renderglobals")[0] except IndexError: pass else: avalon_globals = maya.read(avalon_globals) data["renderGlobals"] = { key: value for key, value in { "Pool": avalon_globals["pool"], "Group": avalon_globals["group"], "Frames": avalon_globals["frames"], "Priority": avalon_globals["priority"], }.items() # Here's the kicker. These globals override defaults # in the submission integrator, but an empty value # means no overriding is made. Otherwise, Frames # would override the default frames set under globals. if value } instance = context.create_instance(layer) instance.data.update(data)