Esempio n. 1
0
        private List <ILoad> ReadBarDistributedLoad(List <Loadcase> loadcases)
        {
            int err = 0;
            Dictionary <int, Loadcase> lcDict = loadcases.ToDictionary(x => GetAdapterId <int>(x));
            List <ILoad> bhLoads = new List <ILoad>();
            List <Bar>   allBars = ReadBars();

            foreach (Bar bar in allBars)
            {
                double length = BH.Engine.Geometry.Query.Length(BH.Engine.Structure.Query.Centreline(bar));
                int    barId  = GetAdapterId <int>(bar);

                // global Distributed Forces
                int globalDistForceCount = 0;
                err = St7.St7GetEntityAttributeSequenceCount(1, St7.tyBEAM, barId, St7.aoBeamDLG, ref globalDistForceCount);
                if (globalDistForceCount > 0)
                {
                    // getting load IDs and direction
                    int[] sequenceNumbers = new int[globalDistForceCount * 4];
                    err = St7.St7GetEntityAttributeSequence(1, St7.tyBEAM, barId, St7.aoBeamDLG, globalDistForceCount, sequenceNumbers);
                    for (int i = 0; i < globalDistForceCount; i++)
                    {
                        int      loadCaseNum      = sequenceNumbers[4 * i + St7.ipAttrCase];
                        int      loadDir          = sequenceNumbers[4 * i + St7.ipAttrAxis];
                        int      loadID           = sequenceNumbers[4 * i + St7.ipAttrID];
                        double   loadX            = loadDir == 1 ? 1 : 0;
                        double   loadY            = loadDir == 2 ? 1 : 0;
                        double   loadZ            = loadDir == 3 ? 1 : 0;
                        int      projected        = 0;
                        int      distributionType = 0;
                        double[] forcesG          = new double[6];
                        err = St7.St7GetBeamDistributedForceGlobal6ID(1, barId, loadDir, loadCaseNum, loadID, ref projected, ref distributionType, forcesG);
                        // adding load case, object information to loads
                        bhLoads.AddRange(DistributedBarLoadsFromSt7(loadX, loadY, loadZ, distributionType, length, forcesG, new double[6], lcDict[loadCaseNum], bar, projected == St7.bpProjected, LoadAxis.Global));
                    }
                }
                // principal Distributed Forces
                int principalDistForceCount = 0;
                err = St7.St7GetEntityAttributeSequenceCount(1, St7.tyBEAM, barId, St7.aoBeamDLL, ref principalDistForceCount);
                if (principalDistForceCount > 0)
                {
                    // getting load IDs and direction
                    int[] sequenceNumbers = new int[principalDistForceCount * 4];
                    err = St7.St7GetEntityAttributeSequence(1, St7.tyBEAM, barId, St7.aoBeamDLL, principalDistForceCount, sequenceNumbers);
                    for (int i = 0; i < principalDistForceCount; i++)
                    {
                        int      loadCaseNum      = sequenceNumbers[4 * i + St7.ipAttrCase];
                        int      loadDir          = sequenceNumbers[4 * i + St7.ipAttrAxis];
                        int      loadID           = sequenceNumbers[4 * i + St7.ipAttrID];
                        double   loadX            = loadDir == 1 ? 1 : 0;
                        double   loadY            = loadDir == 2 ? 1 : 0;
                        double   loadZ            = loadDir == 3 ? 1 : 0;
                        int      distributionType = 0;
                        double[] forcesP          = new double[6];
                        err = St7.St7GetBeamDistributedForcePrincipal6ID(1, barId, loadDir, loadCaseNum, loadID, ref distributionType, forcesP);
                        bhLoads.AddRange(DistributedBarLoadsFromSt7(loadX, loadY, loadZ, distributionType, length, forcesP, new double[6], lcDict[loadCaseNum], bar, false, LoadAxis.Local));
                    }
                }
                // principal Distributed Moments
                int principalDistMomentCount = 0;
                err = St7.St7GetEntityAttributeSequenceCount(1, St7.tyBEAM, barId, St7.aoBeamDML, ref principalDistMomentCount);
                if (principalDistMomentCount > 0)
                {
                    // getting load IDs and direction
                    int[] sequenceNumbers = new int[principalDistMomentCount * 4];
                    err = St7.St7GetEntityAttributeSequence(1, St7.tyBEAM, barId, St7.aoBeamDML, principalDistMomentCount, sequenceNumbers);
                    for (int i = 0; i < principalDistMomentCount; i++)
                    {
                        int      loadCaseNum      = sequenceNumbers[4 * i + St7.ipAttrCase];
                        int      loadDir          = sequenceNumbers[4 * i + St7.ipAttrAxis];
                        int      loadID           = sequenceNumbers[4 * i + St7.ipAttrID];
                        double   loadX            = loadDir == 1 ? 1 : 0;
                        double   loadY            = loadDir == 2 ? 1 : 0;
                        double   loadZ            = loadDir == 3 ? 1 : 0;
                        int      distributionType = 0;
                        double[] momentsP         = new double[6];
                        err = St7.St7GetBeamDistributedMomentPrincipal6ID(1, barId, loadDir, loadCaseNum, loadID, ref distributionType, momentsP);
                        bhLoads.AddRange(DistributedBarLoadsFromSt7(loadX, loadY, loadZ, distributionType, length, new double[6], momentsP, lcDict[loadCaseNum], bar, false, LoadAxis.Local));
                    }
                }
            }
            return(bhLoads);
        }
Esempio n. 2
0
        private List <ILoad> ReadBarPointLoad(List <Loadcase> loadcases)
        {
            int err = 0;
            Dictionary <int, Loadcase> lcDict = loadcases.ToDictionary(x => GetAdapterId <int>(x));
            List <ILoad> bhLoads = new List <ILoad>();
            List <Bar>   allBars = ReadBars();

            foreach (Bar bar in allBars)
            {
                double length = BH.Engine.Geometry.Query.Length(BH.Engine.Structure.Query.Centreline(bar));
                int    barId  = GetAdapterId <int>(bar);

                // ***************** try to get point forces first ************************
                // ****************************** global **********************************
                int globalPointForceCount = 0;
                err = St7.St7GetEntityAttributeSequenceCount(1, St7.tyBEAM, barId, St7.aoBeamCFG, ref globalPointForceCount);
                if (globalPointForceCount > 0)
                {
                    // getting load IDs
                    int[] sequenceNumbers = new int[globalPointForceCount * 4];
                    err = St7.St7GetEntityAttributeSequence(1, St7.tyBEAM, barId, St7.aoBeamCFG, globalPointForceCount, sequenceNumbers);
                    for (int i = 0; i < globalPointForceCount; i++)
                    {
                        int      loadCaseNum = sequenceNumbers[4 * i + St7.ipAttrCase];
                        int      loadID      = sequenceNumbers[4 * i + St7.ipAttrID];
                        double[] forcesG     = new double[4];
                        err = St7.St7GetBeamPointForceGlobal4ID(1, barId, loadCaseNum, loadID, forcesG);
                        if (!IsZeroSqLength(forcesG))
                        {
                            BarPointLoad bhLoad = new BarPointLoad()
                            {
                                DistanceFromA = length * forcesG[3],
                                Force         = new Vector()
                                {
                                    X = forcesG[0], Y = forcesG[1], Z = forcesG[2]
                                },
                                Loadcase  = lcDict[loadCaseNum],
                                Projected = false,
                                Axis      = LoadAxis.Global,
                                Objects   = new BHoMGroup <Bar>()
                                {
                                    Elements = { bar }
                                }
                            };
                            bhLoads.Add(bhLoad);
                        }
                    }
                }
                int globalPointMomentCount = 0;
                err = St7.St7GetEntityAttributeSequenceCount(1, St7.tyBEAM, barId, St7.aoBeamCMG, ref globalPointMomentCount);
                if (globalPointMomentCount > 0)
                {
                    // getting load IDs
                    int[] sequenceNumbers = new int[globalPointMomentCount * 4];
                    err = St7.St7GetEntityAttributeSequence(1, St7.tyBEAM, barId, St7.aoBeamCMG, globalPointMomentCount, sequenceNumbers);
                    for (int i = 0; i < globalPointMomentCount; i++)
                    {
                        int      loadCaseNum = sequenceNumbers[4 * i + St7.ipAttrCase];
                        int      loadID      = sequenceNumbers[4 * i + St7.ipAttrID];
                        double[] momentsG    = new double[4];
                        err = St7.St7GetBeamPointMomentGlobal4ID(1, barId, loadCaseNum, loadID, momentsG);
                        if (!IsZeroSqLength(momentsG))
                        {
                            BarPointLoad bhLoad = new BarPointLoad()
                            {
                                DistanceFromA = length * momentsG[3],
                                Moment        = new Vector()
                                {
                                    X = momentsG[0], Y = momentsG[1], Z = momentsG[2]
                                },
                                Loadcase  = lcDict[loadCaseNum],
                                Projected = false,
                                Axis      = LoadAxis.Global,
                                Objects   = new BHoMGroup <Bar>()
                                {
                                    Elements = { bar }
                                }
                            };
                            bhLoads.Add(bhLoad);
                        }
                    }
                }
                // ****************************** principal **********************************
                int principalPointForceCount = 0;
                err = St7.St7GetEntityAttributeSequenceCount(1, St7.tyBEAM, barId, St7.aoBeamCFL, ref principalPointForceCount);
                if (principalPointForceCount > 0)
                {
                    // getting load IDs
                    int[] sequenceNumbers = new int[principalPointForceCount * 4];
                    err = St7.St7GetEntityAttributeSequence(1, St7.tyBEAM, barId, St7.aoBeamCFL, principalPointForceCount, sequenceNumbers);
                    for (int i = 0; i < principalPointForceCount; i++)
                    {
                        int      loadCaseNum = sequenceNumbers[4 * i + St7.ipAttrCase];
                        int      loadID      = sequenceNumbers[4 * i + St7.ipAttrID];
                        double[] forcesP     = new double[4];
                        err = St7.St7GetBeamPointForcePrincipal4ID(1, barId, loadCaseNum, loadID, forcesP);
                        if (!IsZeroSqLength(forcesP))
                        {
                            BarPointLoad bhLoad = new BarPointLoad()
                            {
                                DistanceFromA = length * forcesP[3],
                                //Force = BH.Engine.Geometry.Modify.Transform(new Vector() { X = forcesP[0], Y = forcesP[1], Z = forcesP[2] }, transformMatrix),
                                Force = new Vector()
                                {
                                    X = forcesP[0], Y = forcesP[1], Z = forcesP[2]
                                },
                                Loadcase  = lcDict[loadCaseNum],
                                Projected = false,
                                Axis      = LoadAxis.Local,
                                Objects   = new BHoMGroup <Bar>()
                                {
                                    Elements = { bar }
                                }
                            };
                            bhLoads.Add(bhLoad);
                        }
                    }
                }
                int principalPointMomentCount = 0;
                err = St7.St7GetEntityAttributeSequenceCount(1, St7.tyBEAM, barId, St7.aoBeamCML, ref principalPointMomentCount);
                if (principalPointMomentCount > 0)
                {
                    // getting load IDs
                    int[] sequenceNumbers = new int[principalPointMomentCount * 4];
                    err = St7.St7GetEntityAttributeSequence(1, St7.tyBEAM, barId, St7.aoBeamCML, principalPointMomentCount, sequenceNumbers);
                    for (int i = 0; i < principalPointMomentCount; i++)
                    {
                        int      loadCaseNum = sequenceNumbers[4 * i + St7.ipAttrCase];
                        int      loadID      = sequenceNumbers[4 * i + St7.ipAttrID];
                        double[] momentsP    = new double[4];
                        err = St7.St7GetBeamPointMomentPrincipal4ID(1, barId, loadCaseNum, loadID, momentsP);
                        if (!IsZeroSqLength(momentsP))
                        {
                            BarPointLoad bhLoad = new BarPointLoad()
                            {
                                DistanceFromA = length * momentsP[3],
                                //Moment = BH.Engine.Geometry.Modify.Transform(new Vector() { X = momentsP[0], Y = momentsP[1], Z = momentsP[2] }, transformMatrix),
                                Moment = new Vector()
                                {
                                    X = momentsP[0], Y = momentsP[1], Z = momentsP[2]
                                },
                                Projected = false,
                                Axis      = LoadAxis.Local,
                                Loadcase  = lcDict[loadCaseNum],
                                Objects   = new BHoMGroup <Bar>()
                                {
                                    Elements = { bar }
                                }
                            };
                            bhLoads.Add(bhLoad);
                        }
                    }
                }
            }
            return(bhLoads);
        }