The map class which store the data and display in usageDataGridView
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new load combination usage
        /// </summary>
        /// <param name="usageName">The new Load Usage name</param>
        /// <returns>true if the process is successful; otherwise, false</returns>
        public Boolean NewLoadUsage(String usageName)
        {
            // First check whether the name has been used
            foreach (String s in m_dataBuffer.LoadUsageNames)
            {
                if (usageName == s)
                {
                    m_dataBuffer.ErrorInformation = "the usage name has been used.";
                    return(false);
                }
            }

            // Begin to new a load combination usage
            try
            {
                LoadUsage loadUsage = LoadUsage.Create(m_document, usageName);
                if (null == loadUsage)
                {
                    m_dataBuffer.ErrorInformation = "Get null reference after usage creation.";
                    return(false);
                }
                // Store this load usage information for further use.
                m_dataBuffer.LoadUsageNames.Add(loadUsage.Name);
                m_dataBuffer.LoadUsages.Add(loadUsage);

                // Add the Load Usage information to UsageMap.
                UsageMap usageMap = new UsageMap(m_dataBuffer, loadUsage.Name);
                m_dataBuffer.UsageMap.Add(usageMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation = e.Message;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new load combination usage
        /// </summary>
        /// <param name="usageName">The new Load Usage name</param>
        /// <returns>true if the process is successful; otherwise, false</returns> 
        public Boolean NewLoadUsage(String usageName)
        {
            // First check whether the name has been used
            foreach (String s in m_dataBuffer.LoadUsageNames)
            {
                if(usageName == s)
                {
                    m_dataBuffer.ErrorInformation = "the usage name has been used.";
                    return false;
                }
            }

            // Begin to new a load combination usage
            try
            {
                LoadUsage loadUsage = m_document.Create.NewLoadUsage(usageName);
                if (null == loadUsage)
                {
                    m_dataBuffer.ErrorInformation = "Get null reference after usage creation.";
                    return false;
                }
                // Store this load usage information for further use.
                m_dataBuffer.LoadUsageNames.Add(loadUsage.Name);
                m_dataBuffer.LoadUsages.Add(loadUsage);

                // Add the Load Usage information to UsageMap.
                UsageMap usageMap = new UsageMap(m_dataBuffer, loadUsage.Name);
                m_dataBuffer.UsageMap.Add(usageMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation = e.Message;
                return false;
            }

            return true;
        }