High level interface to PolyLine with DFX Export
Moderators: SDS, support, admin
-
- Posts: 3
- Joined: 30 Nov 2005, 22:22
High level interface to PolyLine with DFX Export
I am looking for a nice way to make dxf files that will contain polylines. I was pretty discouraged after looking at the syntax for creating dxf files directly. (And I didn’t find a polyline in that part of the example.) I worked with the MetaForm syntax using Drawlines. (Please let me know if this is not the same as polyLine) This syntax was a lot closer to what I was looking for. However it appears that this method is very wrapped up in the user interface. I will need my dxf files to be created automatically without the use of a GUI. I have no interest in seeing the drawing I’m creating on screen.
I was pretty excited when I saw the syntax for creating polylines with the metaform. Is there a simple way to create drawings with polylines without interacting with a form or user interface? Could you post an example of how to do this?
I am trying to determine if DXF Export will satisfy our needs...
any assistance would be most appreciated
Jeff
I was pretty excited when I saw the syntax for creating polylines with the metaform. Is there a simple way to create drawings with polylines without interacting with a form or user interface? Could you post an example of how to do this?
I am trying to determine if DXF Export will satisfy our needs...
any assistance would be most appreciated
Jeff
Hello!
DXF Export VCL available on: http://www.cadsofttools.com/download/DXFExporterSDK.zip includes DXF Exporter demo in DXFExporterSDK\Delphi folder. It has button "Make DXF Directly...". When pressing it DXF file is being created directly.
<b>procedure</b> TfmDXFExporter.btnFormShapesClick(Sender: TObject); has an example of creating of the POLILYNE entity
Here these points are being used for creating HATCH's border. In this case the border consists of three PlolyLines
See unit Main.pas rom DemoDelphi Exporter.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
DXF Export VCL available on: http://www.cadsofttools.com/download/DXFExporterSDK.zip includes DXF Exporter demo in DXFExporterSDK\Delphi folder. It has button "Make DXF Directly...". When pressing it DXF file is being created directly.
<b>procedure</b> TfmDXFExporter.btnFormShapesClick(Sender: TObject); has an example of creating of the POLILYNE entity
Code: Select all
...
vDXF := TsgDXFExport.Create;
<b>try</b>
vDXF.AutoCADVer := R2000;
...
FillChar(Data, SizeOf(Data), 0);
Data.Points := TList.Create;
// first boundary
Data.Points.Add(TList.Create);
New(Pt);
Pt^ := MakeDXFPoint(400, 0.0, 0.0);
TList(Data.Points[0]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(400, -100.0, 0.0);
TList(Data.Points[0]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(600, -100.0, 0.0);
TList(Data.Points[0]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(600, 0.0, 0.0);
TList(Data.Points[0]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(400, 0.0, 0.0);
TList(Data.Points[0]).Add(Pt);
// second boundary
Data.Points.Add(TList.Create);
New(Pt);
Pt^ := MakeDXFPoint(420, -30.0, 0.0);
TList(Data.Points[1]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(430, -70.0, 0.0);
TList(Data.Points[1]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(560, -80.0, 0.0);
TList(Data.Points[1]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(580, -50.0, 0.0);
TList(Data.Points[1]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(540, -20.0, 0.0);
TList(Data.Points[1]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(420, -30.0, 0.0);
TList(Data.Points[1]).Add(Pt);
// third boundary
Data.Points.Add(TList.Create);
New(Pt);
Pt^ := MakeDXFPoint(490, -35.0, 0.0);
TList(Data.Points[2]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(460, -60.0, 0.0);
TList(Data.Points[2]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(540, -50.0, 0.0);
TList(Data.Points[2]).Add(Pt);
New(Pt);
Pt^ := MakeDXFPoint(490, -35.0, 0.0);
TList(Data.Points[2]).Add(Pt);
...
// border polyline
Data.Color := ColorToDXF(TColor($424F35));
<b>for</b> I := 0 <b>to</b> Data.Points.Count - 1 <b>do</b>
vDXF.AddPolyLine(Data, I);
FreeDataPoints;
...
vDXF.SaveToFile(SaveDialog.FileName);
<b>finally</b>
vDXF.Free;
<b>end</b>;
See unit Main.pas rom DemoDelphi Exporter.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
-
- Posts: 3
- Joined: 30 Nov 2005, 22:22
-
- Posts: 3
- Joined: 30 Nov 2005, 22:22
Hello,
>a polyline of 140 points would take up 2.15MB
How have you got this figure?
File that has of the ONLY POLYLINE which consists of 140 points can't take such size.
Here goes an example of code (it is based on Main.pas DemoDelphi Exporter). There are 1000 points are being added. File turned out of 24826 bytes.
Sergey
please post questions to the forum or write to support@cadsofttools.com
>a polyline of 140 points would take up 2.15MB
How have you got this figure?
File that has of the ONLY POLYLINE which consists of 140 points can't take such size.
Here goes an example of code (it is based on Main.pas DemoDelphi Exporter). There are 1000 points are being added. File turned out of 24826 bytes.
Code: Select all
<b>procedure</b> TfmDXFExporter.btnFormShapesClick(Sender: TObject);
<b>const</b>
cnstNumberOfPoints = 1000;
<b>var</b>
vDXF: TsgDXFExport;
Data: TdxfExportData;
Pt: PdxfPoint;
I: Integer;
<b>procedure</b> FreeDataPoints;
<b>var</b>
J, K: Integer;
<b>begin</b>
<b>for</b> K := 0 <b>to</b> Data.Points.Count - 1 <b>do</b>
<b>begin</b>
<b>for</b> J := 0 <b>to</b> TList(Data.Points[K]).Count - 1 <b>do</b>
Dispose(PdxfPoint(TList(Data.Points[K]).Items[J]));
TList(Data.Points[K]).Free;
<b>end</b>;
Data.Points.Free;
<b>end</b>;
<b>begin</b>
<b>if</b> <b>not</b> SaveDialog.Execute <b>then</b>
Exit;
vDXF := TsgDXFExport.Create;
<b>try</b>
vDXF.AutoCADVer := R2000;
FillChar(Data, SizeOf(Data), 0);
Data.Count := cnstNumberOfPoints;
Data.Color := ColorToDXF(TColor($68190));
Data.Points := TList.Create;
// first boundary
Data.Points.Add(TList.Create);
<b>for</b> I := 0 <b>to</b> cnstNumberOfPoints-1 <b>do</b>
<b>begin</b>
New(Pt);
Pt^ := MakeDXFPoint(I+10, (I shl 2)*10, 0.0);
TList(Data.Points[0]).Add(Pt);
<b>end</b>;
vDXF.AddPolyLine(Data, 0);
FreeDataPoints;
vDXF.SaveToFile(SaveDialog.FileName);
<b>finally</b>
vDXF.Free;
<b>end</b>;
<b>end</b>;
please post questions to the forum or write to support@cadsofttools.com