-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release v1.2.0
- Loading branch information
Showing
46 changed files
with
1,758 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using Grasshopper.Kernel; | ||
using KarambaConnect.K2S; | ||
using KarambaConnect.Properties; | ||
using STBDotNet.Elements; | ||
using STBDotNet.Elements.StbModel; | ||
using STBDotNet.Elements.StbModel.StbMember; | ||
using STBDotNet.Elements.StbModel.StbSection; | ||
using STBDotNet.Serialization; | ||
|
||
namespace KarambaConnect.Component.IO | ||
{ | ||
public class Export:GH_Component | ||
{ | ||
private readonly string _defaultOutPath = | ||
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\model.stb"; | ||
|
||
public Export() | ||
: base("Export STB file", "Export", "Export ST-Bridge data.", "HoaryFox", "IO") | ||
{ | ||
} | ||
|
||
protected override void RegisterInputParams(GH_InputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Node", "Node", "StbNode data", GH_ParamAccess.list); | ||
pManager.AddGenericParameter("Axis", "Axis", "StbAxes data", GH_ParamAccess.list); | ||
pManager.AddGenericParameter("Story", "Story", "StbStory data", GH_ParamAccess.list); | ||
pManager.AddGenericParameter("Member", "Mem","StbMember data", GH_ParamAccess.item); | ||
pManager.AddGenericParameter("Section", "Sec", "StbSection data", GH_ParamAccess.list); | ||
pManager.AddTextParameter("Path", "Path", "Output path", GH_ParamAccess.item, _defaultOutPath); | ||
pManager.AddBooleanParameter("Out?", "Out?", "If it is true, output stb file.", GH_ParamAccess.item, false); | ||
|
||
} | ||
|
||
protected override void RegisterOutputParams(GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Stb", "Stb", "StbModel Data", GH_ParamAccess.item); | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
var path = string.Empty; | ||
var isOutput = false; | ||
var node = new List<Node>(); | ||
var axis = new List<Axis>(); | ||
var story = new List<Story>(); | ||
var members = new Members(); | ||
var sections = new List<Section>(); | ||
|
||
if (!DA.GetDataList(0, node)) { return; } | ||
if (!DA.GetDataList(1, axis)) { return; } | ||
if (!DA.GetDataList(2, story)) { return; } | ||
if (!DA.GetData(3, ref members)) { return; } | ||
if (!DA.GetDataList(4, sections)) { return; } | ||
if (!DA.GetData(5, ref path)) { return; } | ||
if (!DA.GetData(6, ref isOutput)) { return; } | ||
|
||
|
||
var elements = new StbElements | ||
{ | ||
Version = "1.4.00", | ||
Common = StbCommon.Set(), | ||
Model = new Model | ||
{ | ||
Axes = axis, | ||
Members = members, | ||
Nodes = node, | ||
Sections = sections, | ||
Stories = story | ||
} | ||
}; | ||
|
||
if (isOutput) | ||
{ | ||
var sr = new Serializer(); | ||
sr.Serialize(elements, path); | ||
} | ||
|
||
DA.SetData(0, elements); | ||
} | ||
|
||
protected override Bitmap Icon => Resource.ExportStb; | ||
public override Guid ComponentGuid => new Guid("41401A49-3552-4741-B8F9-4C8E0C689323"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Collections.Generic; | ||
using Grasshopper.Kernel; | ||
using STBDotNet.Elements.StbModel; | ||
|
||
namespace KarambaConnect.Component.StbBuilder | ||
{ | ||
public class AxisBuilder:GH_Component | ||
{ | ||
public AxisBuilder() | ||
: base("AxisBuilder", "Axis", "Builder StbAxes data", "HoaryFox", "StbBuilder") | ||
{ | ||
} | ||
|
||
protected override void RegisterInputParams(GH_InputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Node", "Node", "StbNode data", GH_ParamAccess.list); | ||
pManager.AddNumberParameter("Distance", "Dist", "Axis coordinates[mm] from origin.", GH_ParamAccess.list); | ||
pManager.AddNumberParameter("Range", "Range", "The range of nodes to include in the axis. (Dist±Range)", GH_ParamAccess.list); | ||
pManager.AddTextParameter("Name", "Name", "Axis Name", GH_ParamAccess.list); | ||
pManager.AddIntegerParameter("Direction", "Dir", "0: X Axis, 1: Y Axis", GH_ParamAccess.list); | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Axis", "Axis", "StbAxis Data", GH_ParamAccess.list); | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
var count = 0; | ||
var nodes = new List<Node>(); | ||
var distance = new List<double>(); | ||
var range = new List<double>(); | ||
var names = new List<string>(); | ||
var dir = new List<int>(); | ||
|
||
if (!DA.GetDataList(0, nodes)) { return; } | ||
if (!DA.GetDataList(1, distance)) { return; } | ||
if (!DA.GetDataList(2, range)) { return; } | ||
if (!DA.GetDataList(3, names)) { return; } | ||
if (!DA.GetDataList(4, dir)) { return; } | ||
|
||
var axes = new List<Axis>(); | ||
|
||
if (distance.Count != names.Count || distance.Count != range.Count || distance.Count != dir.Count || | ||
range.Count != names.Count || range.Count != dir.Count || names.Count != dir.Count) | ||
{ | ||
throw new ArgumentOutOfRangeException("The number of items does not match."); | ||
} | ||
|
||
foreach (double dist in distance) | ||
{ | ||
var nodeIds = new List<NodeId>(); | ||
if (dir[count] == 0) | ||
{ | ||
var xAxis = new XAxis | ||
{ | ||
Id = count + 1, | ||
Name = names[count], | ||
Distance = dist | ||
}; | ||
foreach (Node node in nodes) | ||
{ | ||
if (node.X > dist - range[count] && node.X < dist + range[count]) | ||
{ | ||
nodeIds.Add(new NodeId(node.Id)); | ||
} | ||
} | ||
|
||
if (nodeIds.Count == 0) | ||
{ | ||
throw new ArgumentException("There are no nodes in the target distance range."); | ||
} | ||
|
||
xAxis.NodeIdList = nodeIds; | ||
axes.Add(xAxis); | ||
} | ||
else if (dir[count] == 1) | ||
{ | ||
var yAxis = new YAxis | ||
{ | ||
Id = count + 1, | ||
Name = names[count], | ||
Distance = dist | ||
}; | ||
foreach (Node node in nodes) | ||
{ | ||
if (node.Y > dist - range[count] && node.Y < dist + range[count]) | ||
{ | ||
nodeIds.Add(new NodeId(node.Id)); | ||
} | ||
} | ||
|
||
if (nodeIds.Count == 0) | ||
{ | ||
throw new ArgumentException("There are no nodes in the target distance range."); | ||
} | ||
|
||
yAxis.NodeIdList = nodeIds; | ||
axes.Add(yAxis); | ||
} | ||
|
||
count++; | ||
} | ||
|
||
DA.SetDataList(0, axes); | ||
} | ||
|
||
protected override Bitmap Icon => Properties.Resource.AxisBuilder; | ||
public override Guid ComponentGuid => new Guid("A09E1BF4-90FD-436D-8142-092894CE5D86"); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
KarambaConnect/Component/StbBuilder/FrameBuilderUsingKaramba.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Drawing; | ||
using Grasshopper.Kernel; | ||
using Karamba.GHopper.Models; | ||
using Karamba.Models; | ||
using KarambaConnect.K2S; | ||
|
||
namespace KarambaConnect.Component.StbBuilder | ||
{ | ||
public class FrameBuilderUsingKaramba:GH_Component | ||
{ | ||
public FrameBuilderUsingKaramba() | ||
: base("FrameBuilder using Karamba", "FrameBuilder", "Convert Karamba model to ST-Bridge data.", "HoaryFox", "StbBuilder") | ||
{ | ||
} | ||
|
||
protected override void RegisterInputParams(GH_InputParamManager pManager) | ||
{ | ||
pManager.AddParameter(new Param_Model(), "Model", "Model", "Karamba model data", GH_ParamAccess.item); | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Node", "Node", "StbNode Data", GH_ParamAccess.list); | ||
pManager.AddGenericParameter("Member", "Mem", "StbMember data", GH_ParamAccess.item); | ||
pManager.AddGenericParameter("Section", "Sec", "StbSection data", GH_ParamAccess.list); | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
var modelIn = new object(); | ||
|
||
if (!DA.GetData(0, ref modelIn)) { return; } | ||
|
||
var ghKModel = modelIn as GH_Model; | ||
if (ghKModel == null) | ||
{ | ||
throw new ArgumentException("The input is not of type model!"); | ||
} | ||
Model kModel = ghKModel.Value; | ||
STBDotNet.Elements.StbModel.Model sModel = StbModel.Set(kModel); | ||
|
||
DA.SetDataList(0, sModel.Nodes); | ||
DA.SetData(1, sModel.Members); | ||
DA.SetDataList(2, sModel.Sections); | ||
} | ||
|
||
protected override Bitmap Icon => Properties.Resource.FrameBuilder; | ||
public override Guid ComponentGuid => new Guid("38296D06-E47A-403F-BFE8-00E873A99CF8"); | ||
} | ||
} |
Oops, something went wrong.