Author Topic: Question about disposing.  (Read 14427 times)

0 Members and 1 Guest are viewing this topic.

BillZndl

  • Guest
Re: Question about disposing.
« Reply #45 on: November 05, 2009, 02:44:18 PM »
Is that book by Jesse Liberty? If so, I was going to suggest it as a beginners book.

When you're ready to move to a more advanced book, myself and others here recommend Andrew Troelsen's 'Pro C# and the .NET 3.5 Platform' - it's excellent.

These languages are not like lisp where you can just 'hack away' - you need to put in the effort of learning the groundwork of the language and it's usage.

Keep at it - it is fun!

Yes, Jesse Liberty, net 1.1 & vs 2003.

We're just so used to slapping something together with lisp to solve our problems.
But this has been fun and rewarding.
All part of the learning curve.
Believe it or not, I've come a long way already.  :-D

Thanks again everyone!

Bill





BillZndl

  • Guest
Re: Question about disposing.
« Reply #46 on: November 17, 2009, 04:53:41 PM »
have a look at this code and see if it works for you

Code: [Select]
      if (!Did.IsNull)
      {
       Group EntGrpDic = trans.GetObject(Did, OpenMode.ForWrite) as Group;
       ObjectIdCollection Eids = new ObjectIdCollection();

       foreach (ObjectId id in EntGrpDic.GetAllEntityIds())
       {
        if (!id.IsErased)
        {
         DBObject dbObject = trans.GetObject(id, OpenMode.ForWrite);
         dbObject.Erase();
        }
       }
       [color=red]GrpDic.UpgradeOpen();
       GrpDic.Erase();[/color]
       editor.WriteMessage("\nDeleted Group: < " + Strline + " > \r");
       editor.WriteMessage("\nCommand:\r");
      }
      trans.Commit();
     }
 

Seems like I still have to purge the database of the erased items to keep AutoCAD happy.
And I'm not sure if I have to remove the objectId of the group from the group dictionary,
I'll have test it some more and see about that.
Other wise things are working pretty good but I plan to keep reading and refining my abilities.  :laugh:
Thanks!

Code: [Select]
if (!Did.IsNull)
                        {
                            Group EntGrpDic = trans.GetObject(Did, OpenMode.ForWrite) as Group;
                            [color=red]ObjectIdCollection oidc = new ObjectIdCollection(EntGrpDic.GetAllEntityIds());[/color]

                            foreach (ObjectId id in EntGrpDic.GetAllEntityIds())
                            {
                                if (!id.IsErased)
                                {
                                    DBObject dbObject = trans.GetObject(id, OpenMode.ForWrite);
                                    dbObject.Erase();                                   
                                }
                            }

                            [color=red]GrpDic.UpgradeOpen();
                            GrpDic.Remove(Did);
                            GrpDic.DowngradeOpen();

                            database.Purge(oidc);
                            EntGrpDic.Erase();
                            oidc.Dispose();[/color]
                           
                            editor.WriteMessage("\nDeleted Group: < " + Strline + " > \r");
                            editor.WriteMessage("\nCommand:\r");
                        }