Пример #1
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);
        }
Пример #2
0
 /// <summary>
 /// Overload the constructor
 /// </summary>
 /// <param name="loadCase">Load Case</param>
 public LoadCasesMap(LoadCase loadCase)
 {
     m_loadCase          = loadCase;
     m_loadCasesName     = m_loadCase.Name;
     m_loadCasesNumber   = m_loadCase.Number.ToString();
     m_loadCasesNatureId = m_loadCase.NatureId;
     m_loadCasesCategory = m_loadCase.NatureCategory;
 }