//--------------------------------------------------------------------------------------------------- #region Clash Child Item private void Hight_Lights(object sender, MouseButtonEventArgs e) { my_Image = new ObservableCollection <Image_Solution>(); try { child item = (child)thong_tin_clash_child.SelectedItem; if (item != null) { foreach (ImageSource imageSource in item.bitmap) { my_Image.Add(new Image_Solution() { bitmap = imageSource }); } } hinh_anh_minh_hoa.ItemsSource = my_Image; my_focus.thong_tin_clash_child = thong_tin_clash_child; e_focus.Raise(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- public string Focus(UIApplication uiapp, Document doc) { string result = "F"; try { child item = (child)thong_tin_clash_child.SelectedItem; if (item != null) { SectionBox(uiapp, doc, item); } result = "S"; } catch (Exception ex) { MessageBox.Show(ex.Message); } return(result); }
//---------------------------------------------------------- void SectionBox(UIApplication uiapp, Document doc, child item) { try { ResetView(uiapp, doc); var document1 = item.doc1_child; var document2 = item.doc2_child; ElementId ele1 = new ElementId(Convert.ToInt32(item.id1_child)); ElementId ele2 = new ElementId(Convert.ToInt32(item.id2_child)); BoundingBoxXYZ boundingbox_1 = document1.GetElement(ele1).get_BoundingBox(null); BoundingBoxXYZ boundingbox_2 = document2.GetElement(ele2).get_BoundingBox(null); double a = 10; if (boundingbox_1 != null && boundingbox_2 != null) { var x_1_min = boundingbox_1.Min.X; var y_1_min = boundingbox_1.Min.Y; var z_1_min = boundingbox_1.Min.Z; var x_2_min = boundingbox_2.Min.X; var y_2_min = boundingbox_2.Min.Y; var z_2_min = boundingbox_2.Min.Z; XYZ min = new XYZ(Math.Max(x_1_min, x_2_min) - a, Math.Max(y_1_min, y_2_min) - a, Math.Max(z_1_min, z_2_min) - a); var x_1_max = boundingbox_1.Max.X; var y_1_max = boundingbox_1.Max.Y; var z_1_max = boundingbox_1.Max.Z; var x_2_max = boundingbox_2.Max.X; var y_2_max = boundingbox_2.Max.Y; var z_2_max = boundingbox_2.Max.Z; XYZ max = new XYZ(Math.Min(x_1_max, x_2_max) + a, Math.Min(y_1_max, y_2_max) + a, Math.Min(z_1_max, z_2_max) + a); BoundingBoxXYZ boundingBoxXYZ = new BoundingBoxXYZ(); boundingBoxXYZ.Min = min; boundingBoxXYZ.Max = max; View3D view = doc.ActiveView as View3D; view.SetSectionBox(boundingBoxXYZ); var UIView = uiapp.ActiveUIDocument.GetOpenUIViews(); foreach (var view1 in UIView) { if (view1.ViewId == view.Id) { view1.ZoomAndCenterRectangle(min, max); } } Selection select = uiapp.ActiveUIDocument.Selection; if (doc.Title == document1.Title) { select.SetElementIds(new List <ElementId>() { ele1 }); } else if (doc.Title == document2.Title) { select.SetElementIds(new List <ElementId>() { ele2 }); } } } catch (Exception) { } }