SortEntsTable SDK 7.2
Posted: 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();
}