SortEntsTable SDK 7.2
Moderators: SDS, support, admin
SortEntsTable SDK 7.2
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();
}
Re: SortEntsTable SDK 7.2
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.
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
Chat support on Skype: cadsofttools.support
Re: SortEntsTable SDK 7.2
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 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.
Re: SortEntsTable SDK 7.2
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.
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
Chat support on Skype: cadsofttools.support