Load list of 3d Views from Revit

Load list of 3d Views from Revit

Anonymous
Not applicable
590 Views
1 Reply
Message 1 of 2

Load list of 3d Views from Revit

Anonymous
Not applicable

How I can load list of 3d views from Revit instead my hand written data 

new CameraViewModel ("View1"){ Width = 100, Height = 100 } and etc.

This is my code with hand written data 

public class CamerasCollectionModel
    {
        public ObservableCollection<CameraViewModel> Cameras
        {
            get
            {
                return cameras;
            }
            private set
            {
                cameras = value;
            }
        }
        public void Load() => Cameras = new ObservableCollection<CameraViewModel>
        {
            new CameraViewModel ("View1"){ Width = 100, Height = 100 },
            new CameraViewModel ("View2"){  Width = 200, Height = 200 },
            new CameraViewModel ("View3"){ Width = 300, Height = 300 }
        };
        private ObservableCollection<CameraViewModel> cameras;
}
0 Likes
591 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

The standard approach to retrieve all Revit database elements is by using a filtered element collector:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9

  

For instance, to get all views, you can use:

 

 

FilteredElementCollector views
  = new FilteredElementCollector( doc )
    .OfClass( typeof( View ) );

 

 

You may just want View3D elements, and you may want to add many other filtering criteria to limit the selection.

 

You can find many similar questions and answers here in similar previous threads.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes