How to transform Polyline and Ellipse?
Moderators: SDS, support, admin
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
How to transform Polyline and Ellipse?
Hi,
I am writing codes for moving a SPline, Polyline and Ellipse.
I have successful with Spline by recalculate the Fits anf Controls with Matrix. But Do not know what points should be calculated with the other two. I have tried the following code on both PolyPoints and the DottedPoints,
for(int i=Ent->PolyPoints->Count-1; i>=0; i--)
{
vPt = (TFPoint *)(Ent->PolyPoints->Items);
*vPt = ::PtXMat(*vPt, FCADParams.Matrix);
}
I can see that the value of the points changed but the graph is not moved. Please advise. Also what points should I use for Ellipse?
I am writing codes for moving a SPline, Polyline and Ellipse.
I have successful with Spline by recalculate the Fits anf Controls with Matrix. But Do not know what points should be calculated with the other two. I have tried the following code on both PolyPoints and the DottedPoints,
for(int i=Ent->PolyPoints->Count-1; i>=0; i--)
{
vPt = (TFPoint *)(Ent->PolyPoints->Items);
*vPt = ::PtXMat(*vPt, FCADParams.Matrix);
}
I can see that the value of the points changed but the graph is not moved. Please advise. Also what points should I use for Ellipse?
Re: How to transform Polyline and Ellipse?
Hello.
You're correct, the Fit points and Control points must be recalculated to move a TsgDXFSpline object. For moving a TsgDXFPolyline object please recalculate its Vertexes (TsgDXFVertex objects, placed in child entities collection of TsgDXFPolyline object). To move TsgDXFEllipse object just change its Point property.
Alexander.
You're correct, the Fit points and Control points must be recalculated to move a TsgDXFSpline object. For moving a TsgDXFPolyline object please recalculate its Vertexes (TsgDXFVertex objects, placed in child entities collection of TsgDXFPolyline object). To move TsgDXFEllipse object just change its Point property.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
Re: How to transform Polyline and Ellipse?
HI Alexander,
Thanks for the tips. I have done the Ellipse transform. But for the LwPolyline or Polyline, I donot know how to get the vertecis as you mentioned. I noticed in CADImage.pas, the code for drawing polyline first check the child entities for type Line and Arc and draw respectively,
for I := 0 to APolyLine.PolyLineEntities.Count - 1 do
begin
vEnt := TsgDXFEntity(APolyLine.PolyLineEntities);
if vEnt is TsgDXFArc then
DrawArc(TsgDXFArc(APolyLine.PolyLineEntities))
else
if vEnt is TsgDXFLine then
DrawLine(TsgDXFLine(APolyLine.PolyLineEntities));
end;
I wonder if I should do the same in transformation? Also, I want to mark the selected entity on screen with the 8 dots on the Box. What is the best way. I am using the TsgDXFText with charactor "." and put all the TExt entities in a TsgDXFInsert. Now when doing transform, how can I point to thess Text entities in the Insert? Or, Can you guide me a better way. The problem of using The TsgDXFText is that the dots zoom when the graph is zoomed. I wish the dots donot change size no matter how big or small the enclosed graph changes. Thanks!
Jason
Thanks for the tips. I have done the Ellipse transform. But for the LwPolyline or Polyline, I donot know how to get the vertecis as you mentioned. I noticed in CADImage.pas, the code for drawing polyline first check the child entities for type Line and Arc and draw respectively,
for I := 0 to APolyLine.PolyLineEntities.Count - 1 do
begin
vEnt := TsgDXFEntity(APolyLine.PolyLineEntities);
if vEnt is TsgDXFArc then
DrawArc(TsgDXFArc(APolyLine.PolyLineEntities))
else
if vEnt is TsgDXFLine then
DrawLine(TsgDXFLine(APolyLine.PolyLineEntities));
end;
I wonder if I should do the same in transformation? Also, I want to mark the selected entity on screen with the 8 dots on the Box. What is the best way. I am using the TsgDXFText with charactor "." and put all the TExt entities in a TsgDXFInsert. Now when doing transform, how can I point to thess Text entities in the Insert? Or, Can you guide me a better way. The problem of using The TsgDXFText is that the dots zoom when the graph is zoomed. I wish the dots donot change size no matter how big or small the enclosed graph changes. Thanks!
Jason
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
Re: How to transform Polyline and Ellipse?
Hi Alexander,
When using TsgDXFPolyline, I tried to use PolyFaceVertexIndexes to access the CHild Entities but always get a "Access Violation" error. The definition of PolyFaceVertexIndexes in DXFConv.hpp is,
So I tried both,
and
Both get the "Access Violation" error.
Please advise why?
Jason
When using TsgDXFPolyline, I tried to use PolyFaceVertexIndexes to access the CHild Entities but always get a "Access Violation" error. The definition of PolyFaceVertexIndexes in DXFConv.hpp is,
Code: Select all
__property Classes::TList* PolyLineEntities = {read=FPolyLineEntities}
Code: Select all
for( int i=Ent->TsgDXFPolyline::PolyFaceVertexIndexes->Count-1; i>=0; i--)
Code: Select all
for( int i=Ent->PolyFaceVertexIndexes->Count-1; i>=0; i--)
Please advise why?
Jason
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
Re: How to transform Polyline and Ellipse?
Hi, Alexander,
I tried to change the Point property to move a TsgDXFInsert on the screen. I found the Point property can not be changed. By checking DXFConv.hpp I found the Point is defined in TsgDXFCustomVertex public section as follows,
Donot know why I could not write.
After change the line to:
the problem is solved. I can move a TsgDXFInsert around by changing the Point property. I donot know if this change will cause other functions of the package, or it is really a BUg?
Please advise.
Jason
I tried to change the Point property to move a TsgDXFInsert on the screen. I found the Point property can not be changed. By checking DXFConv.hpp I found the Point is defined in TsgDXFCustomVertex public section as follows,
Code: Select all
__property Sgconsts::TFPoint Point = {read=GetPoint, write=SetPoint};
Donot know why I could not write.
After change the line to:
Code: Select all
__property Sgconsts::TFPoint Point = {read=FPoint, write=FPoint};
Please advise.
Jason
Re: How to transform Polyline and Ellipse?
Hello Jason.
Child entities of an entity accessible via TsgDXFEntity.Entities, where i - number of entity in the list. TsgDXFPolyline.Entities will return vertex with i number.
Alexander.
Child entities of an entity accessible via TsgDXFEntity.Entities, where i - number of entity in the list. TsgDXFPolyline.Entities will return vertex with i number.
Insert is the reference to the block that contains entities. Text entities accessible within the insert in the similar way: TsgDXFInsert.Block.Entities.I want to mark the selected entity on screen with the 8 dots on the Box. I am using the TsgDXFText with charactor "." and put all the TExt entities in a TsgDXFInsert. Now when doing transform, how can I point to thess Text entities in the Insert?
You can use TsgDXFPoint objects instead the "." texts. TsgDXFPoint doesn't zoomed.Or, Can you guide me a better way. The problem of using The TsgDXFText is that the dots zoom when the graph is zoomed. I wish the dots donot change size no matter how big or small the enclosed graph changes.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to transform Polyline and Ellipse?
The modification to access TFPoint field directly is incorrect. Please use the MakeFPoint method from sgConsts unit:
Alexander.
Code: Select all
var
ins: TsgDXFInsert;
begin
...
ins.Point := MakeFPoint(x, y, z);
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
Re: How to transform Polyline and Ellipse?
Hi Alexander,
TsgDXFPolyline.Entities does not work in C++. The following code does not pass the compiler,
I have checked the DXFConv.hpp. In the definition of TsgDXFPolyline, Entities is not defined anywhere. There is only this line:
Please advise hw I should refer to the List? There is also this line under Public:
Can I use this PolyLineEntities? If so, how should I refer to it, ::PolyLineEntities good?
thanks.
Jason
TsgDXFPolyline.Entities does not work in C++. The following code does not pass the compiler,
Code: Select all
for( int i=Ent->Entities->Count-1; i>=0; i--)
Code: Select all
protected:
.
.
__property Classes::TList* List = {read=FEntities};
Code: Select all
__property Classes::TList* PolyLineEntities = {read=FPolyLineEntities};
thanks.
Jason
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
Re: How to transform Polyline and Ellipse?
THis probblly does not solve my problem. My code is as follows,The modification to access TFPoint field directly is incorrect. Please use the MakeFPoint method from sgConsts unit:
Code: Select all
var
ins: TsgDXFInsert;
begin
...
ins.Point := MakeFPoint(x, y, z);
Code: Select all
vPt = (TFPoint *)(&(Ent->Point));
*vPt = ::PtXMat(*vPt, FCADParams.Matrix);
Jason
Re: How to transform Polyline and Ellipse?
Hello Jason.
TsgDXFPolyline->Entities doesn't gives access to entities list, but single TsgDXFEntity object from list.Please see help system if any similar questions, it contains description of entities structure.
Alexander.
TsgDXFPolyline->Entities doesn't gives access to entities list, but single TsgDXFEntity object from list.
Code: Select all
for (int i = 0; i < Ent->Count; i++)
{
Ent->Entities[i]->Visible = true;
}
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to transform Polyline and Ellipse?
Please try the following code:
Alexander.
Code: Select all
PFPoint vpt;
*vpt = ::PtXMat(*vPt, FCADParams.Matrix);
Ent->Point = *vpt;
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to transform Polyline and Ellipse?
Also TsfDXFPolyline.PolyLineEntities property contain TsgDXFArc, TsgDXFLine objects that form polyline if TsgDXFConverter.AllArcsAsCurves = false.
Alexander.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
Re: How to transform Polyline and Ellipse?
Hi Alexander,
Jason
I have taken your advice and changed to use TsgDXFPoint to draw the 8 points on the selected entity box. The problem is no mater what value I set for PointDisplayMode and PointDisplaySize, it always only show a one pixel dot. Just want to ask if PointDisplayMode and PointDisplaySize are actually supported in CADImport? My code is as follows,You can use TsgDXFPoint objects instead the "." texts. TsgDXFPoint doesn't zoomed.
Code: Select all
FImg->Converter->HeadVarStruct.PointDisplayMode = 64;
FImg->Converter->HeadVarStruct.PointDisplaySize = -15;
.
.
void TForm1::AddBoxDotToConv(TsgCADImage *Im, TFPoint vPoint)
{
TsgDXFPoint *pText;
pText = new TsgDXFPoint;
pText->Point = vPoint;
pText->Color = clRed;
Im->Converter->Sections[csEntities]->AddEntity(pText);
if (Im->Converter->OnCreate != NULL)
Im->Converter->OnCreate(pText);
Im->Converter->Loads(pText);
}
-
- Posts: 12
- Joined: 14 Nov 2008, 09:45
Re: How to transform Polyline and Ellipse?
Hi Jason,
PointDisplayMode and PointDisplaySize should be used as properties of TsgDXFConverter:
FImg->Converter->PointDisplayMode
FImg->Converter->PointDisplayMode
without "->HeadVarStruct."
and please call
Im->GetExtents
after adding or changing the point.
Thanks.
Evgeny
PointDisplayMode and PointDisplaySize should be used as properties of TsgDXFConverter:
FImg->Converter->PointDisplayMode
FImg->Converter->PointDisplayMode
without "->HeadVarStruct."
and please call
Im->GetExtents
after adding or changing the point.
Thanks.
Evgeny
-
- Posts: 24
- Joined: 13 Apr 2006, 16:20
Re: How to transform Polyline and Ellipse?
Still not working. the line FImg->Converter->PointDisplaySize does not pass compile with message "PointDisplaySize is not a member of Convertor". TriedPointDisplayMode and PointDisplaySize should be used as properties of TsgDXFConverter:
FImg->Converter->PointDisplayMode
FImg->Converter->PointDisplayMode
without "->HeadVarStruct."
and please call
Im->GetExtents
after adding or changing the point.
Code: Select all
FImg->Converter->PointDisplayMode = 64;
FImg->Converter->HeadVarStruct.PointDisplaySize = -5;
Jason