public SetRevitDataForm(LyrebirdChannel c, GHClient p) { parent = p; channel = c; InitializeComponent(); // Position the form. Left = 0; Top = 0; //MessageBox.Show(string.Format("The system is {0} and the endpoint is:\n{1}", client.State.ToString(), client.Endpoint.Address.ToString())); if (channel != null) { try { string test = channel.DocumentName(); if (test == null) { MessageBox.Show("Error!!!!!!!!!!"); } RevitObject[] temp = channel.FamilyNames().ToArray(); if (temp != null && temp.Any()) { familyNames = channel.FamilyNames().ToList(); } else { MessageBox.Show("The Lyrebird Service for Revit could not be found. Make sure the service is turned on and try again."); this.Close(); } } catch (Exception ex) { MessageBox.Show("Error\n" + ex.ToString()); } if (familyNames != null && familyNames.Count > 0) { familyComboBox.ItemsSource = familyNames; familyComboBox.DisplayMemberPath = "FamilyName"; bool check = false; if (parent.FamilyName != null) { for (int i = 0; i < familyNames.Count; i++) { string famName = familyNames[i].FamilyName; if (famName == parent.FamilyName) { familyComboBox.SelectedIndex = i; check = true; } } } if (!check) { familyComboBox.SelectedIndex = 0; } } } }
static void Main(string[] args) { // Create the client connection LyrebirdChannel channel = new LyrebirdChannel(1); channel.Create(); string message = channel.DocumentName(); channel.Dispose(); Console.WriteLine("Finished: " + message); }
/// <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); }