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