/// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            StructureEngine.Model.ComputedStructure comp = new StructureEngine.Model.ComputedStructure(); // modify to get in solver to get output structure

            Types.StructureType structure1 = new Types.StructureType();

            if (!DA.GetData(0, ref structure1))
            {
                return;
            }

            structure1.CastTo <ComputedStructure>(ref comp);

            comp = structure1.Value;

            FrameAnalysis analysis = new FrameAnalysis();

            analysis.RunAnalysis(comp);

            Types.StructureType Structure_GHrep = new Types.StructureType(comp);
            /*Assign the outputs via the DA object*/
            DA.SetData(0, Structure_GHrep);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            StructureEngine.Model.ComputedStructure comp = new StructureEngine.Model.ComputedStructure(); // modify to get in solver to get output structure

            Types.StructureType structure1 = new Types.StructureType();

            if (!DA.GetData(0, ref structure1))
            {
                return;
            }

            structure1.CastTo <ComputedStructure>(ref comp);

            comp = structure1.Value;

            List <Point3d> Points = new List <Point3d>();
            List <Line>    Lines  = new List <Line>();

            foreach (Member m in comp.Members)
            {
                Point3d start = m.NodeI.ToRhinoPoint();
                Point3d end   = m.NodeJ.ToRhinoPoint();
                //Points.Add(start);
                //Points.Add(end);
                Lines.Add(new Line(start, end));
            }

            foreach (Node n in comp.Nodes)
            {
                Point3d pt = n.ToRhinoPoint();
                Points.Add(pt);
            }

            DA.SetDataList(0, Lines);
            DA.SetDataList(1, Points);
        }
示例#3
0
        /// <summary>
        /// Add Loads to ComputedStructure
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // input
            StructureEngine.Model.ComputedStructure structure = new StructureEngine.Model.ComputedStructure(); // modify to get in solver to get output structure
            List <Point3d> points      = new List <Point3d>();
            Vector3d       forcevector = new Vector3d();
            String         lcname      = "";

            Types.StructureType structure1 = new Types.StructureType();

            if (!DA.GetData(0, ref structure1))
            {
                return;
            }
            if (!DA.GetDataList(1, points))
            {
                return;
            }
            if (!DA.GetData(2, ref forcevector))
            {
                return;
            }
            if (!DA.GetData(3, ref lcname))
            {
                return;
            }

            structure1.CastTo <ComputedStructure>(ref structure);

            structure = structure1.Value;


            // output info

            //String info = "Loading Operation Successful";

            // Create new Loadcase

            LoadCase lc = new LoadCase(lcname);

            double lx = forcevector.X;
            double ly = forcevector.Y;
            double lz = forcevector.Z;


            foreach (Point3d point in points)
            {
                foreach (StructureEngine.Model.Node node in structure.Nodes)
                {
                    if (node.IsAtPoint(point))
                    {
                        Load loadx = new Load(lx, lc, node.DOFs[0]);
                        Console.WriteLine(loadx.Value);
                        Load loady = new Load(ly, lc, node.DOFs[1]);
                        Console.WriteLine(loady.Value);
                        Load loadz = new Load(lz, lc, node.DOFs[2]);
                        Console.WriteLine(loadz.Value);
                        lc.Loads.Add(loadx);
                        lc.Loads.Add(loady);
                        lc.Loads.Add(loadz);
                    }
                }
                //points.Remove(point); collection was modified each time -> error
            }

            // Add Loadcase to structure
            structure.LoadCases.Add(lc);

            /*Assign the outputs via the DA object*/
            Types.StructureType Structure_GH = new Types.StructureType(structure);
            DA.SetData(0, Structure_GH);
            //DA.SetData(1, info);
        }
        public static void Main()
        {
            /* Declare variables to contain all inputs
             * We can assign initial values (or not) that are either indicative or sensible */
            List <Rhino.Geometry.Line> lines = new List <Line>();
            Line line1 = new Line(new Point3d(0, 0, 0), new Point3d(0, 1, 0));
            Line line2 = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 1));

            lines.Add(line1);
            lines.Add(line2);


            //CustomTypes.MaterialType Material;
            //CustomTypes.SectionType Section;
            // double tolerance = double.NaN ;



            /*Retrieve coordinates of start and end points*/
            List <Rhino.Geometry.Point3d> pts = new List <Rhino.Geometry.Point3d>();
            List <Node>   Nodes   = new List <Node>();
            List <Member> Members = new List <Member>();

            foreach (Rhino.Geometry.Line line in lines)
            {
                pts.Add(line.From);
                pts.Add(line.To);

                int n1Index = pts.Count - 2;
                int n2Index = pts.Count - 1;

                // Define start node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 2; i++) // < should become <= (or not?)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 2], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 2);
                        n1Index = i;
                    }
                }

                DOF x1 = new DOF(pts[n1Index].X);
                DOF y1 = new DOF(pts[n1Index].Y);
                DOF z1 = new DOF(pts[n1Index].Z);

                DOF[] coor1 = new DOF[] { x1, y1, z1 };

                Node n1 = new Node(coor1);
                n1.Index = n1Index;

                // Define end node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 1; i++)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 1], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 1);
                        n2Index = i;
                    }
                }

                DOF x2 = new DOF(pts[n2Index].X);
                DOF y2 = new DOF(pts[n2Index].Y);
                DOF z2 = new DOF(pts[n2Index].Z);

                DOF[] coor2 = new DOF[] { x2, y2, z2 };

                Node n2 = new Node(coor2);
                n2.Index = n2Index;

                // Define member

                Member m = new Member(n1, n2);

                //m.Material = Material.MaterialValue;
                //m.Section = Section.SectionValue;

                // Add member and nodes to respective lists

                Nodes.Add(n1);
                Nodes.Add(n2);
                Members.Add(m);
            }

            Structure         Structure     = new Structure(Nodes, Members);
            ComputedStructure CompStructure = new ComputedStructure(Structure);

            Types.StructureType Structure_GHrep = new Types.StructureType(CompStructure);
            /*Assign the outputs via the DA object*/
            //DA.SetDataList(0, pts);
            //DA.SetData(1, Structure_GHrep);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // input
            StructureEngine.Model.ComputedStructure structure = new StructureEngine.Model.ComputedStructure(); // modify to get in solver to get output structure
            List <Point3d> points      = new List <Point3d>();
            Boolean        translation = true;
            Boolean        rotation    = true;

            Types.StructureType structuretype = new Types.StructureType();

            if (!DA.GetData(0, ref structuretype))
            {
                return;
            }
            if (!DA.GetDataList(1, points))
            {
                return;
            }
            if (!DA.GetData(2, ref translation))
            {
                return;
            }
            if (!DA.GetData(3, ref rotation))
            {
                return;
            }

            structuretype.CastTo <ComputedStructure>(ref structure);

            structure = structuretype.Value;

            foreach (Point3d point in points)
            {
                foreach (StructureEngine.Model.Node node in structure.Nodes)
                {
                    if (node.IsAtPoint(point))
                    {
                        node.DOFs[0].Fixed = translation;
                        node.DOFs[1].Fixed = translation;
                        node.DOFs[2].Fixed = translation;
                    }
                }
            }
            //points.Remove(point); collection was modified each time -> error



            foreach (Point3d point in points)
            {
                foreach (StructureEngine.Model.Node node in structure.Nodes)
                {
                    if (node.IsAtPoint(point))
                    {
                        node.DOFs[3].Fixed = rotation;
                        node.DOFs[4].Fixed = rotation;
                        node.DOFs[5].Fixed = rotation;
                    }
                }
                //points.Remove(point); collection was modified each time -> error
            }

            /*Assign the outputs via the DA object*/
            Types.StructureType Structure_GH = new Types.StructureType(structure);
            DA.SetData(0, Structure_GH);
            //DA.SetData(1, info);
        }