Unfortunately Editor.CurretViewportId only works on a paperspace viewport. I'm using modelspace with 2 viewports and I want to be able to update a jig in both viewports.
I tried the code below to see if I can at least get the viewport numbers somehow.
The DB.GetViewports() get the viewports if the user has been in paperspace at least one time. However, the Viewport.Number returns a -1 even though all the properties are correct. I'm pretty sure I'll need a positive number to clear the anonymous graphics.
I think I'll have to do a P/Invoke, but I don't know where or to what. Do people normally not worry about getting a jig to display in both viewports?
{code}
internal static void ClearViewports()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Transaction tr = doc.Database.TransactionManager.StartTransaction();
using (doc.Database)
{
ObjectIdCollection msvpids = doc.Database.GetViewports(true);
ObjectIdCollection psvpids = doc.Database.GetViewports(false);
using (tr)
{
foreach (ObjectId msvp in msvpids)
{
Viewport vp = (Viewport)tr.GetObject(msvp, OpenMode.ForRead);
acgsRemoveAnonymousGraphics(vp.Number);
vp.Dispose();
}
foreach (ObjectId msvp in psvpids)
{
Viewport vp = (Viewport)tr.GetObject(msvp, OpenMode.ForRead);
ACAD_Interface.acgsRemoveAnonymousGraphics(vp.Number);
vp.Dispose();
}
}
}
}
{code}
Actually I just took a look at several jigs...and they never bother to update all the viewports in modelspace...so I won't worry about it.
I looked at BOX, 3dpoly, line, and the jig is only updated in the current viewport...thanks.
Edited by: dwolfe01 on Mar 24, 2009 8:30 AM