Skip to content

Commit

Permalink
Merge pull request #258 from hrntsm/develop
Browse files Browse the repository at this point in the history
Release v2.4.0
  • Loading branch information
hrntsm authored Jun 11, 2023
2 parents f2c3c77 + 3eae2fb commit e73eeee
Show file tree
Hide file tree
Showing 36 changed files with 1,894 additions and 641 deletions.
19 changes: 12 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"name": "Run Rhino8 WIP",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "C:/Program Files/Rhino 6/System/Rhino.exe",
"args": [],
"program": "C:/Program Files/Rhino 8 WIP/System/Rhino.exe",
"args": ["/nosplash"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": true
},
{
"name": ".NET Core Attach",
"name": "Run Rhino7",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
"request": "launch",
"preLaunchTask": "build",
"program": "C:/Program Files/Rhino 7/System/Rhino.exe",
"args": ["/nosplash"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": true
},
]
}
27 changes: 1 addition & 26 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,11 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/HoaryFox/HoaryFox.csproj",
"${workspaceFolder}/HoaryFox/RH7/HoaryFoxRH7.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/HoaryFox/HoaryFox.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/HoaryFox/HoaryFox.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
2 changes: 1 addition & 1 deletion HoaryFox/RH6/HoaryFoxRH6.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Version>2.3.0</Version>
<Version>2.4.0</Version>
<Title>HoaryFox</Title>
<Description>This Component read ST-Bridge file(.stb) and display its model data.</Description>
<TargetExt>.gha</TargetExt>
Expand Down
14 changes: 9 additions & 5 deletions HoaryFox/RH6/HoaryFoxRH6Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ namespace HoaryFox
public class HoaryFoxRH6Info : GH_AssemblyInfo
{
public override string Name => "HoaryFox";

public override Bitmap Icon => HoaryFoxCommon.Properties.Resource.InfoIcon;

public override string Description => "This Component read ST-Bridge file(.stb) and display its model data.";

public override Guid Id => new Guid("093de648-746b-4b0b-85ef-495c6fb4514f");

public override string AuthorName => "hrntsm";

public override string AuthorContact => "contact@hrntsm.com";
}

public class HoaryFoxCategoryIcon : GH_AssemblyPriority
{
public override GH_LoadingInstruction PriorityLoad()
{
Grasshopper.Instances.ComponentServer.AddCategoryIcon("HoaryFox", HoaryFoxCommon.Properties.Resource.InfoIcon);
return GH_LoadingInstruction.Proceed;
}
}
}
26 changes: 18 additions & 8 deletions HoaryFox/RH7/Component/Geometry/Stb2Brep.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;

using Grasshopper.Kernel;
Expand All @@ -22,7 +23,7 @@ namespace HoaryFox.Component.Geometry
public class Stb2Brep : GH_Component
{
private ST_BRIDGE _stBridge;
private readonly GH_Structure<GH_Brep>[] _brepList = new GH_Structure<GH_Brep>[7];
private readonly GH_Structure<GH_Brep>[] _brepList = new GH_Structure<GH_Brep>[9];

public override GH_Exposure Exposure => GH_Exposure.primary;

Expand All @@ -41,13 +42,16 @@ 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);
pManager.AddBrepParameter("Beams", "Bm", "output StbBeams to Brep", GH_ParamAccess.tree);
pManager.AddBrepParameter("Braces", "Brc", "output StbBraces to Brep", GH_ParamAccess.tree);
pManager.AddBrepParameter("Slabs", "Slb", "output StbSlabs to Brep", GH_ParamAccess.tree);
pManager.AddBrepParameter("Walls", "Wl", "output StbWalls to Brep", GH_ParamAccess.tree);
pManager.AddBrepParameter("Piles", "Pil", "output StbPiles to Brep", GH_ParamAccess.tree);
pManager.AddBrepParameter("Footings", "Ftg", "output StbFootings to Brep", GH_ParamAccess.tree);
}

protected override void SolveInstance(IGH_DataAccess dataAccess)
Expand All @@ -56,39 +60,45 @@ 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 < 7; 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;
var brepFromStb = new CreateMemberBrepListFromStb(_stBridge.StbModel.StbSections, _stBridge.StbModel.StbNodes, new[] { DocumentTolerance(), DocumentAngleTolerance() });
var brepFromStb = new CreateMemberBrepListFromStb(_stBridge.StbModel.StbSections, _stBridge.StbModel.StbNodes, new[] { DocumentTolerance(), DocumentAngleTolerance() }, path);
_brepList[0] = brepFromStb.Column(member.StbColumns);
_brepList[1] = brepFromStb.Girder(member.StbGirders);
_brepList[2] = brepFromStb.Post(member.StbPosts);
_brepList[3] = brepFromStb.Beam(member.StbBeams);
_brepList[4] = brepFromStb.Brace(member.StbBraces);
_brepList[5] = brepFromStb.Slab(member.StbSlabs);
_brepList[6] = brepFromStb.Wall(member.StbWalls, member.StbOpens);
_brepList[7] = brepFromStb.Pile(member.StbPiles);
_brepList[8] = brepFromStb.Footing(member.StbFootings);
brepFromStb.SerializeLog();
return brepFromStb.Logger.ToString();
}

private void BakeBrep()
{
RhinoDoc activeDoc = RhinoDoc.ActiveDoc;
var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall" };
Color[] layerColors = { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue };
var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall", "Pile", "Footing" };
Color[] layerColors = new[] { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue, Color.DarkOrange, Color.DarkKhaki };
GeometryBaker.MakeParentLayers(activeDoc, parentLayerNames, layerColors);

Dictionary<string, string>[][] infoArray = Utils.TagUtils.GetAllSectionInfoArray(_stBridge.StbModel.StbMembers, _stBridge.StbModel.StbSections);
Expand Down
65 changes: 39 additions & 26 deletions HoaryFox/RH7/Component/Geometry/Stb2Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Stb2Line : GH_Component
{
private ST_BRIDGE _stBridge;
private List<Point3d> _nodes = new List<Point3d>();
private readonly GH_Structure<GH_Line>[] _lineList = new GH_Structure<GH_Line>[5];
private readonly GH_Structure<GH_Line>[] _lineList = new GH_Structure<GH_Line>[8];

public override GH_Exposure Exposure => GH_Exposure.primary;

Expand All @@ -37,6 +37,7 @@ public Stb2Line()
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Data", "D", "input ST-Bridge Data", GH_ParamAccess.item);
pManager.AddBooleanParameter("OffsetNode", "OfNd", "If it true, offset geometry.", GH_ParamAccess.item, false);
pManager.AddBooleanParameter("Bake", "Bake", "If it true, bake geometry.", GH_ParamAccess.item, false);
}

Expand All @@ -48,15 +49,18 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager)
pManager.AddLineParameter("Posts", "Pst", "output StbPosts to Line", GH_ParamAccess.tree);
pManager.AddLineParameter("Beams", "Beam", "output StbBeams to Line", GH_ParamAccess.tree);
pManager.AddLineParameter("Braces", "Brc", "output StbBraces to Line", GH_ParamAccess.tree);
pManager.AddLineParameter("Piles", "Pil", "output StbPiles to Line", GH_ParamAccess.tree);
}

protected override void SolveInstance(IGH_DataAccess dataAccess)
{
var isBake = false;
var isOffset = false;
if (!dataAccess.GetData("Data", ref _stBridge)) { return; }
if (!dataAccess.GetData("OffsetNode", ref isOffset)) { return; }
if (!dataAccess.GetData("Bake", ref isBake)) { return; }

CreateLine();
CreateLine(isOffset);
if (isBake)
{
BakeLine();
Expand All @@ -65,66 +69,75 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)
dataAccess.SetDataList(0, _nodes);
foreach ((GH_Structure<GH_Line> geometry, int i) in _lineList.Select((geo, index) => (geo, index + 1)))
{
dataAccess.SetDataTree(i, geometry);
if (i == 8)
{
dataAccess.SetDataTree(6, geometry);
}
else if (i == 6 || i == 7)
{
continue;
}
else
{
dataAccess.SetDataTree(i, geometry);
}
}
}

private void BakeLine()
{
RhinoDoc activeDoc = RhinoDoc.ActiveDoc;
var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall" };
Color[] layerColors = { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue };
var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall", "Pile" };
Color[] layerColors = { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue, Color.DarkOrange };
GeometryBaker.MakeParentLayers(activeDoc, parentLayerNames, layerColors);

Dictionary<string, string>[][] infoArray = Utils.TagUtils.GetAllSectionInfoArray(_stBridge.StbModel.StbMembers, _stBridge.StbModel.StbSections);

foreach ((GH_Structure<GH_Line> lines, int i) in _lineList.Select((frameBrep, index) => (frameBrep, index)))
{
if (lines == null)
{
continue;
}
Layer parentLayer = activeDoc.Layers.FindName(parentLayerNames[i]);
int parentIndex = parentLayer.Index;
Guid parentId = parentLayer.Id;
foreach ((Line line, int bIndex) in lines.Select((geometry, bIndex) => (geometry.Value, bIndex)))
{
var objAttr = new ObjectAttributes();

if (i < 5)
Dictionary<string, string>[] infos = infoArray[i];
Dictionary<string, string> info = infos[bIndex];

foreach (KeyValuePair<string, string> pair in info)
{
Dictionary<string, string>[] infos = infoArray[i];
Dictionary<string, string> info = infos[bIndex];

foreach (KeyValuePair<string, string> pair in info)
{
objAttr.SetUserString(pair.Key, pair.Value);
}

var layer = new Layer { Name = info["name"], ParentLayerId = parentId, Color = layerColors[i] };
int layerIndex = activeDoc.Layers.Add(layer);
if (layerIndex == -1)
{
layer = activeDoc.Layers.FindName(info["name"]);
layerIndex = layer.Index;
}
objAttr.LayerIndex = layerIndex;
objAttr.SetUserString(pair.Key, pair.Value);
}
else

var layer = new Layer { Name = info["name"], ParentLayerId = parentId, Color = layerColors[i] };
int layerIndex = activeDoc.Layers.Add(layer);
if (layerIndex == -1)
{
objAttr.LayerIndex = parentIndex;
layer = activeDoc.Layers.FindName(info["name"]);
layerIndex = layer.Index;
}
objAttr.LayerIndex = layerIndex;

activeDoc.Objects.AddLine(line, objAttr);
}
}
}

private void CreateLine()
private void CreateLine(bool isOffset)
{
var createLines = new CreateLineFromStb(_stBridge);
var createLines = new CreateLineFromStb(_stBridge, isOffset);
_nodes = createLines.Nodes();
_lineList[0] = createLines.Columns();
_lineList[1] = createLines.Girders();
_lineList[2] = createLines.Posts();
_lineList[3] = createLines.Beams();
_lineList[4] = createLines.Braces();
_lineList[7] = createLines.Piles();
}

protected override Bitmap Icon => Resource.Line;
Expand Down
Loading

0 comments on commit e73eeee

Please sign in to comment.