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

AutoCAD 2014 hangs because of opening Document but in VS Debugger all works fine

5 REPLIES 5
Reply
Message 1 of 6
vladimior
1101 Views, 5 Replies

AutoCAD 2014 hangs because of opening Document but in VS Debugger all works fine

Hello, All.

 

I am in process of creating library for AutoCAD. The library supports AutoCAD 2012, AutoCAD 2013, AutoCAD 2014. As you know binary compatibility is broken between AutoCAD 2012 and AutoCAD 2013+. So I have two sets of libraries for 2012 and 2013 AutoCADs.

 

The code almost the same for all AutoCADs. Under AutoCAD 2012 library works fine. But if I will execute some operations in library under AutoCAD 2014 (I'm testing on Windows 8 64bit, AutoCAD 2014) AutoCAD hangs and I see picture on attached screenshot. To unfreeze AutoCAD I must go to Task Manager.

 

Right before freeze I do

1. Document.CloseAndDiscard();

2. Application.DocumentManager.Open("[filepath of just closed document]");

 

Version of AutoCAD libraries is 19.0 (got from ObjectArx 2013).

 

Interesting particularity. All works fine if code is executed under Visual Studio Debugger.

 

Do you have ideas where is trouble can be?

 

Thank you for any ideas.

 

Regards, Vladimir

5 REPLIES 5
Message 2 of 6
vladimior
in reply to: vladimior

I have some more details.

 

The two string I have written in above are executed in Application Context. In this case AutoCAD hangs. If I execute CloseAndDiscard() AutoCAD doesn't hangs. But there ar troubles with context. Application context doesn't know that in session was closed some drawing. And it is a Problem.

Message 3 of 6
Balaji_Ram
in reply to: vladimior

Hi Vladimior,

 

Sorry for the long delay.

 

Is this still an issue for you ?

 

I do not reproduce this problem in AutoCAD 2014 with release build. Here is the code that I am trying :

 

[CommandMethod("Test", CommandFlags.Session)]
public static void TestMethod()
{
    foreach (Document doc in Application.DocumentManager)
    {
        String docName = doc.Name;
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(docName);

        if (docName.Contains("Test.dwg"))
        {
            doc.CloseAndDiscard();

            Application.DocumentManager.Open(docName);

            break;
        }
    }
}

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 4 of 6
keep_smile
in reply to: Balaji_Ram

i have same problem but not got anything from above solution
Message 5 of 6
hemarajuc
in reply to: keep_smile

Hi,

I am facing this same issue when I have installed Autocad 2014 on Windows 7 64 bit machine but the same works on Windows 8 machine.

As suggested in some posts, I have applied SP1 patch for the Autocad 2014 and installed .net framework 4.5 in that Windows 7 machine but it didn't help.

But the same add-in works fine in Windows 8 machine with out any issue.

Is there any update regarding how to fix this issue?

Suggestions are most welcome.

Regards,

Hemaraju

Message 6 of 6
hemarajuc
in reply to: hemarajuc

Hi All, 

Just an update about the above mentioned issue.

I am able to fix that issue by running the code under CommandFlags.Session i.e under application context.

I have given below sample code how I have changed it to work.

 

public override void Execute(object parameter)
{
var aDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
aDoc.SendStringToExecute(@"TC \n", true, false, false);
}

[Autodesk.AutoCAD.Runtime.CommandMethod("TC", Autodesk.AutoCAD.Runtime.CommandFlags.Session)]
public void TestCommand()
{

//Your code goes here

//Mark the method as command method and set CommandFlags.Session

//Call this command from whereever you want by using SendStringToExecute method of Document object.

}

 

Hope this helps the people who are still facing this issue.

Regards,

Hemaraju

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