TheSwamp

Code Red => .NET => Topic started by: Keith™ on March 20, 2020, 11:57:53 PM

Title: C# regen single object, not the whole drawing .. possible??
Post by: Keith™ on March 20, 2020, 11:57:53 PM
I vaguely remember that in Lisp or maybe VBA you could regen/refresh or update a single object in the drawing window, but I have not found a similar method in C#. Of course, maybe I am just missing it or my brain is not working right anymore.

The issue is that with the latest programming project, the drawings tend to be very big and take quite a long time to regen completely. I'd like to simply update the objects I am modifying programmatically instead of calling acDoc.Editor.Regen() every few changes just to keep the window relevant and accurate.

Ideas?
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: nobody on March 21, 2020, 01:44:44 AM
Maybe .recordgraphicmodified()?
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: huiz on March 22, 2020, 06:09:44 AM
If you only need to update the screen to show some visual progress, you don't need REGEN but REDRAW:


Application.DocumentManager.MdiActiveDocument.Editor.UpdateScreen()
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: gile on March 22, 2020, 08:18:50 AM
Hi,

Did you try the Entity.Draw() method?
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: Keith™ on March 23, 2020, 02:11:23 PM
Ok,

Draw() doesn't update the object on the screen until something else causes the screen to be invalidated like a mouse move or pan, but it's not the worst case scenario;
UpdateScreen() updates the screen as needed and it seems to be faster than a full regen, although I'll have to test to see what kind of performance boost I can expect on my test machine.
RecordGraphicsModified(t/f) is a new one that I had not used previously, although it appears to have the same drawbacks as Draw() in that it doesn't actually update the screen.

I'll have to examine each one of these in a test case and see what kind of performance improvement I can get. I'm thinking that RecordGraphicsModified is a perhaps building a queue for Draw() in which case I can do that manually, but UpdateScreen() doesn't differentiate between updated and non-updated objects.

I am modifying hundreds of blocks, each with the potential for between 24 and 128 attributes, and that isn't counting the other stuff in the drawing.

Anyway, those are great suggestions and are certainly leaps and bounds better than doc.Editor.Regen()!! Thanks!
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: twdotson on March 24, 2020, 09:04:06 AM
Going from memory, I believe this regenerated a single entity.

Entity.Visible = False
Entity.Visible = True
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: Keith™ on March 24, 2020, 10:14:59 AM
Going from memory, I believe this regenerated a single entity.

Entity.Visible = False
Entity.Visible = True

I may give that a shot and see if it works, and if it does, if it improves the performance.
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: It's Alive! on March 25, 2020, 08:39:01 AM

How about using a document transaction and FlushGraphics();? maybe RecordGraphicsModified(true) would be needed too
Title: Re: C# regen single object, not the whole drawing .. possible??
Post by: Keith™ on March 25, 2020, 04:59:12 PM

How about using a document transaction and FlushGraphics();? maybe RecordGraphicsModified(true) would be needed too

Perhaps, overhead may be a little much on FlushGraphics()

I know that once upon a time this was done in ADS but I don't want to go about mixing a bunch of code and introducing problems.