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

Programmatically erase lines drawn with Editor.DrawVector

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
536 Views, 12 Replies

Programmatically erase lines drawn with Editor.DrawVector

Lines drawn with Editor.DrawVector easily get erased when the user zooms in, etc. However, is there a programmatic command I can call to erase all vectors without disrupting much else? Thanks.
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

Have you tried Editor.UpdateScreen() ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5822127@discussion.autodesk.com...
Lines drawn with Editor.DrawVector easily get erased when the user zooms in, etc. However, is there a programmatic command I can call to erase all vectors without disrupting much else? Thanks.
Message 3 of 13
Anonymous
in reply to: Anonymous

Yes, I tried and it doesn't work. Any other ideas?

Thanks.
Message 4 of 13
Anonymous
in reply to: Anonymous

OK, I figured it out: Editor.Regen()
Message 5 of 13
Anonymous
in reply to: Anonymous

public static class Class1
{
[DllImport( "acad.exe", CallingConvention.Cdecl,
EntryPoint = "?acgsRemoveAnonymousGraphics@@YAHH@Z" )]
extern public static int acgsRemoveAnonymousGraphics( int vportNum );

public static void GRClear()
{
acgsRemoveAnonymousGraphics(
Convert.ToInt32( Application.GetSystemVariable( "CVPORT" ) ) );
}
}

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5822241@discussion.autodesk.com...
Yes, I tried and it doesn't work. Any other ideas?

Thanks.
Message 6 of 13
Anonymous
in reply to: Anonymous

Regen() will do way more than just
remove temporary grahics.

What I posted should be much faster.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5822253@discussion.autodesk.com...
OK, I figured it out: Editor.Regen()
Message 7 of 13
Anonymous
in reply to: Anonymous

Thanks. I want to try your method, but I get the compile error:
No overload for method 'DllImportAttribute' takes '2' arguments
Message 8 of 13
Anonymous
in reply to: Anonymous

Oh, OK. Just missing CallingConvention =. NP.
Thanks.
Message 9 of 13
Anonymous
in reply to: Anonymous

Thanks a lot. I am using what you posted, as it's much faster indeed.
Message 10 of 13
mario.rosenbohm
in reply to: Anonymous

The fastest Method that i use is follow:

1. use the "Editor.ZoomWindow(LeftLower,RightUpper)" and remember the 2 Point3d LeftLower and RightUpper
2. Draw the vectors "Editor.DrawVector"

3. Erase the temp vectors width "Editor.ZoomWindow(LeftLower,RightUpper)"

This is very faster as Regen() because if not change the Windowcoordinates for ZoomWindow, Entitys are not rebuilt, as Regen().

greeds Mario
Message 11 of 13
Anonymous
in reply to: Anonymous

Digging up an old topic...I found this very useful Tony. Very nice...thanks.

However, let's say I want to loop through all the viewport in modelspace, and clear them using GRClear(int viewportnum)
Obviously, I can pass the viewport number, but how do I retrieve it from modelspace viewports.

I know that they are stored as "*Active" ViewportTableRecords in the ViewportTable, but I can't discover the number property associated?

However, the Application.GetSystemVariable("CVPORT") returns a viewport number, so I know it's possible.

Any ideas?
Message 12 of 13
Anonymous
in reply to: Anonymous

The Editor's ActiveViewportId property might help.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6146789@discussion.autodesk.com...
Digging up an old topic...I found this very useful Tony. Very nice...thanks.
However, let's say I want to loop through all the viewport in modelspace,
and clear them using GRClear(int viewportnum) Obviously, I can pass the
viewport number, but how do I retrieve it from modelspace viewports. I know
that they are stored as "*Active" ViewportTableRecords in the ViewportTable,
but I can't discover the number property associated? However, the
Application.GetSystemVariable("CVPORT") returns a viewport number, so I know
it's possible. Any ideas?
Message 13 of 13
Anonymous
in reply to: Anonymous

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

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