/// <summary> /// Create fdscript to run analysis. /// </summary> public static FdScript Analysis(string struxmlPath, Analysis analysis, List <string> bscPath, string docxTemplatePath, bool endSession) { CmdUserModule mode = CmdUserModule.RESMODE; FdScript fdScript = FdScript.CalculateStruxml(struxmlPath, mode, bscPath, docxTemplatePath, endSession); fdScript.CmdCalculation = new CmdCalculation(analysis); return(fdScript); }
/// <summary> /// Create fdscript to perform a calculation. /// </summary> internal static FdScript CalculateStruxml(string struxmlPath, CmdUserModule mode, List <string> bscPath, string docxTemplatePath, bool endSession) { FdScript fdScript = new FdScript(); fdScript.XmlAttrib = "fdscript.xsd"; fdScript.StruxmlPath = struxmlPath; fdScript.FileName = Path.GetFileNameWithoutExtension(struxmlPath); fdScript.Cwd = Path.GetDirectoryName(fdScript.StruxmlPath); fdScript.FdScriptPath = Path.Combine(fdScript.Cwd, fdScript.FileName, "scripts", "Analysis.fdscript"); // set header and logfile fdScript.FdScriptHeader = new FdScriptHeader("Generated script.", Path.Combine(fdScript.Cwd, fdScript.FileName, "logfile.log")); // set open fdScript.CmdOpen = new CmdOpen(fdScript.StruxmlPath); // set user fdScript.CmdUser = new CmdUser(mode); // listgen if (bscPath != null && bscPath.Any()) { fdScript.CmdListGen = new List <CmdListGen>(); foreach (string item in bscPath) { fdScript.CmdListGen.Add(new CmdListGen(item, Path.Combine(fdScript.Cwd, fdScript.FileName, "results"))); } } // set save docx if (docxTemplatePath != "" && docxTemplatePath != null) { // path to .dsc-file (template file) fdScript.DocxTemplatePath = docxTemplatePath; // object containing command to generate .docx and path to generated .docx fdScript.CmdSaveDocx = new CmdSaveDocx(fdScript.FileName + ".docx"); } // set save fdScript.CmdSave = new CmdSave(fdScript.Cwd + @"\" + fdScript.FileName + ".str"); // set endsession if (endSession) { fdScript.CmdEndSession = new CmdEndSession(); } // return return(fdScript); }
/// <summary> /// Generate a FEM-Design documentation. /// </summary> /// <param name="strPath">The .str file to generate base the documentation on.</param> /// <param name="docxTemplatePath">The .docx template path for the documentation.</param> /// <param name="endSession">Close the FEM-Design program after successfully generating documentation.</param> /// <returns>An <see cref="FdScript"/> for generating documentation.</returns> public static FdScript CreateDocumentation(string strPath, string docxTemplatePath, bool endSession = true) { FdScript fdScript = FdScript.ReadStr(strPath, null); fdScript.CmdSave = null; fdScript.DocxTemplatePath = docxTemplatePath; fdScript.CmdSaveDocx = new CmdSaveDocx(fdScript.StruxmlPath.Replace(".struxml", ".docx")); // set endsession if (endSession) { fdScript.CmdEndSession = new CmdEndSession(); } return(fdScript); }
/// <summary> /// Run fd3dstruct with a .fdscript. /// </summary> /// <param name="fdScript"></param> /// <param name="killProcess"></param> /// <param name="endSession"></param> /// <returns></returns> public bool RunFdScript(FdScript fdScript, bool killProcess, bool endSession, bool checkOpenFiles = true) { // serialize script fdScript.SerializeFdScript(); // kill processes if (killProcess) { this.KillProcesses(); } // Check if files are already open if (checkOpenFiles) { CheckOpenFiles(new List <string> { fdScript.CmdOpen?.Filename, fdScript.CmdSave?.FilePath }); } return(RunFdScript(fdScript.FdScriptPath, killProcess, endSession)); }
/// Create fdscript to read a str-model. public static FdScript ReadStr(string strPath, List <string> bscPaths = null) { FdScript fdScript = new FdScript(); fdScript.XmlAttrib = "fdscript.xsd"; strPath = Path.GetFullPath(strPath); fdScript.FileName = Path.GetFileNameWithoutExtension(strPath); fdScript.Cwd = Path.GetDirectoryName(strPath); fdScript.StruxmlPath = Path.Combine(fdScript.Cwd, fdScript.FileName + ".struxml"); fdScript.FdScriptPath = Path.Combine(fdScript.Cwd, fdScript.FileName, "scripts", "Analysis.fdscript"); // set header and logfile fdScript.FdScriptHeader = new FdScriptHeader("Generated script.", Path.Combine(fdScript.Cwd, fdScript.FileName, "logfile.log")); // open str fdScript.CmdOpen = new CmdOpen(strPath); // listgen if (bscPaths != null && bscPaths.Any()) { fdScript.CmdListGen = new List <CmdListGen>(); foreach (string bscPath in bscPaths) { fdScript.CmdListGen.Add(new CmdListGen(Path.GetFullPath(bscPath), Path.Combine(fdScript.Cwd, fdScript.FileName, "results"))); } } // save as .struxml fdScript.CmdSave = new CmdSave(fdScript.StruxmlPath); // end session fdScript.CmdEndSession = new CmdEndSession(); // return return(fdScript); }
/// <summary> /// Create fdscript to run analysis and design. /// </summary> public static FdScript Design(string mode, string struxmlPath, Analysis analysis, Design design, List <string> bscPath, string docxTemplatePath, bool endSession) { CmdUserModule _mode = CmdUserModule.RCDESIGN; switch (mode) { case "rc": case "Rc": case "RC": case "RCDESIGN": _mode = CmdUserModule.RCDESIGN; break; case "steel": case "Steel": case "STEEL": case "STEELDESIGN": _mode = CmdUserModule.STEELDESIGN; break; case "timber": case "Timber": case "TIMBER": case "TIMBERDESIGN": _mode = CmdUserModule.TIMBERDESIGN; break; default: throw new ArgumentException("Mode is not supported. Mode should be rc, steel or timber"); } FdScript fdScript = FdScript.CalculateStruxml(struxmlPath, _mode, bscPath, docxTemplatePath, endSession); fdScript.CmdCalculation = new CmdCalculation(analysis, design); return(fdScript); }
public bool RunDesign(string mode, string struxmlPath, Analysis analysis, Design design, List <string> bscPath, string docxTemplatePath, bool endSession, bool closeOpenWindows) { FdScript fdScript = FdScript.Design(mode, struxmlPath, analysis, design, bscPath, docxTemplatePath, endSession); return(this.RunFdScript(fdScript, closeOpenWindows, endSession, false)); }