Problems with dxfexportvcl
Moderators: SDS, support, admin
Problems with dxfexportvcl
Hi,
i have a problem with the dxfexportvcl. When i execute the following
code i got an dxf which contains nothing. Can you help me? Where is my mistake?
Greetings and thx for help
i have a problem with the dxfexportvcl. When i execute the following
code i got an dxf which contains nothing. Can you help me? Where is my mistake?
Greetings and thx for help
Code: Select all
<b>procedure</b> TForm1.Button1Click(Sender: TObject);
<b>var</b>
E : TsgDXFExport;
Data : TdxfExportData;
<b>function</b> MakedxfPoint(x,y,z : Single) : TdxfPoint;
<b>begin</b>
result.X := x;
result.Y := y;
result.Z := z;
<b>end</b>;
<b>begin
try</b>
Data.Color := clBlack;
Data.Thickness := 3;
Data.Point := MakedxfPoint(0, 0, 0);
Data.Point1 := MakedxfPoint(100, 100, 0);
Data.Style := PS_SOLID;
E := TsgDXFExport.Create;
E.BeginBlock('Test');
E.AddLine(Data);
Data.Point := MakedxfPoint(0, 0, 0);
Data.Point1 := MakedxfPoint(10, 50, 0);
E.AddLine(Data);
Data.Point := MakedxfPoint(10, 50, 0);
Data.Point1 := MakedxfPoint(100, 100, 0);
E.AddLine(Data);
Data.Point := MakedxfPoint(10, 50, 0);
Data.Text := 'TestText';
Data.FName := 'Arial';
Data.FHeight := 15;
E.AddText(Data);
E.EndBlock;
E.EndDraw;
E.SaveToFile('C:\tmp\maling.dxf');
<b>finally</b>
E.Free;
<b>end</b>;
Hello,
First of all here goes several remarks:
1. When using procedures <b>TsgDXFExport.BeginBlock</b> and <b>TsgDXFExport.EndBlock</b> you just create block inside of your DXF file. It is necessary to use procedure <b>TsgDXFExport.Insert</b> for adding block to the drawing.
2. It is necessary to use procedure <b>TsgDXFExport.AddLType</b> for a possibility of using line types.
3. There is no need to use procedure <b>TsgDXFExport.EndDraw</b> when creating DXF file without Windows metafile usage.
4. It is necessary to use the following constants for a possibility of using DXF colors:
For more colors please see <b>arrDXFtoRGBColors</b> in module sgConsts.pas.
We've made some changes to your code. Please see it below:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
First of all here goes several remarks:
1. When using procedures <b>TsgDXFExport.BeginBlock</b> and <b>TsgDXFExport.EndBlock</b> you just create block inside of your DXF file. It is necessary to use procedure <b>TsgDXFExport.Insert</b> for adding block to the drawing.
2. It is necessary to use procedure <b>TsgDXFExport.AddLType</b> for a possibility of using line types.
3. There is no need to use procedure <b>TsgDXFExport.EndDraw</b> when creating DXF file without Windows metafile usage.
4. It is necessary to use the following constants for a possibility of using DXF colors:
Code: Select all
<b>const</b>
DXF_BYBLOCK = 0;
DXF_RED = 1;
DXF_YELLOW = 2;
DXF_LIME = 3;
DXF_AQUA = 4;
DXF_BLUE = 5;
DXF_FUCHSIA = 6;
DXF_BLACK = 7;
DXF_GRAY = 8;// DXF_GRAY = 252;
DXF_SILVER = 9;
DXF_OLIVE = 44;
DXF_GREEN = 74;
DXF_TEAL = 135;
DXF_NAVY = 154;
DXF_PURPLE = 224;
DXF_MAROON = 14;
DXF_WHITE = 255;
DXF_BYLAYER = 256;
DXF_ALTERNATIVEBLACK = 250;// for replacement of a DXF_BLACK
DXF_DKGRAY = 251;// dark gray
DXF_LTGRAY = 254;// light gray
We've made some changes to your code. Please see it below:
Code: Select all
<b>procedure</b> TForm1.DXFExportTest1Click(Sender: TObject);
<b>var</b>
E : TsgDXFExport;
Data : TdxfExportData;
vLayer: TsgExpDXFLayer;
<b>function</b> MakedxfPoint(x,y,z : Single) : TdxfPoint;
<b>begin</b>
result.X := x;
result.Y := y;
result.Z := z;
<b>end</b>;
<b>begin
try</b>
E := TsgDXFExport.Create;
E.AddLType('ACADISO03W100', [5,-3]);
E.AddLType('ACADISO06W100', [24,-3,0,-3,0,-3,0,-3]);
FillChar(Data, SizeOf(Data), 0);
Data.Color := DXF_BLACK;
Data.Thickness := 3;
Data.Style := PS_SOLID;
<i>//Create block 'Test1'</i>
E.BeginBlock('Test1');
FillChar(Data, SizeOf(Data), 0);
Data.Text := 'ACADISO03W100';// linetype
Data.Point := MakedxfPoint(0, 0, 0);
Data.Point1 := MakedxfPoint(10, 50, 0);
E.AddLine(Data);
E.EndBlock;
<i>//Insert block 'Test1' to the drawing</i>
FillChar(Data, SizeOf(Data), 0);
vLayer := TsgExpDXFLayer.Create('Blocks');
E.CurrentLayer := vLayer;
Data.Thickness := 0;
Data.Text := 'Test1';
Data.Point := MakedxfPoint(70, -30, 0);
Data.Scale.X := 3;
Data.Scale.Y := 3;
E.Insert(Data);
<i>//Add text</i>
FillChar(Data, SizeOf(Data), 0);
Data.Point := MakedxfPoint(10, 50, 0);
Data.Text := 'TestText';
Data.FName := 'Arial';
Data.FHeight := 15;
E.AddText(Data);
<i>//Add line with 'ACADISO06W100' linetype</i>
FillChar(Data, SizeOf(Data), 0);
Data.Color := DXF_BLUE;
Data.Text := 'ACADISO06W100';// linetype
Data.Thickness := 10;
Data.Point := MakedxfPoint(10, 10, 0);
Data.Point1 := MakedxfPoint(200, 10, 0);
E.AddLine(Data);
<i>//Add line with 'ACADISO03W100' linetype</i>
FillChar(Data, SizeOf(Data), 0);
Data.Color := DXF_FUCHSIA;
Data.Text := 'ACADISO03W100';// linetype
Data.Thickness := 20;
Data.Point := MakedxfPoint(10, 20, 0);
Data.Point1 := MakedxfPoint(200, 20, 0);
E.AddLine(Data);
E.SaveToFile('C:\tmp\maling.dxf');
<b>finally</b>
E.Free;
<b>end</b>;
<b>end</b>;
please post questions to the forum or write to support@cadsofttools.com