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

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

Anonymous
Not applicable
351 Views
0 Replies
Message 1 of 1

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

Anonymous
Not applicable

 

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!

 

0 Likes
352 Views
0 Replies
Replies (0)