Message 1 of 1
How to scale up/down 3d viewport in sheet set view by code

Not applicable
09-26-2018
05:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm trying to scale a viewport by code but it trows an exception that is not active, any idea how can I achieve activate and scale?
I tryed this way:
using (Transaction transaction = new Transaction(doc, "Scale Up")) { transaction.Start(); RevitCommandId id_addin = RevitCommandId.LookupCommandId("ID_VIEWPORT_ACTIVATE"); uiapp.PostCommand(id_addin); int scale = 1.2; doc.ActiveView.Scale = scale; transaction.Commit(); id_addin = RevitCommandId.LookupCommandId("ID_VIEWPORT_ACTIVATE_BASE"); uiapp.PostCommand(id_addin); transaction.Commit(); }
and this way:
using (Transaction transaction = new Transaction(doc, "Scale Up")) { transaction.Start(); ViewSheet vs = doc.ActiveView as ViewSheet; Viewport legendVP = new FilteredElementCollector(doc).OfClass(typeof(Viewport)).Cast<Viewport>().Where(q => q.SheetId == vs.Id).First(); int scale = 1.2; legendVP.GetBoxOutline().Scale(scale); }
Regards!