The map class which store the data and display in formulaDataGridView
Esempio n. 1
0
 /// <summary>
 /// Add a formula with the load case name
 /// </summary>
 /// <param name="caseName">The name of the load case</param>
 /// <returns>true if the creation is successful; otherwise, false</returns>
 public Boolean AddFormula(String caseName)
 {
     // New a FormulaMap, and add it to m_dataBuffer.FormulaMap
     // Note: the factor of the formula is always set 1
     FormulaMap map = new FormulaMap(caseName);
     m_dataBuffer.FormulaMap.Add(map);
     return true;
 }
Esempio n. 2
0
        /// <summary>
        /// Add a formula with the load case name
        /// </summary>
        /// <param name="caseName">The name of the load case</param>
        /// <returns>true if the creation is successful; otherwise, false</returns>
        public Boolean AddFormula(String caseName)
        {
            // New a FormulaMap, and add it to m_dataBuffer.FormulaMap
            // Note: the factor of the formula is always set 1
            FormulaMap map = new FormulaMap(caseName);

            m_dataBuffer.FormulaMap.Add(map);
            return(true);
        }
Esempio n. 3
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);
        }
Esempio n. 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);
        }