A class to store Load Combination and it's properties.
Пример #1
0
        /// <summary>
        /// Find out all Load Combination and Usage in the existing document.
        /// As specification require, prepare some Load Combination Usages if they are not in document
        /// </summary>
        public void PrepareData()
        {
            // Find out all  Load Combination and Usage in the existing document.
            IList <Element> elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadCombination)).ToElements();

            foreach (Element elem in elements)
            {
                LoadCombination combination = elem as LoadCombination;
                if (null != combination)
                {
                    // Add the Load Combination name.
                    m_dataBuffer.LoadCombinationNames.Add(combination.Name);

                    // Create LoadCombinationMap object.
                    LoadCombinationMap combinationMap = new LoadCombinationMap(combination);

                    // Add the LoadCombinationMap object to the array list.
                    m_dataBuffer.LoadCombinationMap.Add(combinationMap);
                }
            }

            elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadUsage)).ToElements();
            foreach (Element elem in elements)
            {
                // Add Load Combination Usage information
                LoadUsage usage = elem as LoadUsage;
                if (null != usage)
                {
                    // Add the Load Usage name
                    m_dataBuffer.LoadUsageNames.Add(usage.Name);

                    // Add the Load Usage object to a LoadUsageArray
                    m_dataBuffer.LoadUsages.Add(usage);

                    // Add the Load Usage information to UsageMap.
                    UsageMap usageMap = new UsageMap(m_dataBuffer, usage.Name);
                    m_dataBuffer.UsageMap.Add(usageMap);
                }
            }

            // As specification require, some Load Combination Usages if they are not in document
            String[] initUsageArray = { "Gravity", "Lateral", "Steel", "Composite", "Concrete" };
            foreach (String s in initUsageArray)
            {
                NewLoadUsage(s);
            }
        }
Пример #2
0
        /// <summary>
        /// Create new Load Combination
        /// </summary>
        /// <param name="name">The new Load Combination name</param>
        /// <param name="typeIndex">The index of new Load Combination Type</param>
        /// <param name="stateIndex">The index of new Load Combination State</param>
        /// <returns>true if the creation was successful; otherwise, false</returns>
        public Boolean NewLoadCombination(String name, int typeIndex, int stateIndex)
        {
            // Define some data for creation.
            List <ElementId>     usageIds   = new List <ElementId>();
            List <LoadComponent> components = new List <LoadComponent>();

            double[] factorArray = new double[m_dataBuffer.FormulaMap.Count];

            // First check whether the name has been used
            foreach (String s in m_dataBuffer.LoadCombinationNames)
            {
                if (s == name || null == name)
                {
                    m_dataBuffer.ErrorInformation = "the combination name has been used.";
                    return(false);
                }
            }

            // Get the usage information.
            foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
            {
                if (true == usageMap.Set)
                {
                    LoadUsage usage = FindUsageByName(usageMap.Name);
                    if (null != usage)
                    {
                        usageIds.Add(usage.Id);
                    }
                }
            }

            // Get the formula information
            for (int i = 0; i < m_dataBuffer.FormulaMap.Count; i++)
            {
                FormulaMap formulaMap = m_dataBuffer.FormulaMap[i];
                factorArray[i] = formulaMap.Factor;
                LoadCase loadCase = FindLoadCaseByName(formulaMap.Case);
                if (null != loadCase)
                {
                    LoadComponent component = new LoadComponent(loadCase.Id, formulaMap.Factor);
                    components.Add(component);
                }
            }


            // Begin to new a load combination
            try
            {
                LoadCombination loadCombination = LoadCombination.Create(m_document, name, (LoadCombinationType)typeIndex, (LoadCombinationState)stateIndex);
                if (null == loadCombination)
                {
                    m_dataBuffer.ErrorInformation = "Get null reference after usage creation.";
                    return(false);
                }
                loadCombination.SetComponents(components);
                loadCombination.SetUsageIds(usageIds);

                // Store this load combination information for further use
                m_dataBuffer.LoadCombinationNames.Add(loadCombination.Name);
                LoadCombinationMap combinationMap = new LoadCombinationMap(loadCombination);
                m_dataBuffer.LoadCombinationMap.Add(combinationMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation = e.Message;
                return(false);
            }

            // If create combination successful, reset the usage check state and clear the formula
            foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
            {
                usageMap.Set = false;
            }
            m_dataBuffer.FormulaMap.Clear();
            return(true);
        }
Пример #3
0
        /// <summary>
        /// Find out all Load Combination and Usage in the existing document.
        /// As specification require, prepare some Load Combination Usages if they are not in document
        /// </summary>
        public void PrepareData()
        {
            // Find out all  Load Combination and Usage in the existing document.
            IList<Element> elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadCombination)).ToElements();
            foreach (Element elem in elements)
            {
                LoadCombination combination = elem as LoadCombination;
                if (null != combination)
                {
                    // Add the Load Combination name.
                    m_dataBuffer.LoadCombinationNames.Add(combination.Name);

                    // Create LoadCombinationMap object.
                    LoadCombinationMap combinationMap = new LoadCombinationMap(combination);

                    // Add the LoadCombinationMap object to the array list.
                    m_dataBuffer.LoadCombinationMap.Add(combinationMap);
                }
            }

            elements  = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadUsage)).ToElements();
            foreach (Element elem in elements)
            {
                // Add Load Combination Usage information
                LoadUsage usage = elem as LoadUsage;
                if (null != usage)
                {
                    // Add the Load Usage name
                    m_dataBuffer.LoadUsageNames.Add(usage.Name);

                    // Add the Load Usage object to a LoadUsageArray
                    m_dataBuffer.LoadUsages.Add(usage);

                    // Add the Load Usage information to UsageMap.
                    UsageMap usageMap = new UsageMap(m_dataBuffer, usage.Name);
                    m_dataBuffer.UsageMap.Add(usageMap);
                }
            }

            // As specification require, some Load Combination Usages if they are not in document
            String[] initUsageArray = { "Gravity", "Lateral", "Steel", "Composite", "Concrete"};
            foreach (String s in initUsageArray)
            {
                NewLoadUsage(s);
            }
        }
Пример #4
0
        /// <summary>
        /// Create new Load Combination
        /// </summary>
        /// <param name="name">The new Load Combination name</param>
        /// <param name="typeId">The index of new Load Combination Type</param>
        /// <param name="stateId">The index of new Load Combination State</param>
        /// <returns>true if the creation was successful; otherwise, false</returns>
        public Boolean NewLoadCombination(String name, int typeId, int stateId)
        {
            // Define some data for creation.
            LoadUsageArray       usageArray   = new LoadUsageArray();
            LoadCaseArray        caseArray    = new LoadCaseArray();
            LoadCombinationArray combinations = new LoadCombinationArray();

            double[] factorArray = new double[m_dataBuffer.FormulaMap.Count];

            // First check whether the name has been used
            foreach (String s in m_dataBuffer.LoadCombinationNames)
            {
                if (s == name || null == name)
                {
                    m_dataBuffer.ErrorInformation = "the combination name has been used.";
                    return(false);
                }
            }

            // Get the usage information.
            foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
            {
                if (true == usageMap.Set)
                {
                    LoadUsage usage = FindUsageByName(usageMap.Name);
                    if (null != usage)
                    {
                        usageArray.Append(usage);
                    }
                }
            }

            // Get the formula information
            for (int i = 0; i < m_dataBuffer.FormulaMap.Count; i++)
            {
                FormulaMap formulaMap = m_dataBuffer.FormulaMap[i];
                factorArray[i] = formulaMap.Factor;
                LoadCase loadCase = FindLoadCaseByName(formulaMap.Case);
                if (null != loadCase)
                {
                    caseArray.Append(loadCase);
                }
            }


            // Begin to new a load combination
            try
            {
                LoadCombination loadCombination = m_document.Create.NewLoadCombination(name,
                                                                                       typeId, stateId, factorArray, caseArray, combinations, usageArray);
                if (null == loadCombination)
                {
                    m_dataBuffer.ErrorInformation = "Get null reference after usage creation.";
                    return(false);
                }
                // Store this load combination information for further use
                m_dataBuffer.LoadCombinationNames.Add(loadCombination.Name);
                LoadCombinationMap combinationMap = new LoadCombinationMap(loadCombination);
                m_dataBuffer.LoadCombinationMap.Add(combinationMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation = e.Message;
                return(false);
            }

            // If create combination successful, reset the usage check state and clear the formula
            foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
            {
                usageMap.Set = false;
            }
            m_dataBuffer.FormulaMap.Clear();
            return(true);
        }
Пример #5
0
        /// <summary>
        /// Create new Load Combination
        /// </summary>
        /// <param name="name">The new Load Combination name</param>
        /// <param name="typeId">The index of new Load Combination Type</param>
        /// <param name="stateId">The index of new Load Combination State</param>
        /// <returns>true if the creation was successful; otherwise, false</returns>
        public Boolean NewLoadCombination(String name, int typeId, int stateId)
        {
            // Define some data for creation.
            LoadUsageArray usageArray = new LoadUsageArray();
            LoadCaseArray caseArray = new LoadCaseArray();
            LoadCombinationArray combinations = new LoadCombinationArray();
            double[] factorArray = new double[m_dataBuffer.FormulaMap.Count];

            // First check whether the name has been used
            foreach (String s in m_dataBuffer.LoadCombinationNames)
            {
                if (s == name || null == name)
                {
                    m_dataBuffer.ErrorInformation = "the combination name has been used.";
                    return false;
                }
            }

            // Get the usage information.
            foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
            {
                if (true == usageMap.Set)
                {
                    LoadUsage usage = FindUsageByName(usageMap.Name);
                    if (null != usage)
                    {
                        usageArray.Append(usage);
                    }
                }
            }

            // Get the formula information
            for (int i = 0; i < m_dataBuffer.FormulaMap.Count; i++)
            {
                FormulaMap formulaMap = m_dataBuffer.FormulaMap[i];
                factorArray[i] = formulaMap.Factor;
                LoadCase loadCase = FindLoadCaseByName(formulaMap.Case);
                if(null != loadCase)
                {
                    caseArray.Append(loadCase);
                }
            }

            // Begin to new a load combination
            try
            {
                LoadCombination loadCombination = m_document.Create.NewLoadCombination(name,
                                        typeId, stateId, factorArray, caseArray, combinations, usageArray);
                if (null == loadCombination)
                {
                    m_dataBuffer.ErrorInformation = "Get null reference after usage creation.";
                    return false;
                }
                // Store this load combination information for further use
                m_dataBuffer.LoadCombinationNames.Add(loadCombination.Name);
                LoadCombinationMap combinationMap = new LoadCombinationMap(loadCombination);
                m_dataBuffer.LoadCombinationMap.Add(combinationMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation = e.Message;
                return false;
            }

            // If create combination successful, reset the usage check state and clear the formula
            foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
            {
                usageMap.Set = false;
            }
            m_dataBuffer.FormulaMap.Clear();
            return true;
        }