/** * Check that the user has properly selected a target node for this tool * * <p> * * @return The phase progress message or <CODE>null</CODE> to abort early. * @throws PipelineException If unable to validate the given user input. */ public synchronized String collectPhaseInput() throws PipelineException { if ((pPrimary == null) || (pSelected.size() != 1)) throw new PipelineException("Please selected one node only."); // folder = nPath.getParent(); // assetName = nPath.getName(); Path nPath = new Path(pPrimary); nPath = nPath.getParentPath().getParentPath(); if (!nPath.toString().matches(assetPattern)) throw new PipelineException( "This tool only works on assets." + nPath.toString() + " " + nPath.toOsString()); // if(!pPrimary.matches(matPattern)) // throw new PipelineException("This tool will only work on a lgt node!"); File errFile; try { errFile = File.createTempFile("MaterialsCheckOut", ".err", PackageInfo.sTempPath.toFile()); err = new PrintWriter(errFile); FileCleaner.add(errFile); } catch (IOException e) { e.printStackTrace(); } NodeStatus status = pSelected.get(pPrimary); NodeID nodeID = status.getNodeID(); pUser = nodeID.getAuthor(); pView = nodeID.getView(); OverallNodeState state = status.getHeavyDetails().getOverallNodeState(); JToolDialog tool = new JToolDialog("MaterialsCheckOut", new JPanel(), "Continue"); if (!state.equals(OverallNodeState.Identical)) { JConfirmDialog dialog = new JConfirmDialog( tool, "This node is different from the checked in node. Do you want to continue with this check out?"); dialog.setVisible(true); if (!dialog.wasConfirmed()) { return null; } // end if } // end if return "...Sing Hallelujah!"; }
/** * Updates the asset references for a shot within Maya and then in pipeline. * * @param shotName The name of the shot being processed. * @param pRemoveRef The list of assets being dereferenced from the shot. * @param pReplaceRef The list of assets being referenced into the shot. * @param nameMap */ private void editShotReferences( String shotName, NodeMod targetMod, TreeSet<String> pRemoveRef, TreeSet<String> pReplaceRef, TreeMap<String, String> nameMap) throws PipelineException { logLine("Editing shot: " + shotName); boolean anim = !shotName.matches(lgtPattern); /* writing the mel script */ if (anim) { File script = null; try { script = File.createTempFile("UpdateAssetGUI.", ".mel", PackageInfo.sTempPath.toFile()); FileCleaner.add(script); } // end try catch (IOException ex) { throw new PipelineException( "Unable to create the temporary MEL script used to collect " + "texture information from the Maya scene!"); } // end catch try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(script))); for (String asset : pReplaceRef) { String nameSpace; if (asset.endsWith(lr)) nameSpace = nameMap.get(getShortName(asset.substring(0, asset.length() - 3))); else { System.err.println("This should not be happening, a hi res asset in a lo-res node."); continue; // nameSpace = nameMap.get(getShortName(asset)); } out.println("print (\"referencing file: $WORKING" + asset + ".ma\");"); out.println( "file -reference -namespace \"" + nameSpace + "\" \"$WORKING" + asset + ".ma\";"); } // end for for (String asset : pRemoveRef) { out.println("print (\"dereferencing file: $WORKING" + asset + ".ma\");"); out.println("file -rr \"$WORKING" + asset + ".ma\";"); } // end for out.println("// SAVE"); out.println("file -save;"); out.close(); } // end try catch (IOException ex) { throw new PipelineException( "Unable to write the temporary MEL script(" + script + ") used add the references!"); } // end catch NodeID targetID = new NodeID(w.user, w.view, shotName); // NodeStatus targetStat = mclient.status(targetID); /* run Maya to collect the information */ try { Path targetPath = getNodePath(shotName); ArrayList<String> args = new ArrayList<String>(); args.add("-batch"); args.add("-script"); args.add(script.getPath()); args.add("-file"); args.add(targetPath.toOsString()); Path wdir = new Path(PackageInfo.sProdPath.toOsString() + targetID.getWorkingParent()); TreeMap<String, String> env = mclient.getToolsetEnvironment( w.user, w.view, targetMod.getToolset(), PackageInfo.sOsType); Map<String, String> nenv = env; String midefs = env.get("PIPELINE_MI_SHADER_PATH"); if (midefs != null) { nenv = new TreeMap<String, String>(env); Path dpath = new Path(new Path(wdir, midefs)); nenv.put("MI_CUSTOM_SHADER_PATH", dpath.toOsString()); } String command = "maya"; if (PackageInfo.sOsType.equals(OsType.Windows)) command += ".exe"; SubProcessLight proc = new SubProcessLight("UpdateAssetGUI", command, args, env, wdir.toFile()); try { proc.start(); proc.join(); if (!proc.wasSuccessful()) { throw new PipelineException( "Did not correctly edit the reference due to a maya error.!\n\n" + proc.getStdOut() + "\n\n" + proc.getStdErr()); } // end if } // end try catch (InterruptedException ex) { throw new PipelineException(ex); } // end catch } // end try catch (Exception ex) { throw new PipelineException(ex); } // end catch } /*-edit the references in pipeline once they are done in the file-*/ BaseAction targetAction = targetMod.getAction(); for (String asset : pReplaceRef) { mclient.link( w.user, w.view, shotName, asset, LinkPolicy.Reference, LinkRelationship.All, null); if (anim) { /*Set the namespaces*/ String nameSpace = nameMap.get(getShortName(asset.substring(0, asset.length() - 3))); System.err.println(nameSpace); targetAction.initSourceParams(asset); targetAction.setSourceParamValue(asset, "PrefixName", nameSpace); targetMod.setAction(targetAction); } } w.mclient.modifyProperties(w.user, w.view, targetMod); for (String asset : pRemoveRef) mclient.unlink(w.user, w.view, shotName, asset); if (!anim) { System.err.println("Queuing the switchLgt node " + shotName); mclient.submitJobs(w.user, w.view, shotName, null); } } // end editShotReferences