Example #1
0
        protected override void SolveInstance(IGH_DataAccess dataAccess)
        {
            if (!dataAccess.GetData(0, ref _stBridge))
            {
                return;
            }
            if (!dataAccess.GetData(1, ref _factor))
            {
                return;
            }
            if (!dataAccess.GetData(2, ref _size))
            {
                return;
            }

            StbAxes axis = _stBridge.StbModel.StbAxes;

            StbParallelAxes[] parallels = axis.StbParallelAxes;
            StbStory[]        stories   = _stBridge.StbModel.StbStories;
            double            length    = GetMaxLength(_stBridge.StbModel.StbNodes);

            StbParallelAxesToLine(_factor, parallels, stories, length);

            dataAccess.SetDataList(0, _axisLines);
        }
Example #2
0
        protected override void SolveInstance(IGH_DataAccess dataAccess)
        {
            var path     = string.Empty;
            var isOutput = false;
            var nodes    = new List <StbNode>();
            var axes     = new StbAxes();
            var stories  = new List <StbStory>();
            var members  = new StbMembers();
            var sections = new StbSections();

            if (!dataAccess.GetDataList(0, nodes))
            {
                return;
            }
            if (!dataAccess.GetData(1, ref axes))
            {
                return;
            }
            if (!dataAccess.GetDataList(2, stories))
            {
                return;
            }
            if (!dataAccess.GetData(3, ref members))
            {
                return;
            }
            if (!dataAccess.GetData(4, ref sections))
            {
                return;
            }
            if (!dataAccess.GetData(5, ref path))
            {
                return;
            }
            if (!dataAccess.GetData(6, ref isOutput))
            {
                return;
            }

            var stbData = new ST_BRIDGE
            {
                version   = "2.0.2",
                StbCommon = new StbCommon
                {
                    project_name = ActiveCanvasFileName(),
                    app_name     = "HoaryFox",
                },
                StbModel = new StbModel
                {
                    StbAxes     = axes,
                    StbStories  = stories.ToArray(),
                    StbNodes    = nodes.ToArray(),
                    StbMembers  = members,
                    StbSections = sections,
                    StbJoints   = new StbJoints(),
                },
                StbAnaModels = Array.Empty <StbAnaModel>(),
                StbCalData   = new StbCalData(),
            };

            if (isOutput)
            {
                bool result = Serializer.Serialize(stbData, path, STBDotNet.Enums.Version.Stb202);
                if (!result)
                {
                    throw new Exception("Failed to serialize.");
                }
            }

            dataAccess.SetData(0, stbData);
        }
Example #3
0
        protected override void SolveInstance(IGH_DataAccess dataAccess)
        {
            var count    = 0;
            var nodes    = new List <StbNode>();
            var distance = new List <double>();
            var range    = new List <double>();
            var names    = new List <string>();
            var dir      = new List <int>();

            if (!dataAccess.GetDataList(0, nodes))
            {
                return;
            }
            if (!dataAccess.GetDataList(1, distance))
            {
                return;
            }
            if (!dataAccess.GetDataList(2, range))
            {
                return;
            }
            if (!dataAccess.GetDataList(3, names))
            {
                return;
            }
            if (!dataAccess.GetDataList(4, dir))
            {
                return;
            }

            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 ArgumentException("The number of items does not match.");
            }

            var xAxisList = new List <StbParallelAxis>();
            var yAxisList = new List <StbParallelAxis>();

            foreach (double dist in distance)
            {
                var nodeIds = new List <StbNodeId>();
                if (dir[count] == 0)
                {
                    nodeIds.AddRange(from StbNode node in nodes
                                     where node.X > dist - range[count] && node.X < dist + range[count]
                                     select new StbNodeId {
                        id = node.id
                    });
                    CheckNodeIdsNull(nodeIds);
                    xAxisList.Add(CreateParallelAxis(count, names, dist, nodeIds));
                }
                else if (dir[count] == 1)
                {
                    nodeIds.AddRange(from StbNode node in nodes
                                     where node.Y > dist - range[count] && node.Y < dist + range[count]
                                     select new StbNodeId {
                        id = node.id
                    });
                    CheckNodeIdsNull(nodeIds);
                    yAxisList.Add(CreateParallelAxis(count, names, dist, nodeIds));
                }

                count++;
            }

            var axes  = new StbAxes();
            var xAxes = new StbParallelAxes {
                X = 0, Y = 0, angle = 270, group_name = "X", StbParallelAxis = xAxisList.ToArray()
            };
            var yAxes = new StbParallelAxes {
                X = 0, Y = 0, angle = 0, group_name = "Y", StbParallelAxis = yAxisList.ToArray()
            };

            axes.StbParallelAxes = new[] { xAxes, yAxes };

            dataAccess.SetData(0, axes);
        }