Page 1 of 1
polyline
Posted: 28 Nov 2006, 13:46
by branka
Where can I get more information about TsgDXFPolyline? I need more information about it's shape. I am trying to use information from dwg file in c++ code. I tried extracting information on polyline by using Entities, but all I get are the first and the last point of the polyline. Can you tell me how I could get more information about its shape?
Posted: 28 Nov 2006, 17:53
by support
Hello Branka,
1. <b>CADImportVCL</b> (available at:
http://www.cadsofttools.com/download/cadimportvcl.zip) contains respective documentation. Please find it in the ..\cadimportvcl\Doc\.. folder of the package.
2. The following example shows how to get vertexes of the polyline:
<b>Unit1.cpp</b>
Code: Select all
...
<font color="green">#include "Unit1.h"</font id="green">
<font color="blue">//---------------------------------------------------------------------------</font id="blue">
...
<font color="green">#pragma link "SGImage"</font id="green">
...
//---------------------------------------------------------------------------
<b>void __fastcall</b> TForm1::Button1Click(TObject *Sender)
{
TsgDXFVertex *Vertex;
TsgDXFPolyline *Poly;
TsgDXFConverter *Conv;
TsgDXFEntity *Ent;
AnsiString S = <font color="blue">""</font id="blue">;
<b>if</b> (!OpenDialog1->Execute()) <b>return</b>;
sgImage1->LoadFromFile(OpenDialog1->FileName);
FImg = <b>dynamic_cast</b><TsgDXFImage *>(sgImage1->Picture->Graphic);
Conv = <b>dynamic_cast</b><TsgDXFConverter *>(FImg->Converter);
<b>int</b> cnt = Conv->Sections[csEntities]->Count;
<b>for</b> (<b>int</b> i = <font color="blue">0</font id="blue">; i < cnt; i++)
{
Ent = <b>dynamic_cast</b><TsgDXFEntity *>(Conv->Sections[csEntities]->Entities[i]);
<b>if</b> (Ent->ClassType() == __classid(TsgDXFPolyline))
{
Poly = dynamic_cast<TsgDXFPolyline *>(Conv->Sections[csEntities]->Entities[i]);
<b>for</b> (<b>int</b> j = <font color="blue">0</font id="blue">; j < Poly->Count; j++)
{
Vertex = dynamic_cast<TsgDXFVertex *>(Poly->Entities[j]);
S = S + <font color="blue">"Vertex "</font id="blue"> + IntToStr(j) + <font color="blue">"\n"</font id="blue"> +
<font color="blue">" X = "</font id="blue"> + FloatToStr(Vertex->Point.X) + <font color="blue">"\n"</font id="blue"> +
<font color="blue">" Y = "</font id="blue"> + FloatToStr(Vertex->Point.Y) + <font color="blue">"\n"</font id="blue"> +
<font color="blue">" Z = "</font id="blue"> + FloatToStr(Vertex->Point.Z) + <font color="blue">"\n"</font id="blue">;
}
ShowMessage(S);
}
}
}
<font color="blue">//---------------------------------------------------------------------------</font id="blue">
<b>Unit1.h</b>
Code: Select all
...
//---------------------------------------------------------------------------
...
<font color="green">#include "SGImage.hpp"
#include "DXFImage.hpp"
#include "DXFConv.hpp"</font id="green">
...
//---------------------------------------------------------------------------
<b>class</b> TForm1 : <b>public</b> TForm
{
__published: // IDE-managed Components
...
TsgImage *sgImage1;
TButton *Button1;
TOpenDialog *OpenDialog1;
void __fastcall Button1Click(TObject *Sender);
<b>private:</b> // User declarations
TsgDXFImage *FImg;
...
};
//---------------------------------------------------------------------------
...
Sergey.
please post questions to the forum or write to
support@cadsofttools.com
Posted: 28 Nov 2006, 20:50
by branka
Thanks for the reply. I have another question. It says in the help that polyline is made up from arcs and lines and that vertexes are end points of those arcs and lines. I was wondering how i could get more information about the arc, its curvature.
Thanks in advance
Posted: 29 Nov 2006, 16:38
by support
Hello Branka,
There two ways:
<ul><li>Easy one:
use the following property:
<b>__property</b> Classes::TList* DottedSingPts = {read=FDottedSingPts};
Contains coordinates of the polyline as a list of the pointers to TFPoint type.</li>
<li>Difficult one:
It is nescessary to analize <b>Bulge</b> property of every vertex received from the <b>TsgDXFPolyline.Entities</b> list.
<b>AutoCAD</b> documantion says:
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">The bulge is the tangent of one fourth the included angle for an arc segment, made negative if the arc goes clockwise from the start point to the endpoint. A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Basing on this information polyline has to be built.
</li></ul>
Sergey.
please post questions to the forum or write to
support@cadsofttools.com