.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Zoom extents object in viewport

1 REPLY 1
Reply
Message 1 of 2
Vinx.Eng
419 Views, 1 Reply

Zoom extents object in viewport

Because my English not good. I'm so sorry if I don't write grammatically correct.

I want to write a function to zoom in viewport objects on CAD2015.

But the code that I used to write on CAD2010 not true in this case.

Who can help me with a corrected version CAD2015. Thanks for the help.

 

public static void ZoomToObject(Entity ent, Viewport _vp)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
using (Transaction trx = doc.Database.TransactionManager.StartTransaction())
{
using (Autodesk.AutoCAD.GraphicsSystem.Manager gm = doc.GraphicsManager)
using (Autodesk.AutoCAD.GraphicsSystem.View vw = gm.GetGsView(_vp.Number, true))
{
if(_vp.Locked) _vp.Locked = false;
Extents3d ext = ent.GeometricExtents;
vw.ZoomExtents(ext.MinPoint, ext.MaxPoint);
gm.SetViewportFromView(_vp.Number, vw, true, true, false);
_vp.Locked = true;
}

trx.Commit();
}
}

1 REPLY 1
Message 2 of 2
Vinx.Eng
in reply to: Vinx.Eng

No one cares about it so.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost