/// <summary>
        /// Method to convert a single of loads into dictionaries containing GsaAPI objects. Maintains the referenced dictionaries and counters.
        /// </summary>
        /// <param name="load"></param>
        /// <param name="gravityLoads"></param>
        /// <param name="nodeLoads_node"></param>
        /// <param name="nodeLoads_displ"></param>
        /// <param name="nodeLoads_settle"></param>
        /// <param name="beamLoads"></param>
        /// <param name="faceLoads"></param>
        /// <param name="gridPointLoads"></param>
        /// <param name="gridLineLoads"></param>
        /// <param name="gridAreaLoads"></param>
        /// <param name="existingAxes"></param>
        /// <param name="axisidcounter"></param>
        /// <param name="existingGridPlanes"></param>
        /// <param name="gridplaneidcounter"></param>
        /// <param name="existingGridSurfaces"></param>
        /// <param name="gridsurfaceidcounter"></param>
        /// <param name="gp_guid"></param>
        /// <param name="gs_guid"></param>
        public static void ConvertLoad(GsaLoad load,
                                       ref List <GravityLoad> gravityLoads,
                                       ref List <NodeLoad> nodeLoads_node, ref List <NodeLoad> nodeLoads_displ, ref List <NodeLoad> nodeLoads_settle,
                                       ref List <BeamLoad> beamLoads, ref List <FaceLoad> faceLoads,
                                       ref List <GridPointLoad> gridPointLoads, ref List <GridLineLoad> gridLineLoads, ref List <GridAreaLoad> gridAreaLoads,
                                       ref Dictionary <int, Axis> existingAxes, ref int axisidcounter,
                                       ref Dictionary <int, GridPlane> existingGridPlanes, ref int gridplaneidcounter,
                                       ref Dictionary <int, GridSurface> existingGridSurfaces, ref int gridsurfaceidcounter,
                                       ref Dictionary <Guid, int> gp_guid, ref Dictionary <Guid, int> gs_guid)
        {
            switch (load.LoadType)
            {
            case GsaLoad.LoadTypes.Gravity:
                gravityLoads.Add(load.GravityLoad.GravityLoad);
                break;

            case GsaLoad.LoadTypes.Node:
                if (load.NodeLoad.NodeLoadType == GsaNodeLoad.NodeLoadTypes.APPLIED_DISP)
                {
                    nodeLoads_displ.Add(load.NodeLoad.NodeLoad);
                }
                if (load.NodeLoad.NodeLoadType == GsaNodeLoad.NodeLoadTypes.NODE_LOAD)
                {
                    nodeLoads_node.Add(load.NodeLoad.NodeLoad);
                }
                if (load.NodeLoad.NodeLoadType == GsaNodeLoad.NodeLoadTypes.SETTLEMENT)
                {
                    nodeLoads_settle.Add(load.NodeLoad.NodeLoad);
                }
                break;

            case GsaLoad.LoadTypes.Beam:
                beamLoads.Add(load.BeamLoad.BeamLoad);
                break;

            case GsaLoad.LoadTypes.Face:
                faceLoads.Add(load.FaceLoad.FaceLoad);
                break;

            case GsaLoad.LoadTypes.GridPoint:
                if (load.PointLoad.GridPlaneSurface == null)     // if gridsurface id has been set
                {
                    // add the load to our list of loads to be set later
                    gridPointLoads.Add(load.PointLoad.GridPointLoad);
                    break;
                }

                // set grid point load and grid plane surface
                GsaGridPointLoad    gridptref  = load.PointLoad;
                GsaGridPlaneSurface gridplnsrf = gridptref.GridPlaneSurface;

                if (gridplnsrf.GridPlane != null)
                {
                    // - grid load references a grid surface number
                    // -- grid surface references a grid plane number
                    // --- grid plane references an Axis number
                    // toggle through the members in reverse order, set/add to model in each step

                    // ### AXIS ###
                    // set axis property in grid plane, add/set axis in model
                    gridplnsrf.GridPlane.AxisProperty = SetAxis(ref gridplnsrf, ref existingAxes, ref axisidcounter);

                    // ### GRID PLANE ###
                    // set grid plane number in grid surface, add/set grid plane in model
                    gridplnsrf.GridSurface.GridPlane = SetGridPlane(ref gridplnsrf, ref existingGridPlanes, ref gridplaneidcounter, ref gp_guid, existingAxes);

                    // ### GRID SURFACE ###
                    // set the surface number in the load, add/set the surface in the model
                    gridptref.GridPointLoad.GridSurface = SetGridSurface(ref gridplnsrf, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gs_guid, existingGridPlanes, existingAxes);
                }

                // add the load to our list of loads to be set later
                gridPointLoads.Add(gridptref.GridPointLoad);
                break;

            case GsaLoad.LoadTypes.GridLine:
                if (load.LineLoad.GridPlaneSurface == null)     // if gridsurface id has been set
                {
                    // add the load to our list of loads to be set later
                    gridLineLoads.Add(load.LineLoad.GridLineLoad);
                    break;
                }

                // set grid line load and grid plane surface
                GsaGridLineLoad gridlnref = load.LineLoad;
                gridplnsrf = gridlnref.GridPlaneSurface;

                if (gridplnsrf.GridPlane != null)
                {
                    // - grid load references a grid surface number
                    // -- grid surface references a grid plane number
                    // --- grid plane references an Axis number
                    // toggle through the members in reverse order, set/add to model in each step

                    // ### AXIS ###
                    // set axis property in grid plane, add/set axis in model
                    gridplnsrf.GridPlane.AxisProperty = SetAxis(ref gridplnsrf, ref existingAxes, ref axisidcounter);

                    // ### GRID PLANE ###
                    // set grid plane number in grid surface, add/set grid plane in model
                    gridplnsrf.GridSurface.GridPlane = SetGridPlane(ref gridplnsrf, ref existingGridPlanes, ref gridplaneidcounter, ref gp_guid, existingAxes);

                    // ### GRID SURFACE ###
                    // set the surface number in the load, add/set the surface in the model
                    gridlnref.GridLineLoad.GridSurface = SetGridSurface(ref gridplnsrf, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gs_guid, existingGridPlanes, existingAxes);
                }
                // add the load to our list of loads to be set later
                gridLineLoads.Add(gridlnref.GridLineLoad);
                break;

            case GsaLoad.LoadTypes.GridArea:
                if (load.AreaLoad.GridPlaneSurface == null)     // if gridsurface id has been set
                {
                    // add the load to our list of loads to be set later
                    gridAreaLoads.Add(load.AreaLoad.GridAreaLoad);
                    break;
                }

                // set grid line load and grid plane surface
                GsaGridAreaLoad gridarref = load.AreaLoad;
                gridplnsrf = gridarref.GridPlaneSurface;

                if (gridplnsrf.GridPlane != null)
                {
                    // - grid load references a grid surface number
                    // -- grid surface references a grid plane number
                    // --- grid plane references an Axis number
                    // toggle through the members in reverse order, set/add to model in each step

                    // ### AXIS ###
                    // set axis property in grid plane, add/set axis in model
                    gridplnsrf.GridPlane.AxisProperty = SetAxis(ref gridplnsrf, ref existingAxes, ref axisidcounter);

                    // ### GRID PLANE ###
                    // set grid plane number in grid surface, add/set grid plane in model
                    gridplnsrf.GridSurface.GridPlane = SetGridPlane(ref gridplnsrf, ref existingGridPlanes, ref gridplaneidcounter, ref gp_guid, existingAxes);

                    // ### GRID SURFACE ###
                    // set the surface number in the load, add/set the surface in the model
                    gridarref.GridAreaLoad.GridSurface = SetGridSurface(ref gridplnsrf, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gs_guid, existingGridPlanes, existingAxes);
                }
                // add the load to our list of loads to be set later
                gridAreaLoads.Add(gridarref.GridAreaLoad);
                break;
            }
        }
Beispiel #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaGridPointLoad gridpointload = new GsaGridPointLoad();

            // 0 Load case
            int        lc    = 1;
            GH_Integer gh_lc = new GH_Integer();

            if (DA.GetData(0, ref gh_lc))
            {
                GH_Convert.ToInt32(gh_lc, out lc, GH_Conversion.Both);
            }
            gridpointload.GridPointLoad.Case = lc;

            // 1 Point
            Point3d  pt    = new Point3d();
            GH_Point gh_pt = new GH_Point();

            if (DA.GetData(1, ref gh_pt))
            {
                GH_Convert.ToPoint3d(gh_pt, ref pt, GH_Conversion.Both);
            }
            gridpointload.GridPointLoad.X = pt.X;
            gridpointload.GridPointLoad.Y = pt.Y;

            // 2 Plane
            GsaGridPlaneSurface grdplnsrf;
            Plane            pln    = Plane.WorldXY;
            GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

            if (DA.GetData(2, ref gh_typ))
            {
                if (gh_typ.Value is GsaGridPlaneSurfaceGoo)
                {
                    GsaGridPlaneSurface temppln = new GsaGridPlaneSurface();
                    gh_typ.CastTo(ref temppln);
                    grdplnsrf = temppln.Duplicate();
                    gridpointload.GridPlaneSurface = grdplnsrf;
                }
                else if (gh_typ.Value is Plane)
                {
                    gh_typ.CastTo(ref pln);
                    grdplnsrf = new GsaGridPlaneSurface(pln);
                    gridpointload.GridPlaneSurface = grdplnsrf;
                }
                else
                {
                    int id = 0;
                    if (GH_Convert.ToInt32(gh_typ.Value, out id, GH_Conversion.Both))
                    {
                        gridpointload.GridPointLoad.GridSurface = id;
                        gridpointload.GridPlaneSurface          = null;
                    }
                    else
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in GPS input. Accepted inputs are Grid Plane Surface or Plane. " +
                                          System.Environment.NewLine + "If no input here then the point's z-coordinate will be used for an xy-plane at that elevation");
                        return;
                    }
                }
            }
            else
            {
                pln        = Plane.WorldXY;
                pln.Origin = pt;
                grdplnsrf  = new GsaGridPlaneSurface(pln);
                gridpointload.GridPlaneSurface = grdplnsrf;
            }

            // 3 direction
            string    dir   = "Z";
            Direction direc = Direction.Z;

            GH_String gh_dir = new GH_String();

            if (DA.GetData(3, ref gh_dir))
            {
                GH_Convert.ToString(gh_dir, out dir, GH_Conversion.Both);
            }
            dir = dir.ToUpper();
            if (dir == "X")
            {
                direc = Direction.X;
            }
            if (dir == "Y")
            {
                direc = Direction.Y;
            }

            gridpointload.GridPointLoad.Direction = direc;

            // 4 Axis
            int axis = 0;

            gridpointload.GridPointLoad.AxisProperty = 0;
            GH_Integer gh_ax = new GH_Integer();

            if (DA.GetData(4, ref gh_ax))
            {
                GH_Convert.ToInt32(gh_ax, out axis, GH_Conversion.Both);
                if (axis == 0 || axis == -1)
                {
                    gridpointload.GridPointLoad.AxisProperty = axis;
                }
            }

            // 5 Name
            string    name    = "";
            GH_String gh_name = new GH_String();

            if (DA.GetData(5, ref gh_name))
            {
                if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both))
                {
                    gridpointload.GridPointLoad.Name = name;
                }
            }

            // 6 load value
            double load = 0;

            if (DA.GetData(6, ref load))
            {
                load *= -1000; //convert to kN
            }
            gridpointload.GridPointLoad.Value = load;

            // convert to goo
            GsaLoad gsaLoad = new GsaLoad(gridpointload);

            DA.SetData(0, new GsaLoadGoo(gsaLoad));
        }