SortEntsTable SDK 7.2

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
usedbyanr
Posts: 2
Joined: 26 Feb 2010, 22:38

SortEntsTable SDK 7.2

Post by usedbyanr » 26 Feb 2010, 23:07

I have some code similar to the code below written in pascal for Delphi and I get "Bad handle xxxx: already in use" under v 7.2. Is this code still supposed to work. It was posted by someone in support in response to a question about drawing order. It works under 6.3.

Code: Select all

private void button1_Click(object sender, System.EventArgs e)
{         
   if(this.cadImage == null) 
   {
      this.cadImage = new CADImage();
      this.cadImage.InitialNewImage();
      this.cadImage.UseDoubleBuffering = false;
   }
   this.cadImage.UseDoubleBuffering = false;
         
   int i = 0;
   long BottomHandle;
   CADEntity vEntity;
   CADSortEntsTable SortTable;
   ArrayList HandleList;     

   HandleList = new ArrayList();
   SortTable = new CADSortEntsTable();
   BottomHandle = Int32.MaxValue;
   for (i=0;i<this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
   {
      vEntity = (CADEntity)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
      SortTable.HandlesOld.Add(vEntity.Handle);
      if (vEntity is CADGradientPolygon)
         HandleList.Add(vEntity);
      if (BottomHandle > vEntity.Handle)
         BottomHandle = vEntity.Handle;
   }

   BottomHandle++;

   for (i=0;i<this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
   {
      if (HandleList.IndexOf(this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i]) == -1)               
      {
         vEntity = (CADEntity)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
         SortTable.HandlesNew.Add(vEntity.Handle);
         vEntity.Handle = BottomHandle + HandleList.Count + i;
      }
   }

   for (i=0;i<HandleList.Count;i++)
   {
      vEntity = (CADEntity)HandleList[i];
      vEntity.Handle = BottomHandle + i;
      SortTable.HandlesNew.Add(vEntity.Handle);
   }

   this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Tables).AddEntity(SortTable);            
   this.cadImage.Converter.Loads(SortTable);
   this.cadImage.Converter.SortEntities();         
   this.cadPictBox.Invalidate();
}

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: SortEntsTable SDK 7.2

Post by support » 27 Feb 2010, 16:11

Hello.
The above mentioned code isn't correct for version 7. Moreover, we're not recommend to change handles manually anymore (such possibility will be disabled in next versions). Such an action can results in "Bad handle xxxx: already in use" exception.
The code sorts entities to draw CADGradientPolygon at bottom. Such result can be gained also without CADSortEntsTable object. You just need to sort entities order in entities list.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

usedbyanr
Posts: 2
Joined: 26 Feb 2010, 22:38

Re: SortEntsTable SDK 7.2

Post by usedbyanr » 01 Mar 2010, 17:52

support wrote:The code sorts entities to draw CADGradientPolygon at bottom. Such result can be gained also without CADSortEntsTable object. You just need to sort entities order in entities list.
I do something similar to this so that the objects in layers that I have added draw at the bottom. I assume that sorting entities in the entities list may work when drawn with the SDK but what will AutoCAD do when it's exported as a DXF? Will it draw in handle order? I'm going to test it myself but I'm curious to hear the answer.

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: SortEntsTable SDK 7.2

Post by support » 03 Mar 2010, 16:11

Hello.
The order of drawing entities in AutoCAD depends on SORTENTSTABLE object if exists. Otherwise AutoCAD regenerates entities in ascending index order on model_space.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply