/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { bool runCommand = false; int category = 3; DA.GetData(0, ref runCommand); DA.GetData(1, ref category); try { ElementIdCategory eicTemp = (ElementIdCategory)category; if (eic != eicTemp) { eic = (ElementIdCategory)category; } } catch { } if (runCommand) { try { elements = new List <string>(); elements.Clear(); // Open the Channel to Revit LyrebirdChannel channel = new LyrebirdChannel(appVersion); channel.Create(); if (channel != null) { string documentName = channel.DocumentName(); if (documentName != null) { elements = channel.GetCategoryElements(eic); } channel.Dispose(); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error\n" + ex.Message); } } DA.SetDataList(0, elements); }
public List <string> GetCategoryElements(ElementIdCategory eic) { if (IsValid()) { try { List <string> materials = _channel.GetCategoryElements(eic); return(materials); } catch { List <string> errors = new List <string> { "error" }; return(errors); } } return(null); }
List<string> ILyrebirdService.GetCategoryElements(ElementIdCategory eic) { elementIdCollection = new List<string>(); elementIdCollection.Add("NULL"); lock (_locker) { try { UIApplication uiApp = RevitServerApp.UIApp; var doc = uiApp.ActiveUIDocument.Document; elementIdCollection = new List<string>(); if (eic == ElementIdCategory.DesignOption) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_DesignOptions); foreach (Element elem in collector) { try { DesignOption desOpt = elem as DesignOption; elementIdCollection.Add(desOpt.Name + "," + desOpt.Id.IntegerValue.ToString()); } catch { } } elementIdCollection.Sort(); } else if (eic == ElementIdCategory.Image) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_RasterImages); foreach (Element elem in collector) { try { ImageType imgType = elem as ImageType; elementIdCollection.Add(imgType.Name + "," + imgType.Id.IntegerValue.ToString()); } catch { } } elementIdCollection.Sort(); } else if (eic == ElementIdCategory.Level) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_Levels); List<Level> levels = new List<Level>(); foreach (Element elem in collector) { try { Level lvl = elem as Level; double elev = lvl.Elevation; levels.Add(lvl); } catch { } } // Sort the levels by elevation levels.Sort((lvl1, lvl2) => lvl1.Elevation.CompareTo(lvl2.Elevation)); foreach (Level lvl in levels) { try { elementIdCollection.Add(lvl.Name + " [" + lvl.Elevation.ToString() + "]," + lvl.Id.IntegerValue.ToString()); } catch { } } } else if (eic == ElementIdCategory.Material) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_Materials); foreach (Element elem in collector) { try { Material mat = elem as Material; elementIdCollection.Add(mat.Name + "," + mat.Id.IntegerValue.ToString()); } catch { } } elementIdCollection.Sort(); } else if (eic == ElementIdCategory.Phase) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_Phases); foreach (Element elem in collector) { try { Phase phase = elem as Phase; elementIdCollection.Add(phase.Name + "," + phase.Id.IntegerValue.ToString()); } catch { } } elementIdCollection.Sort(); } } catch { } } return elementIdCollection; }
public List<string> GetCategoryElements(ElementIdCategory eic) { if (IsValid()) { try { List<string> materials = _channel.GetCategoryElements(eic); return materials; } catch { List<string> errors = new List<string> { "error" }; return errors; } } return null; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { bool runCommand = false; int category = 3; DA.GetData(0, ref runCommand); DA.GetData(1, ref category); try { ElementIdCategory eicTemp = (ElementIdCategory)category; if (eic != eicTemp) { eic = (ElementIdCategory)category; } } catch { } if (runCommand) { try { elements = new List<string>(); elements.Clear(); // Open the Channel to Revit LyrebirdChannel channel = new LyrebirdChannel(appVersion); channel.Create(); if (channel != null) { string documentName = channel.DocumentName(); if (documentName != null) { elements = channel.GetCategoryElements(eic); } channel.Dispose(); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error\n" + ex.Message); } } DA.SetDataList(0, elements); }