Exemplo n.º 1
0
        // Zoom to the CAD
        private void GoCAD_Click(object sender, RoutedEventArgs e)
        {
            CADItem SelectedCad = CADListView.SelectedItem as CADItem;

            uidoc.ActiveView = SelectedCad.OwnerView;
            uidoc.ShowElements(SelectedCad.CADImportInstance.Id);
        }
Exemplo n.º 2
0
        // Open the view
        private void GoView_Click(object sender, RoutedEventArgs e)
        {
            CADItem SelectedCad = CADListView.SelectedItem as CADItem;

            View selectedCadView = SelectedCad.OwnerView;

            uidoc.ActiveView = selectedCadView;
        }
Exemplo n.º 3
0
        public FindCADsWindow(UIDocument uid)
        {
            InitializeComponent();
            CADListView.ItemsSource = CADList;
            uidoc = uid;
            doc   = uidoc.Document;

            // Get all imports in the model
            FilteredElementCollector collector = new FilteredElementCollector(doc);

            collector.OfClass(typeof(ImportInstance))
            .WhereElementIsNotElementType()
            .Cast <ImportInstance>();

            foreach (ImportInstance IInstance in collector)
            {
                // This section gets view specific imports
                if (IInstance.OwnerViewId != null && IInstance.OwnerViewId.IntegerValue != -1)
                {
                    View ownerView = doc.GetElement(IInstance.OwnerViewId) as View;

                    ViewFamilyType ViewTy = doc.GetElement(ownerView.GetTypeId()) as ViewFamilyType;

                    string ViewN = ViewTy.Name + " - " + ownerView.Name;

                    CADItem addition = new CADItem
                    {
                        ViewName          = ViewN,
                        CADImportInstance = IInstance,
                        OwnerView         = ownerView,
                        IsHide            = IInstance.IsHidden(ownerView).ToString()
                    };
                    CADList.Add(addition);
                }

                // This section gets model-wide imports. These CADs can be viewed in every view
                else
                {
                    CADItem addition = new CADItem
                    {
                        ViewName          = null,
                        CADImportInstance = IInstance,
                        OwnerView         = null,
                        IsHide            = null
                    };
                    CADList.Add(addition);
                }
            }
        }