Author Topic: How to Collect / Explode AECC objects?  (Read 3828 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
How to Collect / Explode AECC objects?
« on: May 21, 2016, 09:26:15 AM »
I want to explode all civil 3d objects in a drawing with the API...is there an efficient way to do this without iterating through every entity and checking for "AEC" then exploding them individually? Or at least a way to limit the data I check?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to Collect / Explode AECC objects?
« Reply #1 on: May 21, 2016, 03:00:27 PM »
Get a selection set using {0, "AECC-*"} for the filter?

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How to Collect / Explode AECC objects?
« Reply #2 on: May 21, 2016, 06:21:52 PM »
yea :/ was hoping there was a secret aecc.explodeeverything method I didn't know about lol

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: How to Collect / Explode AECC objects?
« Reply #3 on: May 22, 2016, 04:01:12 AM »
is there an efficient way to do this without iterating through every entity and checking for "AEC" then exploding them individually?
In my opinion iteration is not a problem... For example, iteration of 736 323 objects of database (DWG size is more than 50 Mb)  takes a 00:00:00,2781968 (i.e. less than one second).

Code - C#: [Select]
  1. public static ObjectId[] GetDBObjectIds(this Database db,
  2.         Func<ObjectId, Boolean> filter) {
  3.  
  4.         // Check arguments
  5.         if (null == db)
  6.                 throw new ArgumentNullException("null == db");
  7.         if (null == filter)
  8.                 throw new ArgumentNullException("null == filter");
  9.         if (db.IsDisposed)
  10.                 throw new ArgumentException("true == db.IsDisposed");
  11.  
  12.         // -------------------
  13.         Int32 approxNum = db.ApproxNumObjects;
  14.         List<ObjectId> ids = new List<ObjectId>();
  15.  
  16.         for (Int64 i = db.BlockTableId.Handle.Value; i < db.Handseed.Value
  17.                 && approxNum > 0; ++i) {
  18.  
  19.                 Handle h = new Handle(i);
  20.                 ObjectId id = ObjectId.Null;
  21.  
  22.                 Boolean parseResult = db.TryGetObjectId(h, out id);
  23.  
  24.                 if (parseResult) {
  25.                         --approxNum;
  26.                         if (filter(id)) {
  27.                                 ids.Add(id);
  28.                         }
  29.                 }
  30.         }
  31.         return ids.ToArray();
  32. }
I use it for the searching, exploding, and removing all proxy in the Database (usual AutoCAD).
« Last Edit: May 22, 2016, 04:04:26 AM by Andrey Bushman »

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How to Collect / Explode AECC objects?
« Reply #4 on: May 22, 2016, 04:38:52 PM »
But with exploding each AEC object one at a time?

is there an efficient way to do this without iterating through every entity and checking for "AEC" then exploding them individually?
In my opinion iteration is not a problem... For example, iteration of 736 323 objects of database (DWG size is more than 50 Mb)  takes a 00:00:00,2781968 (i.e. less than one second).

Code - C#: [Select]
  1. public static ObjectId[] GetDBObjectIds(this Database db,
  2.         Func<ObjectId, Boolean> filter) {
  3.  
  4.         // Check arguments
  5.         if (null == db)
  6.                 throw new ArgumentNullException("null == db");
  7.         if (null == filter)
  8.                 throw new ArgumentNullException("null == filter");
  9.         if (db.IsDisposed)
  10.                 throw new ArgumentException("true == db.IsDisposed");
  11.  
  12.         // -------------------
  13.         Int32 approxNum = db.ApproxNumObjects;
  14.         List<ObjectId> ids = new List<ObjectId>();
  15.  
  16.         for (Int64 i = db.BlockTableId.Handle.Value; i < db.Handseed.Value
  17.                 && approxNum > 0; ++i) {
  18.  
  19.                 Handle h = new Handle(i);
  20.                 ObjectId id = ObjectId.Null;
  21.  
  22.                 Boolean parseResult = db.TryGetObjectId(h, out id);
  23.  
  24.                 if (parseResult) {
  25.                         --approxNum;
  26.                         if (filter(id)) {
  27.                                 ids.Add(id);
  28.                         }
  29.                 }
  30.         }
  31.         return ids.ToArray();
  32. }
I use it for the searching, exploding, and removing all proxy in the Database (usual AutoCAD).

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: How to Collect / Explode AECC objects?
« Reply #5 on: May 22, 2016, 04:47:51 PM »
But with exploding each AEC object one at a time?
I don't understand you. What do you mean?

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How to Collect / Explode AECC objects?
« Reply #6 on: May 22, 2016, 08:31:06 PM »
But with exploding each AEC object one at a time?
I don't understand you. What do you mean?

eh...I was just hoping there was an allaecobjects.explodeinstantly() method available that I just didn't know about.

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: How to Collect / Explode AECC objects?
« Reply #7 on: May 23, 2016, 05:12:35 AM »
Exploding objects will create new AutoCAD objects, after that you need to erase the original objects.

Erasing objects will affect the existence of others, if you immediately erase an Alignment after exploding, all Profiles and Profile Views and Sections etc will be deleted too.

So you better explode all object first, then erase all original objects inside a try-catch.

Or, send a Command Line string: "Explode all".
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How to Collect / Explode AECC objects?
« Reply #8 on: May 23, 2016, 05:49:01 AM »
Exploding objects will create new AutoCAD objects, after that you need to erase the original objects.

Erasing objects will affect the existence of others, if you immediately erase an Alignment after exploding, all Profiles and Profile Views and Sections etc will be deleted too.

So you better explode all object first, then erase all original objects inside a try-catch.

Or, send a Command Line string: "Explode all".
Thanks Huiz and all