Author Topic: .net table.explode file save error  (Read 1751 times)

0 Members and 1 Guest are viewing this topic.

xsakabsx

  • Guest
.net table.explode file save error
« on: June 11, 2013, 08:01:10 AM »
after exploding table,
File can not be saved, show the error.
after audit command.  File can be saved.
but audit command  show 0 erorrs;

sorry for my bad  Eng (google.transalate)  :ugly:


Code - C#: [Select]
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Autodesk.AutoCAD.Runtime;
  6. using Autodesk.AutoCAD.ApplicationServices;
  7. using Autodesk.AutoCAD.DatabaseServices;
  8. using Autodesk.AutoCAD.Geometry;
  9. using Autodesk.AutoCAD.EditorInput;
  10. using System.Diagnostics;
  11.  
  12. namespace SKBS.SimplifyDWG.routines
  13. {
  14.     public class ExplodeRoutines
  15.     {
  16.         public static void Explode(ObjectId entId)
  17.         {
  18.             Document acDoc = Application.DocumentManager.MdiActiveDocument;
  19.             Database acDB = acDoc.Database;
  20.  
  21.             using (Transaction acTrans = acDB.TransactionManager.StartTransaction())
  22.             {
  23.                 Entity currEnt = acTrans.GetObject(entId, OpenMode.ForWrite) as Entity;
  24.                 BlockTableRecord ownerBTR = acTrans.GetObject(currEnt.OwnerId, OpenMode.ForWrite) as BlockTableRecord;
  25.                 #region Table explode
  26.                 if (currEnt.GetType() == typeof(Table))
  27.                 {
  28.                     Table currTable = (Table)currEnt;
  29.                     DBObjectCollection tableExplodedobjects = new DBObjectCollection();
  30.                     currTable.Explode(tableExplodedobjects);
  31.                     foreach (DBObject tableEntite in tableExplodedobjects)
  32.                     {
  33.                         bool add = true;
  34.                         if (tableEntite.GetType() == typeof(Line))
  35.                         {
  36.                             Line acLine = (Line)tableEntite;
  37.                             if (acLine.ColorIndex == 8 || !acLine.Visible)
  38.                             {
  39.                                 add = false;
  40.                             }
  41.                         }
  42.  
  43.                         Entity addedEnt = (Entity)tableEntite;
  44.                         ownerBTR.AppendEntity(addedEnt);
  45.                         Debug.WriteLine("object " + addedEnt.GetType().Name+":"+addedEnt.Id);
  46.                         acTrans.AddNewlyCreatedDBObject(addedEnt, add);
  47.  
  48.                     }
  49.                     Debug.WriteLine("ExplodeTableFinish");
  50.                     BlockTableRecord acTablerecord = acTrans.GetObject(((BlockReference)currEnt).BlockTableRecord, OpenMode.ForWrite) as BlockTableRecord;
  51.                     currEnt.Erase();
  52.                     acTablerecord.Erase();
  53.                 }
  54.                 #endregion
  55.                 #region BrfExplode
  56.                 else if (currEnt.GetType() == typeof(BlockReference))
  57.                 {
  58.                 }
  59.                 #endregion
  60.                
  61.                 acTrans.Commit();
  62.             }
  63.  
  64.         }
  65.     }
  66. }
  67.  

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: .net table.explode file save error
« Reply #1 on: June 11, 2013, 10:34:42 AM »
Code - C#: [Select]
  1. if (add) {
  2.    ownerBTR.AppendEntity(addedEnt);
  3.    Debug.WriteLine("object " + addedEnt.GetType().Name+":"+addedEnt.Id);
  4.    acTrans.AddNewlyCreatedDBObject(addedEnt, true);
  5. } else {
  6.    addedEnt.Dispose();
  7. }

xsakabsx

  • Guest
Re: .net table.explode file save error
« Reply #2 on: June 13, 2013, 06:20:58 AM »
Ура  работает !
Даже не подумал бы про мусор !