public override void writer(MFileObject file, string optionsString, MPxFileTranslator.FileAccessMode mode) { string fullName = file.fullName; StreamWriter sWriter = new StreamWriter(fullName); sWriter.Write("# Simple text file of custom node information" + Environment.NewLine); MItDependencyNodes iterator = new MItDependencyNodes(); while (!iterator.isDone) { MObject obj = iterator.thisNode; try { MFnDependencyNode dnFn = new MFnDependencyNode(obj); MPxNode userNode = dnFn.userNode; if (userNode != null) { sWriter.Write("# custom node: " + dnFn.name + Environment.NewLine); } } catch (System.Exception) { } iterator.next(); } sWriter.Close(); return; }
public override void writer(MFileObject file, string optionsString, MPxFileTranslator.FileAccessMode mode) { // Prepare to export, pass it off if (file.fullName.ToUpper().EndsWith(".SIEGE_ANIM_SOURCE")) { CODXAnim.ExportXAnim(file.fullName, CODXAnim.XAnimType.SiegeAnimSource); } }
public override void reader(MFileObject file, string optionsString, MPxFileTranslator.FileAccessMode mode) { string fullName = file.fullName; StreamReader sReader = new StreamReader(fullName); while (!sReader.EndOfStream) { string lineStr = sReader.ReadLine(); processLine(lineStr); } sReader.Close(); return; }
public override void writer(MFileObject file, string optionsString, MPxFileTranslator.FileAccessMode mode) { // Prepare to export, pass it off if (file.fullName.ToUpper().EndsWith(".XMODEL_EXPORT")) { // Parse settings bool ExportSiegeModel = false; string Cosmetic = string.Empty; var SplitSettings = optionsString.Trim().Split(';'); foreach (var Setting in SplitSettings) { if (string.IsNullOrWhiteSpace(Setting)) { continue; } var SettingValue = Setting.Split('='); if (SettingValue.Length < 2) { continue; } if (SettingValue[0] == "exportsiege") { ExportSiegeModel = (SettingValue[1] == "1"); } else if (SettingValue[0] == "cosmeticroot") { Cosmetic = CODXModel.CleanNodeName((SettingValue[1].Trim())); } } // Export the model CODXModel.ExportXModel(file.fullName, CODXModel.XModelType.Export, ExportSiegeModel, Cosmetic); } }
public override void writer(MFileObject file, string optionsString, MPxFileTranslator.FileAccessMode mode) { // Prepare to export, pass it off if (file.fullName.ToUpper().EndsWith(".XANIM_EXPORT")) { // Parse settings bool GrabNotes = true, EditNotes = false; var SplitSettings = optionsString.Trim().Split(';'); foreach (var Setting in SplitSettings) { if (string.IsNullOrWhiteSpace(Setting)) { continue; } var SettingValue = Setting.Split('='); if (SettingValue.Length < 2) { continue; } if (SettingValue[0] == "grabnotes") { GrabNotes = (SettingValue[1] == "1"); } else if (SettingValue[0] == "editnotes") { EditNotes = (SettingValue[1] == "1"); } } // Export anim CODXAnim.ExportXAnim(file.fullName, CODXAnim.XAnimType.Export, GrabNotes, EditNotes); } }
public override void reader(MFileObject file, string optionsString, MPxFileTranslator.FileAccessMode mode) { throw new NotImplementedException("We only support support writer not reader"); }
public override void reader(MFileObject file, string optionsString, MPxFileTranslator.FileAccessMode mode) { string fileName = file.fullName; // Parse the options. The options syntax is in the form of // "flag=val;flag1=val;flag2=val" // if (optionsString.Length > 0) { // Set up the flags for the paste command. // const string flagTime = "time"; const string flagCopies = "copies"; const string flagOption = "option"; const string flagConnect = "connect"; string copyValue = ""; string flagValue = ""; string connectValue = ""; string timeValue = ""; // Start parsing. // string[] optionList = optionsString.Split(new Char[] { ';' }); int nOptions = optionList.Length; for (int i = 0; i < nOptions; i++) { string[] theOption = optionList[i].Split(new Char[] { '=' }); if (theOption.Length < 1) { continue; } if (theOption[0] == flagCopies && theOption.Length > 1) { copyValue = theOption[1];; } else if (theOption[0] == flagOption && theOption.Length > 1) { flagValue = theOption[1]; } else if (theOption[0] == flagConnect && theOption.Length > 1) { if (Convert.ToInt32(theOption[1]) != 0) { connectValue += theOption[1]; } } else if (theOption[0] == flagTime && theOption.Length > 1) { timeValue += theOption[1]; } } if (copyValue.Length > 0) { pasteFlags += " -copies "; pasteFlags += copyValue; pasteFlags += " "; } if (flagValue.Length > 0) { pasteFlags += " -option \""; pasteFlags += flagValue; pasteFlags += "\" "; } if (connectValue.Length > 0) { pasteFlags += " -connect "; pasteFlags += connectValue; pasteFlags += " "; } if (timeValue.Length > 0) { bool useQuotes = false; try { Convert.ToDouble(timeValue); } catch (System.Exception) { useQuotes = true; } pasteFlags += " -time "; if (useQuotes) { pasteFlags += "\""; } pasteFlags += timeValue; if (useQuotes) { pasteFlags += "\""; } pasteFlags += " "; } } bool isImported = false; if (mode == MPxFileTranslator.FileAccessMode.kImportAccessMode) { isImported = importAim(fileName, pasteFlags); } else { throw new ArgumentException("Invalid File Access mode.", "mode"); } if (!isImported) { throw new ApplicationException("Importing Anim Failed."); } return; }
public override void writer(MFileObject file, string options, MPxFileTranslator.FileAccessMode mode) { string fileName = file.fullName; StreamWriter animFile = new StreamWriter(fileName); // Defaults. // string copyFlags = "copyKey -cb api -fea 1 "; int precision = kDefaultPrecision; bool nodeNames = true; bool verboseUnits = false; // Parse the options. The options syntax is in the form of // "flag=val;flag1=val;flag2=val" // if (options.Length > 0) { const string flagPrecision = "precision"; const string flagNodeNames = "nodeNames"; const string flagVerboseUnits = "verboseUnits"; const string flagCopyKeyCmd = "copyKeyCmd"; // Start parsing. // string[] optionList = options.Split(new Char[] { ';' }); int nOptions = optionList.Length; for (int i = 0; i < nOptions; i++) { string[] theOption = optionList[i].Split(new Char[] { '=' }); if (theOption.Length < 1) { continue; } if (theOption[0] == flagPrecision && theOption.Length > 1) { precision = Convert.ToInt32(theOption[1]); } else if (theOption[0] == flagNodeNames && theOption.Length > 1) { if (Convert.ToInt32(theOption[1]) == 0) { nodeNames = false; } else { nodeNames = true; } } else if (theOption[0] == flagVerboseUnits && theOption.Length > 1) { if (Convert.ToInt32(theOption[1]) == 0) { verboseUnits = false; } else { verboseUnits = true; } } else if (theOption[0] == flagCopyKeyCmd && theOption.Length > 1) { // Replace any '>' characters with '"'. This is needed // since the file translator option boxes do not handle // escaped quotation marks. // string optStr = theOption[1]; string copyStr = ""; for (int j = 0; j < optStr.Length; j++) { if (optStr[j] == '>') { copyStr += '"'; } else { copyStr += optStr[j]; } } copyFlags += copyStr; } } } // Set the precision of the ofstream. // bool isExported = exportSelected(ref animFile, ref copyFlags, nodeNames, verboseUnits); animFile.Flush(); animFile.Close(); if (!isExported) { throw new ApplicationException("Exporting Anim Failed."); } return; }