Sorting entities
Moderators: SDS, support, admin
Sorting entities
Hi
I have some TsgCADCurvePolygon entities and TsgDXFinsert entities.
Sometimes CurvePolygon entities are drawn over DXFinserts and sometimes vice versa.
Can you give some example code for sorting entities? DXFInserts should be drawn over CurvePolygons which has solid fill.
This is correct:

incorrect;

-- Timo
I have some TsgCADCurvePolygon entities and TsgDXFinsert entities.
Sometimes CurvePolygon entities are drawn over DXFinserts and sometimes vice versa.
Can you give some example code for sorting entities? DXFInserts should be drawn over CurvePolygons which has solid fill.
This is correct:

incorrect;

-- Timo
Re: Sorting entities
Hello Timo,
The draw order depends on entity index in the Model space block (block with name '*MODEL_SPACE'). Entities are drawn in the following order: Entities[0], Entities[1], Entities[2], etc. that means the entity with a higher index value is drawn on top of the entity with a lower index value.
We may give you a sample code which moves entities of a certain type (e.g. inserts of a given block) to the top of the draw order, so that these entities will be drawn over other entities. If you need some other criteria for sorting, let us know.
Mikhail
The draw order depends on entity index in the Model space block (block with name '*MODEL_SPACE'). Entities are drawn in the following order: Entities[0], Entities[1], Entities[2], etc. that means the entity with a higher index value is drawn on top of the entity with a lower index value.
We may give you a sample code which moves entities of a certain type (e.g. inserts of a given block) to the top of the draw order, so that these entities will be drawn over other entities. If you need some other criteria for sorting, let us know.
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Sorting entities
Hi,
All entities on layer "Koki_Grafiikka_Tausta" should drawn first as background (solid fill entites) and all other entities in their default drawing order.
-- Timo
All entities on layer "Koki_Grafiikka_Tausta" should drawn first as background (solid fill entites) and all other entities in their default drawing order.
-- Timo
Re: Sorting entities
Hello Timo,
Sorry for the delay in our reply.
Please try the following routine:
To draw the solid fill entities which belong to the layer "Koki_Grafiikka_Tausta" at first, you should call the given routine as follows, then redraw the CAD image.
Mikhail
Sorry for the delay in our reply.
Please try the following routine:
Code: Select all
procedure SendEntitiesToBack(ACADImage: TsgCADImage; ALayerName: string; EntType: TsgCADEntities);
var
I, Count: Integer;
vModelSpaceBlock: TsgDXFBlock;
vDXFEntity: TsgDXFEntity;
begin
I := 0;
Count := 0;
vModelSpaceBlock := ACADImage.Converter.BlockByName('*MODEL_SPACE');
while I < vModelSpaceBlock.Count do
begin
vDXFEntity := vModelSpaceBlock.Entities[I];
if ((vDXFEntity.EntType = EntType) and (vDXFEntity.Layer.Name = ALayerName)) then
begin
Inc(Count);
vModelSpaceBlock.InsertEntity(Count - 1, vDXFEntity);
vModelSpaceBlock.DeleteEntity(I + 1);
end;
Inc(I);
end;
end;
Code: Select all
SendEntitiesToBack(vCADImage, 'Koki_Grafiikka_Tausta', ceCurvePolygon);
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support