/// <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); }
/// <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); }
/// <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); }