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

Modeless Form & Mutliple Drawings Open

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Ron_M
500 Views, 4 Replies

Modeless Form & Mutliple Drawings Open

Good day all. 

 

Explanation of Issue:  I am using a modeless form as a block library insertion tool.  Everything about it works great except when there is more than one drawing open in the session.  In that case it always when activated switches back to the drawing in which it was originally opened instead of staying on the current drawing.  How do I disconnect the drawing in which the modeless from was opened in and reassociate it with the current active drawing?

 

Ron

4 REPLIES 4
Message 2 of 5
mcicognani
in reply to: Ron_M

Have you specified the CommandFlag.Session attribute on the starting command?

Message 3 of 5
norman.yuan
in reply to: Ron_M

Since Modeless dialog does nto block AutoCAD process until it is dismissed, user can switch current document, as you experienced. Therefore, the the data shown in the modeless dialog is somehow related to given drawing, then you need to do something, such as either close the modeless dialog when the associated document becomes not current; or change the data shown iin the dialog box to the data associated to the new current document.

 

Either way, you need to handle DocumentBecameCurrent and/or DocumentActivated event (usually DocumentBecameCurrent), so that what current document changes, you do somethign accordingly.

 

This link might be of help:

 

http://drive-cad-with-code.blogspot.ca/2014/02/showing-and-closing-modeless-formdialog.html

 

Norman Yuan

Drive CAD With Code

EESignature

Message 4 of 5
Ron_M
in reply to: mcicognani

CommandFlag.Session set.

Message 5 of 5
mcicognani
in reply to: Ron_M

I have a very similar application, mine use a palette and is istantiated on startup. I have no problem with multiple drawings, this is a snippet of the insertion code:

 

private void InsertBlock(String szFileName)
{
    if (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Count == 0) return;    // no documents
    if (!Autodesk.AutoCAD.ApplicationServices.Application.IsQuiescent) return;                             // AutoCAD busy
 
    // get current document
    ACAD.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
    if (doc == nullreturn;    // programmer's paranoia
 
    String szName = Path.GetFileNameWithoutExtension(szFileName);
    String szPath = Path.GetDirectoryName(szFileName);
    String szFullPath = szPath + "\\" + szName + ".dwg";
 
    if (File.Exists(szFullPath))
    {
        // lock document and set focus on graphics window
        ACAD.DocumentLock docLock = doc.LockDocument(ACAD.DocumentLockMode.Write, "-insert""-insert"true);
        csTools.ActivateEditor();
 
// send command and let user finish it interactively         csTools.GenericSendCommand("_-insert " + szFullPath + "\r _s 1 ");         if (doc.LockMode(true) != ACAD.DocumentLockMode.NotLocked) docLock.Dispose(); // unlock document     } }

 

 

 

 

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