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

open drawing stops execution of .net code

2 REPLIES 2
Reply
Message 1 of 3
wbdehaan
364 Views, 2 Replies

open drawing stops execution of .net code

Hi,

 

when I run .Net code which opens and activates a drawing, the execution of the .net code stops because another drawing is activated, and therefore the msgbox("..") is not being showed, untill the drawing is activated  (in which the .net code originally was executed). How is it possible to show the msgbox or other code and stay in the just opened drawing (without manually reactivating the original drawing)?

 

(the msgbox is just an example of some code, the solution is not to put the msgbox before opening the drawing)

 

kind regards,

 

Wouter

 

    <CommandMethod("OpenDrawing")> Public Sub OpenDrawing()
        Dim strFileName As String = "d:\test.dwg"
        Dim acDocMgr As DocumentCollection = Application.DocumentManager
        Dim ExistingFile As Document = acDocMgr.Open(strFileName, False)
        acDocMgr.MdiActiveDocument = ExistingFile


        MsgBox("this msgbox is not displayed untill the original file is re-activated")

    End Sub

 

2 REPLIES 2
Message 2 of 3
mcicognani
in reply to: wbdehaan

You should execute your code in session mode, try add the  CommandFlags.Session to your CommandMethod declaration.

This means that your code runs at application level and not document level. This will require to lock the document you want to operate on, but this way you may operate on multiple drawing without loosing the execution focus.

Message 3 of 3
wbdehaan
in reply to: mcicognani

Thank You!

I added <CommandMethod("OpenDrawing", commandflags.session)> Public Sub OpenDrawing(), and it works, thanks!

kind regards Wouter

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