Skip to content

Commit

Permalink
✨ save documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco-Pellegrino committed Oct 26, 2023
1 parent 88e8779 commit 9bcab67
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 4 deletions.
49 changes: 49 additions & 0 deletions FemDesign.Core/Calculate/CmdChild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// https://strusoft.com/
using System.IO;
using System.Xml.Serialization;
using System.Xml.Linq;

namespace FemDesign.Calculate
{
/// <summary>
/// fdscript.xsd
/// cmdchild
/// </summary>
[XmlRoot("cmdchild")]
public partial class CmdChild : CmdCommand
{
[XmlText]
public string _templatePath;

[XmlIgnore]
public string TemplatePath
{
get { return _templatePath; }
set
{
string extension = Path.GetExtension(value);
if (extension != ".dsc")
{
throw new System.ArgumentException("Incorrect file-extension. Expected .dsc.");
}

_templatePath = value;
}
}
/// <summary>
/// Parameterless constructor for serialization.
/// </summary>
private CmdChild()
{

}
public CmdChild(string filePath)
{
TemplatePath = Path.GetFullPath(filePath);
}
public override XElement ToXElement()
{
return Extension.ToXElement<CmdChild>(this);
}
}
}
6 changes: 2 additions & 4 deletions FemDesign.Core/Calculate/CmdSaveDocx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ private CmdSaveDocx()
}
public CmdSaveDocx(string filePath)
{
//
string extension = Path.GetExtension(filePath);
if (extension != ".docx")
{
throw new System.ArgumentException("Incorrect file-extension. Expected .docx. CmdSaveDocx failed.");
}

//
this.FilePath = filePath;

this.FilePath = Path.GetFullPath(filePath);
}
public override XElement ToXElement()
{
Expand Down
1 change: 1 addition & 0 deletions FemDesign.Core/FemDesign.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Compile Include="Bars\Column.cs" />
<Compile Include="Bars\Truss.cs" />
<Compile Include="Calculate\CmdApplyDesignChanges.cs" />
<Compile Include="Calculate\CmdChild.cs" />
<Compile Include="Calculate\CmdConfig.cs" />
<Compile Include="Calculate\CmdDesignGroup.cs" />
<Compile Include="Calculate\CmdGlobalCfg.cs" />
Expand Down
32 changes: 32 additions & 0 deletions FemDesign.Core/FemDesignConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,38 @@ public Model GetModel()
return Model.DeserializeFromFilePath(struxmlPath);
}

/// <summary>
/// Save the documentation in a docx file.
/// </summary>
/// <param name="filePath"></param>
public void SaveDocx(string filePath)
{
string logfile = OutputFileHelper.GetLogfilePath(OutputDir);

var script = new FdScript(
logfile,
new CmdSaveDocx(filePath)
);

this.RunScript(script, "SaveDocx");
}

/// <summary>
/// Apply a template to a documentation
/// </summary>
/// <param name="templatePath"></param>
public void SaveDocxFromTemplate(string templatePath)
{
string logfile = OutputFileHelper.GetLogfilePath(OutputDir);

var script = new FdScript(
logfile,
new CmdChild(templatePath)
);

this.RunScript(script, "SaveDocxFromTemplate");
}

/// <summary>
/// Retrieves the loads from the currently opened model with all available elements as a <see cref="Loads.Loads"/> object.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions femdesign-api.sln
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FemDesign.TestsGh", "FemDes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Practical example - Stiffness Point from CSV", "FemDesign.Examples\C#\Practical example - Create Stiffness Point from a CSV\Practical example - Stiffness Point from CSV.csproj", "{7A17B115-949E-48F2-86E5-F8BEBBAA61B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Practical example - PrintDocumentation", "FemDesign.Examples\C#\Practical example - PrintDocumentation\Practical example - PrintDocumentation.csproj", "{649E8E00-EBE9-4F65-A75F-AF9F8B0FE601}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -162,6 +164,10 @@ Global
{7A17B115-949E-48F2-86E5-F8BEBBAA61B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A17B115-949E-48F2-86E5-F8BEBBAA61B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A17B115-949E-48F2-86E5-F8BEBBAA61B4}.Release|Any CPU.Build.0 = Release|Any CPU
{649E8E00-EBE9-4F65-A75F-AF9F8B0FE601}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{649E8E00-EBE9-4F65-A75F-AF9F8B0FE601}.Debug|Any CPU.Build.0 = Debug|Any CPU
{649E8E00-EBE9-4F65-A75F-AF9F8B0FE601}.Release|Any CPU.ActiveCfg = Release|Any CPU
{649E8E00-EBE9-4F65-A75F-AF9F8B0FE601}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -184,6 +190,7 @@ Global
{3646ABCA-0703-425A-BB27-4D838DB92FE8} = {C68FA42C-7B20-4FE3-AED6-8B6619EE5410}
{2747D6C1-1E22-4262-A938-44FEE99A022C} = {C68FA42C-7B20-4FE3-AED6-8B6619EE5410}
{7A17B115-949E-48F2-86E5-F8BEBBAA61B4} = {C68FA42C-7B20-4FE3-AED6-8B6619EE5410}
{649E8E00-EBE9-4F65-A75F-AF9F8B0FE601} = {C68FA42C-7B20-4FE3-AED6-8B6619EE5410}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DDF9D949-F79B-4EA6-A766-976B0BE0BC79}
Expand Down

0 comments on commit 9bcab67

Please sign in to comment.