Update Screen

Update Screen

SRSDS
Advisor Advisor
4,435 Views
8 Replies
Message 1 of 9

Update Screen

SRSDS
Advisor
Advisor

Some changes made in a palette do not get reflected on screen until the mouse moves to the drawing area.

When the mouse moves over the drawing area the updates are instantly reflected.

 

Application.UpdateScreen() doesn't work.

SendStringToExecute"REGEN " does, but with complicated drawings with xrefs it can take a long time to update.

 

The commands I need to execute are very often so I don't want the user to be sitting back for 10 seconds every time they execute a command.

Is there a solution or workaround for this?

0 Likes
Accepted solutions (1)
4,436 Views
8 Replies
Replies (8)
Message 2 of 9

Virupaksha_aithal
Autodesk Support
Autodesk Support

Hi,

 

does blog https://adndevblog.typepad.com/autocad/2013/03/use-of-windowfocus-in-autocad-2014.html helps?

 

 



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 9

SRSDS
Advisor
Advisor

Hi,

That's the exact problem and solution but I need some help converting it to vb.net

Below is the converted code using an online converter.

And below that my attempt at adjusting it.

"Dynamic" is an unknown syntax.

Desperately hoping you or someone else can help me on this.

 

Capture.JPG

0 Likes
Message 4 of 9

_gile
Consultant
Consultant

Hi,

 

Try replacing dynamic with Object.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 9

SRSDS
Advisor
Advisor

Sorry about this. Commenting out the converted portion left me with this

 

Capture.JPG

0 Likes
Message 6 of 9

_gile
Consultant
Consultant

If I remember well, there's an issue with the GetAcadDocument() extension method and VB.

You should try like this:

Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim docObj As Object = DocumentExtension.GetAcadDocument(doc)
docObj.Window.Focus()

But it seems to me this can be done without using the COM object AcadDocument, you can access the Window directly from the .NET Document instance by simply doing:

Dim doc As Document = Application.DocumentManager.MdiActiveDocument
doc.Window.Focus()


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 7 of 9

Alexander.Rivilis
Mentor
Mentor
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView()

This static method can been helpful.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 8 of 9

_gile
Consultant
Consultant
Accepted solution

Another way, recommended by Kean Walmsley* that I extensively use with Palettes is to wrap the method related to AutoCAD in a CommandMethod and just call them from the palette with SendStringToExecute. This way you let AutoCAD do all the locking / focus stuff.

 

* "Once again there’s our important rule of thumb when it comes to implementing a modeless UI: rather than manually locking the current document, it’s safer to define a command – which will implicitly lock the current document – and call that from the UI via SendStringToExecute()."



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 9 of 9

SRSDS
Advisor
Advisor

 

 

I'm going to drop this here which I found on another thread..

Seems to solve the problem when Utils.SetFocusToDwgView doesn't want to work and you don't want to SendStringToExecute.

 

Private Declare Function SetFocus Lib "user32" (ByVal hwnd As System.IntPtr) As System.IntPtr
SetFocus(Application.DocumentManager.MdiActiveDocument.Window.Handle)

 

 

0 Likes