private List <LoadCombination> ReadLoadCombination(List <string> ids = null)
        {
            // Linear Load Combinations !! Only !!
            // only solver generated combinations
            List <LoadCombination> loadCombinations = new List <LoadCombination>();
            int             err            = 0;
            int             uID            = 1;
            int             freedomCase    = 1;
            int             loadComboCount = 0;
            List <Loadcase> allLoadCases   = ReadLoadcase();

            err = St7.St7GetNumLSACombinations(uID, ref loadComboCount);
            if (!St7ErrorCustom(err, "Could not get loadCombinations"))
            {
                return(loadCombinations);
            }

            for (int ldCombo = 1; ldCombo <= loadComboCount; ldCombo++)
            {
                StringBuilder loadComboName = new StringBuilder(St7.kMaxStrLen);
                err = St7.St7GetLSACombinationName(uID, ldCombo, loadComboName, St7.kMaxStrLen);
                if (!St7ErrorCustom(err, "Could not get a name of load combination " + ldCombo))
                {
                    continue;
                }
                List <double> loadCaseFactors = new List <double>();
                for (int j = 0; j < allLoadCases.Count; j++)
                {
                    int    loadcaseNum = GetAdapterId <int>(allLoadCases[j]);
                    double factor      = 0;
                    err = St7.St7GetLSACombinationFactor(uID, St7.ltLoadCase, ldCombo, loadcaseNum, freedomCase, ref factor);
                    if (!St7ErrorCustom(err, "Could not get a factor for a loadcase " + loadcaseNum + " load combo " + ldCombo))
                    {
                        return(loadCombinations);
                    }
                    loadCaseFactors.Add(factor);
                }
                LoadCombination loadCombination = BH.Engine.Structure.Create.LoadCombination(loadComboName.ToString(), ldCombo, allLoadCases, loadCaseFactors);
                SetAdapterId(loadCombination, ldCombo);
                loadCombinations.Add(loadCombination);
            }
            return(loadCombinations);
        }
Exemple #2
0
        /***************************************************/
        /**** Adapter overload method                   ****/
        /***************************************************/

        // Method that returns the next free index for a specific object type as 'object'.
        // 'object' is required as ID is software specific (could be int, string, Guid or anything else).
        // NextId is called in the base Adapter Push method, just before the call to Create();
        // it follows that at the point of index assignment, the objects have not yet been created in the target software.
        // This is to ensure that the object exported in the software will have the the ID that we decided here.
        protected override object NextFreeId(Type objectType, bool refresh = false)
        {
            //Change from object to what the specific software is using
            int index = 1;
            int uID   = 1;

            if (!refresh && m_indexDict.TryGetValue(objectType, out index))
            {
                index++;
            }
            else if (objectType == typeof(Loadcase))
            {
                int err           = 0;
                int loadCaseCount = 0;
                err = St7.St7GetNumLoadCase(uID, ref loadCaseCount);
                // check if it is default loadcase and override it
                if (loadCaseCount == 1)
                {
                    StringBuilder loadCaseName = new StringBuilder(St7.kMaxStrLen);
                    err = St7.St7GetLoadCaseName(1, 1, loadCaseName, St7.kMaxStrLen);
                    if (loadCaseName.ToString() == "Load Case 1")
                    {
                        loadCaseCount = 0;
                    }
                }
                if (St7Error(err))
                {
                    index = loadCaseCount + 1;
                }
            }
            else if (objectType == typeof(Node))
            {
                int err       = 0;
                int nodeCount = 0;
                err = St7.St7GetTotal(uID, St7.tyNODE, ref nodeCount);
                if (St7Error(err))
                {
                    index = nodeCount + 1;
                }
            }
            else if (objectType == typeof(St7RigidMPLink))
            {
                int err       = 0;
                int linkCount = 0;
                err = St7.St7GetTotal(uID, St7.tyLINK, ref linkCount);
                if (St7Error(err))
                {
                    index = linkCount + 1;
                }
            }
            else if (objectType == typeof(LoadCombination))
            {
                int err            = 0;
                int loadComboCount = 0;
                err = St7.St7GetNumLSACombinations(uID, ref loadComboCount);
                if (St7Error(err))
                {
                    index = loadComboCount + 1;
                }
            }
            else if (objectType == typeof(Bar))
            {
                int err       = 0;
                int beamCount = 0;
                err = St7.St7GetTotal(uID, St7.tyBEAM, ref beamCount);
                if (St7Error(err))
                {
                    index = beamCount + 1;
                }
            }
            else if (typeof(IAreaElement).IsAssignableFrom(objectType))
            {
                int err        = 0;
                int plateCount = 0;
                err = St7.St7GetTotal(uID, St7.tyPLATE, ref plateCount);
                if (St7Error(err))
                {
                    index = plateCount + 1;
                }
            }
            else if (typeof(IFace).IsAssignableFrom(objectType))
            {
                int err        = 0;
                int plateCount = 0;
                err = St7.St7GetTotal(uID, St7.tyPLATE, ref plateCount);
                if (St7Error(err))
                {
                    index = plateCount + 1;
                }
            }
            else if (typeof(ISectionProperty).IsAssignableFrom(objectType))
            {
                int   err             = 0;
                int[] propCount       = new int[St7.kMaxEntityTotals - 1];
                int[] propLastNumbers = new int[St7.kMaxEntityTotals - 1];
                err = St7.St7GetTotalProperties(uID, propCount, propLastNumbers);
                if (St7Error(err))
                {
                    index = propLastNumbers[St7.ipBeamPropTotal] + 1;
                }
            }
            else if (typeof(ISurfaceProperty).IsAssignableFrom(objectType))
            {
                int   err             = 0;
                int[] propCount       = new int[St7.kMaxEntityTotals - 1];
                int[] propLastNumbers = new int[St7.kMaxEntityTotals - 1];
                err = St7.St7GetTotalProperties(uID, propCount, propLastNumbers);
                if (St7Error(err))
                {
                    index = propLastNumbers[St7.ipPlatePropTotal] + 1;
                }
            }

            m_indexDict[objectType] = index;
            return(index);
        }