Skip to main content

Change layers procedure

uses DXF, DXFConv;

...

type

TForm1 = class(TForm)

Image1: TImage;

...

implementation

procedure TForm1.ChangeLayersClick(Sender: TObject);

var
// a reading class for DXF format
// Please use a correspond class to read a drawing of other format.
// For example TsgDWGImage for DWG format, TsgCGMImage for CGM, etc.
vDrawing: TsgCADDXFImage;
vLayer: TsgDXFLayer; // a class for Layers

begin
vDrawing := TsgCADDXFImage.Create;
vDrawing.LoadFromFile('Entities.dxf');

// change color of Layer '0'

vDrawing.Converter.LayerByName('0').Color := clRed;

// if layer does not exist, new layer will be created

vLayer := vDrawing.Converter.LayerByName('Layer2');

vLayer.Visible := False; //change layer visibility

Image1.Picture.Graphic := nil;

Image1.Canvas.StretchDraw(Rect(0, 0,

Round(vDrawing.Width * Image1.Height / vDrawing.Height), Image1.Height), vDrawing);

vDrawing.Free;

end;