Author Topic: Closing the DST error  (Read 2000 times)

0 Members and 1 Guest are viewing this topic.

pBe

  • Bull Frog
  • Posts: 402
Closing the DST error
« on: September 12, 2016, 05:02:39 AM »
Good Day all,

I modified a code found at http://through-the-interface.typepad.com/through_the_interface/2010/05/populating-a-tree-view-inside-autocad-with-sheet-set-data-using-net-part-2.html

I'm having trouble with the order of things, although the code did what it was supposed to do. [Write to sheet view] it always gives me the error

Quote
Application does not support just-in-time (JIT)
debugging. See the end of this message for details.

************** Exception Text **************
Autodesk.AutoCAD.Runtime.Exception: eNullPtr
   at Autodesk.AutoCAD.ApplicationServices.Document.get_CommandInProgress()
   at Autodesk.AutoCAD.StatusBar.StatusBarContainer.IsAnyCommandInProcess()
   at Autodesk.AutoCAD.StatusBar.StatusBarContainer.AcadApplication_Idle(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Autodesk.AutoCAD.ApplicationServices.Core.Application.raise_Idle(Object value0, EventArgs value1)
   at Autodesk.AutoCAD.ApplicationServices.Core.Application.OnIdle()

Appears that "a" file is still opened, not sure if its the TEXT file or the DST file that is still "CommandInProgress".

by TEXT file i mean a .txt file where the information is stored. I had it up and running before , but the difference is before it was one item one call to SheetViewWrite, now i incorporated a while to read an external file the call SheetViewWrite once.

I did the same thing with XREFATTACH succesfully, but im not getting any error there. guess its the DST then? Been at it for 2 days now, with no luck.

Here's the modified code

Code - C#: [Select]
  1. using Autodesk.AutoCAD.ApplicationServices;
  2. using Autodesk.AutoCAD.EditorInput;
  3. using Autodesk.AutoCAD.Runtime;
  4. using ACSMCOMPONENTS21Lib;
  5. using System;
  6.  
  7.  
  8. namespace MyApplication
  9. {
  10.     public class Commands
  11.     {
  12.  
  13.  
  14.         [CommandMethod("SheetViewWrite")]
  15.         public void PopulateSheetView()
  16.         {
  17.             Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
  18.  
  19.  
  20.             string ssFilePath = userInput("\nEnter Sheet Set Name: ");
  21.             Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
  22.  
  23.  
  24.             // Get the SheetSet Manager
  25.             AcSmSheetSetMgr mgr = new AcSmSheetSetMgr();
  26.  
  27.  
  28.             // Create a new SheetSet Database
  29.             AcSmDatabase db = new AcSmDatabase();
  30.  
  31.  
  32.             // Try and load a default DST file...
  33.             try
  34.             {
  35.                 db = mgr.OpenDatabase(ssFilePath, true);
  36.             }
  37.             catch (System.Exception ex)
  38.             {
  39.                 ed.WriteMessage(ex.ToString());
  40.                 return;
  41.             }
  42.  
  43.  
  44.             // Lock the db for processing
  45.             db.LockDb(db);
  46.  
  47.  
  48.             AcSmSheetSet ss = db.GetSheetSet();
  49.             PromptStringOptions SSVsource = new PromptStringOptions("Enter Source: ");
  50.             SSVsource.AllowSpaces = true;
  51.             PromptResult fileRes = acDoc.Editor.GetString(SSVsource);
  52.  
  53.  
  54.             string svfilePath = (fileRes.StringResult);
  55.             using (System.IO.StreamReader reader = new System.IO.StreamReader(svfilePath))
  56.  
  57.  
  58.             {
  59.                 while (!reader.EndOfStream)
  60.                 {
  61.                     string textLine2 = reader.ReadLine();
  62.                     string componentName    = textLine2.Split(',')[2];
  63.                     string componentValue    = textLine2.Split(',')[3];
  64.  
  65.  
  66.                     try
  67.                     {
  68.                         ProcessItems(db, false, componentValue, componentName);
  69.                     }
  70.                     catch { }
  71.  
  72.  
  73.                     // Use the sheet enumerator to process the contents
  74.  
  75.  
  76.                     try
  77.                     {
  78.                         ProcessEnumerator(ss.GetSheetEnumerator(), true, componentValue, componentName);
  79.                     }
  80.                     catch { }
  81.                 }
  82.             }
  83.  
  84.  
  85.             db.UnlockDb(db, true);
  86.             mgr.Close(db);
  87.  
  88.  
  89.             acDoc.Dispose();
  90.         }


Thank you

pBe

  • Bull Frog
  • Posts: 402
Re: Closing the DST error
« Reply #1 on: September 12, 2016, 08:00:01 AM »
it's odd, All i did is commented out one line, it works and the error went away

Code: [Select]
acDoc.Dispose();
But i know i'm supposed to implement a dispose right?  Otherwise it will  consume large amounts of memory?

FWIW ,what is the correct way to dispose? or should i even dispose acDoc?

Thank you in advance

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Closing the DST error
« Reply #2 on: September 12, 2016, 08:39:31 AM »
Hi,

You should never dispose a document, AutoCAD takes care of that.

With AutoCAD API, you must dispose transactions, locked documents, and every dbobject which is not handled by a transaction e.g.: opened with theObjectId.Open() method or any new dbobject (created with new or a method generating a DBObjectCollection as Explode()) which is not added to a transaction (when added to a transaction, this transaction will take care to dispose the object when disposing itself).
Speaking English as a French Frog

pBe

  • Bull Frog
  • Posts: 402
Re: Closing the DST error
« Reply #3 on: September 12, 2016, 08:48:37 AM »
Hi,

You should never dispose a document, AutoCAD takes care of that.

With AutoCAD API, you must dispose.....

Thank you for the info Gile, appreciate the time.