/// <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); } } }
/// <summary> /// add a new load nature /// </summary> /// <param name="index">the selected nature's index in the nature map</param> /// <returns></returns> public bool AddLoadNature(int index) { string natureName = null; //the load nature's name to be added bool isUnique = false; // check if the name is unique LoadNaturesMap myLoadNature = null; //try to get out the loadnature from the map try { myLoadNature = m_dataBuffer.LoadNaturesMap[index]; } catch (Exception e) { m_dataBuffer.ErrorInformation += e.ToString(); return(false); } //Can not get the load nature if (null == myLoadNature) { m_dataBuffer.ErrorInformation += "Can't find the nature"; return(false); } //check if the name is unique natureName = myLoadNature.LoadNaturesName; while (!isUnique) { natureName += "(1)"; isUnique = IsNatureNameUnique(natureName); } //try to create a load nature try { UIApplication uiapplication = new UIApplication(m_revit); LoadNature newLoadNature = uiapplication.ActiveUIDocument.Document.Create.NewLoadNature(natureName); if (null == newLoadNature) { m_dataBuffer.ErrorInformation += "Create Failed"; return(false); } //add the load nature into the list and maps m_dataBuffer.LoadNatures.Add(newLoadNature); LoadNaturesMap newMap = new LoadNaturesMap(newLoadNature); m_dataBuffer.LoadNaturesMap.Add(newMap); } catch (Exception e) { m_dataBuffer.ErrorInformation += e.ToString(); return(false); } return(true); }
/// <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); } } }
/// <summary> /// add a new load nature /// </summary> /// <param name="index">the selected nature's index in the nature map</param> /// <returns></returns> public bool AddLoadNature(int index) { string natureName = null; //the load nature's name to be added bool isUnique = false; // check if the name is unique LoadNaturesMap myLoadNature = null; //try to get out the loadnature from the map try { myLoadNature = m_dataBuffer.LoadNaturesMap[index]; } catch (Exception e) { m_dataBuffer.ErrorInformation += e.ToString(); return false; } //Can not get the load nature if (null == myLoadNature) { m_dataBuffer.ErrorInformation += "Can't find the nature"; return false; } //check if the name is unique natureName = myLoadNature.LoadNaturesName; while (!isUnique) { natureName += "(1)"; isUnique = IsNatureNameUnique(natureName); } //try to create a load nature try { UIApplication uiapplication = new UIApplication(m_revit); LoadNature newLoadNature = uiapplication.ActiveUIDocument.Document.Create.NewLoadNature(natureName); if (null == newLoadNature) { m_dataBuffer.ErrorInformation += "Create Failed"; return false; } //add the load nature into the list and maps m_dataBuffer.LoadNatures.Add(newLoadNature); LoadNaturesMap newMap = new LoadNaturesMap(newLoadNature); m_dataBuffer.LoadNaturesMap.Add(newMap); } catch (Exception e) { m_dataBuffer.ErrorInformation += e.ToString(); return false; } return true; }
/// <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); } } }