Ejemplo n.º 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve                  curve                 = null;
            Motions                motions               = null;
            Rotations              rotations             = null;
            MotionsPlasticLimits   motionsPlasticLimit   = null;
            RotationsPlasticLimits rotationsPlasticLimit = null;
            bool movingLocal = false;

            if (!DA.GetData(0, ref curve))
            {
                return;
            }
            if (!DA.GetData(1, ref motions))
            {
                return;
            }
            if (!DA.GetData(2, ref rotations))
            {
                return;
            }
            DA.GetData(3, ref motionsPlasticLimit);
            DA.GetData(4, ref rotationsPlasticLimit);
            DA.GetData(5, ref movingLocal);
            Vector3d v = Vector3d.Zero;

            DA.GetData(6, ref v);

            bool orientLCS = true;

            DA.GetData(7, ref orientLCS);

            string identifier = "S";

            DA.GetData(8, ref identifier);

            if (curve == null || identifier == null)
            {
                return;
            }

            Geometry.Edge edge = Convert.FromRhinoLineOrArc1(curve);
            var           obj  = new Supports.LineSupport(edge, motions, motionsPlasticLimit, rotations, rotationsPlasticLimit, movingLocal, identifier);

            // Set local y-axis
            if (!v.Equals(Vector3d.Zero))
            {
                obj.Group.LocalY = v.FromRhino();
            }
            else // Orient coordinate system to GCS
            {
                if (orientLCS)
                {
                    obj.Group.OrientCoordinateSystemToGCS();
                }
            }

            DA.SetData(0, obj);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            // EXAMPLE 4: EDITING AN EXISTING MODEL
            // In this example, we will edit an existing model by isolating a floor and replacing supporting
            // walls and pillars with appropriate supports. Using height as a point of comparison we can find
            // which elements to reuse from the old model, and create a new model with our selected elements.

            // This example was last updated 2022-04-13, using the ver. 21.1.0 FEM-Design API.


            // READ THE MODEL:
            // Deserialize the current model to access all the data in the .struxml file.
            FemDesign.Model model = FemDesign.Model.DeserializeFromFilePath("Example 4 - model.struxml");


            // ISOLATE A FLOOR:
            // Choose which floor will be singled out.
            int floor = 3;

            FemDesign.StructureGrid.Storey          storey       = model.Entities.Storeys.Storey[floor];
            List <GenericClasses.IStructureElement> storeyAsList = new List <GenericClasses.IStructureElement> {
                storey
            };
            double zCoord = storey.Origo.Z;


            // POINT SUPPORTS:
            // Find all pillars supporting the chosen floor, and place point supports in their place.
            // We can use the fact that point [1] of any pillar is always the highest one.
            var supports = new List <GenericClasses.ISupportElement>();

            for (int i = 0; i < model.Entities.Bars.Count; i++)
            {
                Bars.Bar tempBar = model.Entities.Bars[i];
                if (tempBar.BarPart.Type != Bars.BarType.Column)
                {
                    continue;
                }

                if (Math.Abs(tempBar.BarPart.Edge.Points[1].Z - zCoord) < Tolerance.LengthComparison)
                {
                    var tempSupport = new Supports.PointSupport(
                        point: new Geometry.FdPoint3d(tempBar.BarPart.Edge.Points[1].X, tempBar.BarPart.Edge.Points[1].Y, zCoord),
                        motions: Releases.Motions.RigidPoint(),
                        rotations: Releases.Rotations.Free()
                        );
                    supports.Add(tempSupport);
                }
            }


            // ELEMENTS:
            // The model only contains plates and walls, so we will not be looking for beams etc.
            // We are looking for the floor plate at the right height, and the walls below it to
            // replace them with line supports.
            var elements = new List <GenericClasses.IStructureElement>();

            // TESTING SLABS:
            // Slabs have a property which indicates if they are floors (plate) or walls (wall).
            // Based on this, we can sort out if we want to use them as an element or place a
            // line support in their stead.
            for (int i = 0; i < model.Entities.Slabs.Count; i++)
            {
                Shells.Slab tempSlab = model.Entities.Slabs[i];
                if (tempSlab.Type == Shells.SlabType.Plate && Math.Abs(tempSlab.SlabPart.LocalPos.Z - zCoord) < Tolerance.LengthComparison)
                {
                    elements.Add(tempSlab);
                }
                else if (tempSlab.Type == Shells.SlabType.Wall)
                {
                    if (Math.Abs(tempSlab.SlabPart.Region.Contours[0].Edges[2].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                    {
                        // Creating supports with translational stiffnes in the Z direction only.
                        var tempSupport = new Supports.LineSupport(
                            edge: tempSlab.SlabPart.Region.Contours[0].Edges[2],
                            motions: new Releases.Motions(0, 0, 0, 0, 10E7, 10E7),
                            rotations: new Releases.Rotations(0, 0, 0, 0, 0, 0),
                            movingLocal: true
                            );
                        supports.Add(tempSupport);
                    }
                }
            }

            // TESTING PANELS:
            // Panels do not have the same property as slabs. Instead, we compare the height of all the
            // edge curves of the panel to discern if it is horizontal or not.
            for (int i = 0; i < model.Entities.Panels.Count; i++)
            {
                Shells.Panel tempPanel = model.Entities.Panels[i];
                bool         isSlab    = true;
                for (int j = 0; j < tempPanel.Region.Contours[0].Edges.Count; j++)
                {
                    if (tempPanel.Region.Contours[0].Edges[j].Points[0].Z != tempPanel.Region.Contours[0].Edges[j].Points[1].Z)
                    {
                        isSlab = false;
                        break;
                    }
                }
                if (isSlab && Math.Abs(tempPanel.Region.Contours[0].Edges[0].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                {
                    elements.Add(tempPanel);
                }
                else if (!isSlab && Math.Abs(tempPanel.Region.Contours[0].Edges[2].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                {
                    // Creating supports with translational stiffnes in the Z direction only.
                    var tempSupport = new Supports.LineSupport(
                        edge: tempPanel.Region.Contours[0].Edges[2],
                        motions: new Releases.Motions(0, 0, 0, 0, 10E7, 10E7),
                        rotations: new Releases.Rotations(0, 0, 0, 0, 0, 0),
                        movingLocal: true
                        );
                    supports.Add(tempSupport);
                }
            }


            // LOADS:
            // Similar to supports and elements, we will reuse loads from the model if they are on the correct height
            var loads = new List <GenericClasses.ILoadElement>();

            for (int i = 0; i < model.Entities.Loads.LineLoads.Count; i++)
            {
                if (Math.Abs(model.Entities.Loads.LineLoads[i].Edge.XAxis.Z - zCoord) < Tolerance.LengthComparison)
                {
                    loads.Add(model.Entities.Loads.LineLoads[i]);
                }
            }
            for (int i = 0; i < model.Entities.Loads.SurfaceLoads.Count; i++)
            {
                Loads.SurfaceLoad tempLoad = model.Entities.Loads.SurfaceLoads[i];
                if (Math.Abs(tempLoad.Region.Contours[0].Edges[0].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                {
                    loads.Add(tempLoad);
                }
            }


            // CREATE NEW MODEL:
            // With a new model, we can add all our gathered elements to it. We can also take load cases,
            // load combinations, and the storey marker directly from the old model.
            FemDesign.Model newModel = new FemDesign.Model(Country.S);
            newModel.AddElements(elements);
            newModel.AddSupports(supports);
            newModel.AddLoads(loads);
            newModel.AddLoadCases(model.Entities.Loads.LoadCases);
            newModel.AddLoadCombinations(model.Entities.Loads.LoadCombinations);
            newModel.AddElements(storeyAsList);


            // SAVE AND RUN:
            // Create a file path for the new model, serialize it, and run the script!
            string path = Path.GetFullPath("output/edited_model.struxml");

            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }
            newModel.SerializeModel(path);
            Console.WriteLine($"Opening file at {path}");

            var app = new Calculate.Application();

            app.OpenStruxml(path, false);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get Rhino Curve from LineSupport.
 /// </summary>
 internal static Rhino.Geometry.Curve GetRhinoGeometry(this Supports.LineSupport lineSupport)
 {
     return(lineSupport.Edge.ToRhino());
 }