Hi
Anyone know if its possible to access the "type" properties of a viewport via the API. After creating a new viewport object i'd like to be able to change the type as highlighted in the image below. This snapshot was taken after selecting a viewport. I'm using 2013.
Thanks.
Solved! Go to Solution.
Solved by grahamcook. Go to Solution.
I figured this one out in the end. Viewport is system family that has types, the types represented the items in the menu in the original post above. So i grabbed the first viewport object on the model, looped through the types until the type name matched the name i was looking for. This gave me the id of the type i needed so i could then set the type of the viewport using the viewport.ChangeTypeId method. Code below assumes vp is the new View Port.
Viewport firstViewPort = new FilteredElementCollector(doc) .OfClass(typeof(Viewport)).Cast<Viewport>().FirstOrDefault<Viewport>(); ICollection<ElementId> vpt = firstViewPort.GetValidTypes(); foreach (ElementId e in vpt) { ElementType type = doc.GetElement(e) as ElementType; // Edit line to suit or pass in variable if (type.Name == "Title w Line") { vp.ChangeTypeId(type.Id); } }