A class to store Load Case and it's properties.
Beispiel #1
0
        /// <summary>
        /// prepare data for the dialog
        /// </summary>
        public void PrepareData()
        {
            //Create seven Load Natures first
            CreateLoadNatures();

            //get all the categories of load cases
            UIApplication uiapplication = new UIApplication(m_revit);

            //get all the loadnatures name
            IList <Element> elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadNature)).ToElements();

            foreach (Element e in elements)
            {
                LoadNature nature = e as LoadNature;
                if (null != nature)
                {
                    m_dataBuffer.LoadNatures.Add(nature);
                    LoadNaturesMap newLoadNaturesMap = new LoadNaturesMap(nature);
                    m_dataBuffer.LoadNaturesMap.Add(newLoadNaturesMap);
                }
            }
            elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadCase)).ToElements();
            foreach (Element e in elements)
            {
                //get all the loadcases
                LoadCase loadCase = e as LoadCase;
                if (null != loadCase)
                {
                    m_dataBuffer.LoadCases.Add(loadCase);
                    LoadCasesMap newLoadCaseMap = new LoadCasesMap(loadCase);
                    m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Duplicate a new load case
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool DuplicateLoadCase(int index)
        {
            LoadCasesMap myLoadCase = null;
            bool         isUnique   = false;
            string       caseName   = null;

            //try to get the load case from the map
            try
            {
                myLoadCase = m_dataBuffer.LoadCasesMap[index];
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }

            //get nothing
            if (null == myLoadCase)
            {
                m_dataBuffer.ErrorInformation += "Can not find the load case";
                return(false);
            }

            //check the name
            caseName = myLoadCase.LoadCasesName;
            while (!isUnique)
            {
                caseName += "(1)";
                isUnique  = IsCaseNameUnique(caseName);
            }

            //get the selected case's nature
            Autodesk.Revit.DB.Structure.LoadNatureCategory natureCategory = myLoadCase.LoadNatureCategory;
            Autodesk.Revit.DB.ElementId natureId = myLoadCase.LoadCasesNatureId;

            UIApplication uiapplication = new UIApplication(m_revit);

            //try to create a load case
            try
            {
                LoadCase newLoadCase = LoadCase.Create(uiapplication.ActiveUIDocument.Document, caseName, natureId, natureCategory);
                if (null == newLoadCase)
                {
                    m_dataBuffer.ErrorInformation += "Create Load Case Failed";
                    return(false);
                }
                //add the new case into list and map
                m_dataBuffer.LoadCases.Add(newLoadCase);
                LoadCasesMap newLoadCaseMap = new LoadCasesMap(newLoadCase);
                m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// prepare data for the dialog
        /// </summary>
        public void PrepareData()
        {
            //Create seven Load Natures first
            if (!CreateLoadNatures())
            {
                return;
            }

            //get all the categories of load cases
            UIApplication   uiapplication   = new UIApplication(m_revit);
            Categories      categories      = uiapplication.ActiveUIDocument.Document.Settings.Categories;
            Category        category        = categories.get_Item(BuiltInCategory.OST_LoadCases);
            CategoryNameMap categoryNameMap = category.SubCategories;

            System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator();
            iter.Reset();
            while (iter.MoveNext())
            {
                Category temp = iter.Current as Category;
                if (null == temp)
                {
                    continue;
                }
                m_dataBuffer.LoadCasesCategory.Add(temp);
            }

            //get all the loadnatures name
            IList <Element> elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadNature)).ToElements();

            foreach (Element e in elements)
            {
                LoadNature nature = e as LoadNature;
                if (null != nature)
                {
                    m_dataBuffer.LoadNatures.Add(nature);
                    LoadNaturesMap newLoadNaturesMap = new LoadNaturesMap(nature);
                    m_dataBuffer.LoadNaturesMap.Add(newLoadNaturesMap);
                }
            }
            elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadCase)).ToElements();
            foreach (Element e in elements)
            {
                //get all the loadcases
                LoadCase loadCase = e as LoadCase;
                if (null != loadCase)
                {
                    m_dataBuffer.LoadCases.Add(loadCase);
                    LoadCasesMap newLoadCaseMap = new LoadCasesMap(loadCase);
                    m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Duplicate a new load case
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool DuplicateLoadCase(int index)
        {
            LoadCasesMap myLoadCase = null;
            bool         isUnique   = false;
            string       caseName   = null;

            //try to get the load case from the map
            try
            {
                myLoadCase = m_dataBuffer.LoadCasesMap[index];
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }

            //get nothing
            if (null == myLoadCase)
            {
                m_dataBuffer.ErrorInformation += "Can not find the load case";
                return(false);
            }

            //check the name
            caseName = myLoadCase.LoadCasesName;
            while (!isUnique)
            {
                caseName += "(1)";
                isUnique  = IsCaseNameUnique(caseName);
            }

            //get the selected case's nature
            Category   caseCategory = null;
            LoadNature caseNature   = null;

            Autodesk.Revit.DB.ElementId categoryId = myLoadCase.LoadCasesCategoryId;
            Autodesk.Revit.DB.ElementId natureId   = myLoadCase.LoadCasesNatureId;

            UIApplication uiapplication = new UIApplication(m_revit);

            caseNature = uiapplication.ActiveUIDocument.Document.get_Element(natureId) as LoadNature;

            //get the selected case's category
            Categories      categories      = uiapplication.ActiveUIDocument.Document.Settings.Categories;
            Category        category        = categories.get_Item(BuiltInCategory.OST_LoadCases);
            CategoryNameMap categoryNameMap = category.SubCategories;

            System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator();
            iter.Reset();
            while (iter.MoveNext())
            {
                Category tempC = iter.Current as Category;
                if (null != tempC && (categoryId.IntegerValue == tempC.Id.IntegerValue))
                {
                    caseCategory = tempC;
                    break;
                }
            }

            //check if lack of the information
            if (null == caseNature || null == caseCategory || null == caseName)
            {
                m_dataBuffer.ErrorInformation += "Can't find the load case";
                return(false);
            }

            //try to create a load case
            try
            {
                LoadCase newLoadCase = uiapplication.ActiveUIDocument.Document.Create.NewLoadCase(caseName, caseNature, caseCategory);
                if (null == newLoadCase)
                {
                    m_dataBuffer.ErrorInformation += "Create Load Case Failed";
                    return(false);
                }
                //add the new case into list and map
                m_dataBuffer.LoadCases.Add(newLoadCase);
                LoadCasesMap newLoadCaseMap = new LoadCasesMap(newLoadCase);
                m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// prepare data for the dialog
        /// </summary>
        public void PrepareData()
        {
            //Create seven Load Natures first
            if (!CreateLoadNatures())
            {
                return;
            }

            //get all the categories of load cases
            UIApplication uiapplication = new UIApplication(m_revit);
            Categories categories = uiapplication.ActiveUIDocument.Document.Settings.Categories;
            Category category = categories.get_Item(BuiltInCategory.OST_LoadCases);
            CategoryNameMap categoryNameMap = category.SubCategories;
            System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator();
            iter.Reset();
            while (iter.MoveNext())
            {
                Category temp = iter.Current as Category;
                if (null == temp)
                {
                    continue;
                }
                m_dataBuffer.LoadCasesCategory.Add(temp);
            }

            //get all the loadnatures name
            IList<Element> elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadNature)).ToElements();
            foreach (Element e in elements)
            {
                LoadNature nature = e as LoadNature;
                if (null != nature)
                {
                    m_dataBuffer.LoadNatures.Add(nature);
                    LoadNaturesMap newLoadNaturesMap = new LoadNaturesMap(nature);
                    m_dataBuffer.LoadNaturesMap.Add(newLoadNaturesMap);

                }
            }
            elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadCase)).ToElements();
            foreach (Element e in elements)
            {
                //get all the loadcases
                LoadCase loadCase = e as LoadCase;
                if (null != loadCase)
                {
                    m_dataBuffer.LoadCases.Add(loadCase);
                    LoadCasesMap newLoadCaseMap = new LoadCasesMap(loadCase);
                    m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Duplicate a new load case
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool DuplicateLoadCase(int index)
        {
            LoadCasesMap myLoadCase = null;
            bool isUnique = false;
            string caseName = null;

            //try to get the load case from the map
            try
            {
                myLoadCase = m_dataBuffer.LoadCasesMap[index];
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return false;
            }

            //get nothing
            if (null == myLoadCase)
            {
                m_dataBuffer.ErrorInformation += "Can not find the load case";
                return false;
            }

            //check the name
            caseName = myLoadCase.LoadCasesName;
            while (!isUnique)
            {
                caseName += "(1)";
                isUnique = IsCaseNameUnique(caseName);
            }

            //get the selected case's nature
            Category caseCategory = null;
            LoadNature caseNature = null;
            Autodesk.Revit.DB.ElementId categoryId = myLoadCase.LoadCasesCategoryId;
            Autodesk.Revit.DB.ElementId natureId = myLoadCase.LoadCasesNatureId;

            UIApplication uiapplication = new UIApplication(m_revit);
            caseNature = uiapplication.ActiveUIDocument.Document.get_Element(natureId) as LoadNature;

            //get the selected case's category
            Categories categories = uiapplication.ActiveUIDocument.Document.Settings.Categories;
            Category category = categories.get_Item(BuiltInCategory.OST_LoadCases);
            CategoryNameMap categoryNameMap = category.SubCategories;
            System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator();
            iter.Reset();
            while (iter.MoveNext())
            {
                Category tempC = iter.Current as Category;
                if (null != tempC && (categoryId.IntegerValue == tempC.Id.IntegerValue))
                {
                    caseCategory = tempC;
                    break;
                }
            }

            //check if lack of the information
            if (null == caseNature || null == caseCategory || null == caseName)
            {
                m_dataBuffer.ErrorInformation += "Can't find the load case";
                return false;
            }

            //try to create a load case
            try
            {
                LoadCase newLoadCase = uiapplication.ActiveUIDocument.Document.Create.NewLoadCase(caseName, caseNature, caseCategory);
                if (null == newLoadCase)
                {
                    m_dataBuffer.ErrorInformation += "Create Load Case Failed";
                    return false;
                }
                //add the new case into list and map
                m_dataBuffer.LoadCases.Add(newLoadCase);
                LoadCasesMap newLoadCaseMap = new LoadCasesMap(newLoadCase);
                m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return false;
            }
            return true;
        }