Skip to content

Commit

Permalink
Add log output to s2b component
Browse files Browse the repository at this point in the history
  • Loading branch information
hrntsm committed Jun 11, 2023
1 parent 9d66b00 commit 480d7a7
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 80 deletions.
11 changes: 7 additions & 4 deletions HoaryFox/RH7/Component/Geometry/Stb2Brep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager)

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddTextParameter("Log", "Log", "Log", GH_ParamAccess.item);
pManager.AddBrepParameter("Columns", "Col", "output StbColumns to Brep", GH_ParamAccess.tree);
pManager.AddBrepParameter("Girders", "Gird", "output StbGirders to Brep", GH_ParamAccess.tree);
pManager.AddBrepParameter("Posts", "Pst", "output StbPosts to Brep", GH_ParamAccess.tree);
Expand All @@ -59,22 +60,23 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)
if (!dataAccess.GetData("Data", ref _stBridge)) { return; }
if (!dataAccess.GetData("Bake", ref isBake)) { return; }

CreateBrep();
var log = CreateBrep();
if (isBake)
{
BakeBrep();
}

for (var i = 0; i < 9; i++)
dataAccess.SetData(0, log);
for (var i = 1; i < 10; i++)
{
dataAccess.SetDataTree(i, _brepList[i]);
dataAccess.SetDataTree(i, _brepList[i - 1]);
}
}

protected override Bitmap Icon => Resource.Brep;
public override Guid ComponentGuid => new Guid("B2D5EA7F-E75F-406B-8D22-C267B43C5E72");

private void CreateBrep()
private string CreateBrep()
{
var path = Path.GetDirectoryName(Grasshopper.Instances.ComponentServer.FindAssemblyByObject(this).Location);
StbMembers member = _stBridge.StbModel.StbMembers;
Expand All @@ -89,6 +91,7 @@ private void CreateBrep()
_brepList[7] = brepFromStb.Pile(member.StbPiles);
_brepList[8] = brepFromStb.Footing(member.StbFootings);
brepFromStb.SerializeLog();
return brepFromStb.Logger.ToString();
}

private void BakeBrep()
Expand Down
17 changes: 11 additions & 6 deletions HoaryFox/RH7/Component/Utils/ConvertLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,29 @@ public void AppendInfo(string guid, string message)
_logger.AppendLine($"::INFO :: [{guid}] | {message}");
}

public void AppendConvertSuccess(string guid)
public void AppendConvertSuccess(string guid, string tag)
{
_logger.AppendLine($"::INFO :: [{guid}] | 変換完了");
_logger.AppendLine($"::INFO :: [{guid}] | {tag} | 変換完了");
}

public void AppendWarning(string guid, string message)
{
_logger.AppendLine($"::WARNING:: [{guid}] | {message}");
}

public void AppendConvertWarning(string guid, string message)
public void AppendConvertWarning(string guid, string tag, string message)
{
_logger.AppendLine($"::WARNING:: [{guid}] | 変換結果 要確認 | {message}");
_logger.AppendLine($"::WARNING:: [{guid}] | {tag} | 変換結果 要確認 | {message}");
}

public void AppendError(string guid, string message)
{
_logger.AppendLine($"::ERROR :: [{guid}] | {message}");
}

public void AppendConvertFailed(string guid, string message)
public void AppendConvertFailed(string guid, string tag, string message)
{
_logger.AppendLine($"::ERROR :: [{guid}] | 変換失敗 | {message}");
_logger.AppendLine($"::ERROR :: [{guid}] | {tag} | 変換失敗 | {message}");
}

public void AppendSummary(int[] resultCount)
Expand All @@ -96,5 +96,10 @@ public void Serialize()
AppendInfoConvertEndMessage("ST-BridgeデータのBrepへ");
File.WriteAllText(_path + "/S2B_convert.log", _logger.ToString());
}

public override string ToString()
{
return _logger.ToString();
}
}
}
Loading

0 comments on commit 480d7a7

Please sign in to comment.