public void Load_Form(UIApplication uiapp, Document doc) { try { data_revit_link item = (data_revit_link)link_file.SelectedItem; doc.Delete(item.type.Id); ModelPath mp = ModelPathUtils.ConvertUserVisiblePathToModelPath(path); RevitLinkOptions rlo = new RevitLinkOptions(false); var linkType = RevitLinkType.Create(doc, mp, rlo); var instance = RevitLinkInstance.Create(doc, linkType.ElementId); List <Document> docs = new List <Document>(); foreach (Document d in uiapp.Application.Documents) { docs.Add(d); } item.document = docs.First(y => y.Title + ".rvt" == item.name); item.type = doc.GetElement(linkType.ElementId) as RevitLinkType; link_file.Items.Refresh(); MessageBox.Show(item.document.PathName); } catch (Exception ex) { MessageBox.Show(ex.Message); link_file.SelectedItem = null; } }
//------------------------------------------------------- private void roll_back_Click(object sender, RoutedEventArgs e) { if (link_file.SelectedItem != null) { F_ListBox.Roll_Back_Save_Data_Check(my_element_change, link_file, uiapp, doc_link, doc, my_parameter_settings); data_revit_link item = (data_revit_link)link_file.SelectedItem; doc_link = item.document; my_element_change = new ObservableCollection <Element_Change>(); F_All.Check_Element(doc, doc_link, my_parameter_settings, my_element_change); Add_Element_Change(); } }
private void Check_Click(object sender, RoutedEventArgs e) { try { if (link_file.SelectedItem != null) { data_revit_link item = (data_revit_link)link_file.SelectedItem; doc_link = item.document; my_element_change = new ObservableCollection <Element_Change>(); F_All.Check_Element(doc, doc_link, my_parameter_settings, my_element_change); Add_Element_Change(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//------------------------------------------------------- private void Select_Link_File(object sender, EventArgs e) { try { if (link_file.SelectedItem != null) { data_revit_link item = (data_revit_link)link_file.SelectedItem; if (item.document == null) { System.Windows.Forms.OpenFileDialog file = new System.Windows.Forms.OpenFileDialog(); file.FileName = MessageBox_Data.discription_loadform; file.Filter = MessageBox_Data.filter_revit; if (file.ShowDialog() == System.Windows.Forms.DialogResult.OK) { my_load_form.path = file.FileName; my_load_form.link_file = link_file; e_load_form.Raise(); } else { link_file.SelectedItem = null; } } else { string path_file = item.document.PathName; string path_direction = Path.GetDirectoryName(path_file); string name_direction = new DirectoryInfo(path_direction).Name; if (item.name != name_direction + ".rvt") { MessageBox.Show(MessageBox_Data.file_not_check, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); link_file.SelectedItem = null; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }