public MayaAnimBuildAction() { super( "MayaAnimBuild", new VersionID("2.4.1"), "Temerity", "Extends the MayaBuild Action to now allow for the referencing of Maya files " + "that only contain curves, which are then hooked up to models which have either " + "been Imported or Referenced."); addUnitsParams(); addStartFrameParam(); addEndFrameParam(); addInitalMELParam(); addAnimMELParam(); addModelMELParam(); addFinalMELParam(); { LayoutGroup layout = new LayoutGroup(true); addUnitsParamsToLayout(layout); layout.addSeparator(); layout.addEntry(aStartFrame); layout.addEntry(aEndFrame); layout.addSeparator(); layout.addEntry(aInitialMEL); layout.addEntry(aModelMEL); layout.addEntry(aAnimMEL); layout.addEntry(aFinalMEL); setSingleLayout(layout); } { LinkedList<String> layout = new LinkedList<String>(); layout.add(aSceneType); layout.add(aBuildType); layout.add(aNameSpace); layout.add(aPrefixName); setSourceLayout(layout); } addSupport(OsType.MacOS); addSupport(OsType.Windows); }
/** * Construct a {@link SubProcessHeavy SubProcessHeavy} instance which when executed will fulfill * the given action agenda. * * <p> * * @param agenda The agenda to be accomplished by the action. * @param outFile The file to which all STDOUT output is redirected. * @param errFile The file to which all STDERR output is redirected. * @return The SubProcess which will fulfill the agenda. * @throws PipelineException If unable to prepare a SubProcess due to illegal, missing or * imcompatable information in the action agenda or a general failure of the prep method code. */ public SubProcessHeavy prep(ActionAgenda agenda, File outFile, File errFile) throws PipelineException { NodeID nodeID = agenda.getNodeID(); /* sanity checks */ Path loadScene = null; Path saveScene = null; boolean isAscii = false; TreeMap<Integer, LinkedList<Path>> mel = new TreeMap<Integer, LinkedList<Path>>(); { /* generate the filename of the Maya scene to load */ { String sname = (String) getSingleParamValue("MayaScene"); if (sname != null) { FileSeq fseq = agenda.getPrimarySource(sname); if (fseq == null) throw new PipelineException( "Somehow the Maya Scene node (" + sname + ") was not one of the source " + "nodes!"); String suffix = fseq.getFilePattern().getSuffix(); if (!fseq.isSingle() || (suffix == null) || !(suffix.equals("ma") || suffix.equals("mb"))) throw new PipelineException( "The MayaMEL Action requires that the source node specified by the Maya " + "Scene parameter (" + sname + ") must have a single Maya scene file as " + "its primary file sequence!"); NodeID snodeID = new NodeID(nodeID, sname); loadScene = new Path(PackageInfo.sProdPath, snodeID.getWorkingParent() + "/" + fseq.getPath(0)); } } /* generate the name of the Maya scene to save */ { Boolean save = (Boolean) getSingleParamValue("SaveResult"); if ((save != null) && save) { FileSeq fseq = agenda.getPrimaryTarget(); String suffix = fseq.getFilePattern().getSuffix(); if (!fseq.isSingle() || (suffix == null) || !(suffix.equals("ma") || suffix.equals("mb"))) throw new PipelineException( "The MayaMEL Action requires that the primary target file sequence must " + "be a single Maya scene file if the Save Result parameter is set!"); isAscii = suffix.equals("ma"); saveScene = new Path(PackageInfo.sProdPath, nodeID.getWorkingParent() + "/" + fseq.getPath(0)); } } /* generate the table of MEL script files to evaluate */ for (String sname : getSourceNames()) { Integer order = (Integer) getSourceParamValue(sname, "Order"); FileSeq fseq = agenda.getPrimarySource(sname); if (fseq == null) throw new PipelineException( "Somehow an per-source Order parameter exists for a node (" + sname + ") " + "which was not one of the source nodes!"); String suffix = fseq.getFilePattern().getSuffix(); if (!fseq.isSingle() || (suffix == null) || !suffix.equals("mel")) throw new PipelineException( "The MayaMEL Action requires that the source node (" + sname + ") with " + "per-source Order parameter must have a single MEL script file as its " + "primary file sequence!"); NodeID snodeID = new NodeID(nodeID, sname); Path script = new Path(PackageInfo.sProdPath, snodeID.getWorkingParent() + "/" + fseq.getPath(0)); LinkedList<Path> scripts = mel.get(order); if (scripts == null) { scripts = new LinkedList<Path>(); mel.put(order, scripts); } scripts.add(script); } } /* create a temporary MEL script file */ File script = createTemp(agenda, 0755, "mel"); try { FileWriter out = new FileWriter(script); /* a workaround needed in "maya -batch" mode */ out.write("// WORK AROUNDS:\n" + "lightlink -q;\n\n"); /* rename the current scene as the output scene */ if (saveScene != null) { out.write( "// SCENE SETUP\n" + "file -rename \"" + saveScene + "\";\n" + "file -type \"" + (isAscii ? "mayaAscii" : "mayaBinary") + "\";\n\n"); } /* evaluate the MEL scripts */ if (!mel.isEmpty()) { out.write("// MEL SCRIPTS \n"); for (LinkedList<Path> scripts : mel.values()) { for (Path spath : scripts) out.write("source \"" + spath + "\";\n"); } out.write("\n"); } /* save the file */ if (saveScene != null) out.write("// SAVE\n" + "file -save;\n"); out.close(); } catch (IOException ex) { throw new PipelineException( "Unable to write temporary MEL script file (" + script + ") for Job " + "(" + agenda.getJobID() + ")!\n" + ex.getMessage()); } /* create the process to run the action */ try { ArrayList<String> args = new ArrayList<String>(); args.add("-batch"); args.add("-script"); args.add(script.getPath()); if (loadScene != null) { args.add("-file"); args.add(loadScene.toOsString()); } String program = "maya"; if (PackageInfo.sOsType == OsType.Windows) program = (program + ".exe"); return new SubProcessHeavy( agenda.getNodeID().getAuthor(), getName() + "-" + agenda.getJobID(), program, args, agenda.getEnvironment(), agenda.getWorkingDir(), outFile, errFile); } catch (Exception ex) { throw new PipelineException( "Unable to generate the SubProcess to perform this Action!\n" + ex.getMessage()); } }
/** Initialize the common user interface components. */ private void initUI() { /* initialize fields */ { pFileSeqPanels = new TreeMap<FileSeq, JFileSeqPanel>(); } /* initialize the popup menus */ { initBasicMenus(true, false); updateMenuToolTips(); } /* initialize the panel components */ { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); /* header */ { pApplyToolTipText = "Replace the working area files with the selected checked-in files."; pUnApplyToolTipText = "There are no unsaved changes to Apply at this time."; JPanel panel = initHeader(true); add(panel); } add(Box.createRigidArea(new Dimension(0, 4))); /* full node name */ { LinkedList<Component> extra = new LinkedList<Component>(); extra.add(Box.createRigidArea(new Dimension(4, 0))); { JButton btn = new JButton(); pSeqLayoutButton = btn; btn.setName(pIsListLayout ? "ListLayoutButton" : "TabbedLayoutButton"); Dimension size = new Dimension(19, 19); btn.setMinimumSize(size); btn.setMaximumSize(size); btn.setPreferredSize(size); btn.setActionCommand("seq-layout-changed"); btn.addActionListener(this); extra.add(btn); } initNameField(this, extra); pNodeNameField.setFocusable(true); pNodeNameField.addKeyListener(this); pNodeNameField.addMouseListener(this); } add(Box.createRigidArea(new Dimension(0, 4))); { JTabbedPane tab = new JTabbedPane(); pFileSeqsTab = tab; tab.setVisible(!pIsListLayout); add(tab); } { Box vbox = new Box(BoxLayout.Y_AXIS); pFileSeqsBox = vbox; { JScrollPane scroll = UIFactory.createVertScrollPane(vbox); pFileSeqsScroll = scroll; scroll.setVisible(!pIsListLayout); add(scroll); } } Dimension size = new Dimension(sSize + 22, 120); setMinimumSize(size); setPreferredSize(size); setFocusable(true); addKeyListener(this); addMouseListener(this); } updateNodeStatus(null, null, null); }