PolyLine
Moderators: SDS, support, admin
Hello!
The following code is based on the demo available at: http://www.cadsofttools.com/download/Template.zip
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
The following code is based on the demo available at: http://www.cadsofttools.com/download/Template.zip
Code: Select all
<b>procedure</b> TForm1.btnAddGradientHatchClick(Sender: TObject);
<b>var</b>
vGradient: TsgCADCurvePolygon;
v2DBList: Tsg2DBoundaryList;
v2DPolyline: Tsg2DPolyline;
vPoint2D: TF2DPoint;
<b>begin
if</b> FCADImg <> <b>nil then
begin</b>
FCADImg.Free;
FCADImg := <b>nil</b>;
<b>end</b>;
FCADImg := TsgDXFImage.Create;
vGradient := TsgCADCurvePolygon.Create;
vGradient.GradientAngle := <font color="blue">45 </font id="blue">;
vGradient.GradientColor := clRed;
vGradient.GradientName := 'INVSPHERICAL';
<font color="blue">//'CURVED', 'CYLINDER', 'HEMISPHERICAL', 'LINEAR', </font id="blue">
<font color="blue">//'SPHERICAL', 'INVCURVED', 'INVCYLINDER', 'INVHEMISPHERICAL', 'INVSPHERICAL' </font id="blue">
vGradient.GradientUseCenter := true;
v2DBList := Tsg2DBoundaryList.Create;
v2DBList.BoundaryType := <font color="blue">7</font id="blue">; <font color="blue">// Polyline type </font id="blue">
vGradient.BoundaryData.Add(v2DBList);
v2DPolyline := Tsg2DPolyline.Create;
v2DBList.Add(v2DPolyline);
vPoint2D := MakeF2DPoint(<font color="blue">0.0</font id="blue">, <font color="blue">0.0</font id="blue">);
v2DPolyline.AddVertex(vPoint2D);
vPoint2D := MakeF2DPoint(<font color="blue">93.0</font id="blue">,<font color="blue">29.0</font id="blue">);
v2DPolyline.AddVertex(vPoint2D);
vPoint2D := MakeF2DPoint(<font color="blue">150.0</font id="blue">, <font color="blue">120.0</font id="blue">);
v2DPolyline.AddVertex(vPoint2D);
vPoint2D := MakeF2DPoint(<font color="blue">0.0</font id="blue">,<font color="blue">0.0</font id="blue">);
v2DPolyline.AddVertex(vPoint2D);
<b>if not</b> AddEntityToLayout(vGradient, <font color="blue">0</font id="blue">) <b>then</b> vGradient.Free;
<i><font color="blue">{ Apply new drawing extents } </font id="blue"></i>
FCADImg.GetExtents;
<i> <font color="blue">{ Copying new drawing to the sgPaintBox } </font id="blue"></i>
sgPaintBox.Picture.Graphic := FCADImg;
sgPaintBox.Width := Round(FCADImg.AbsWidth);
sgPaintBox.Height := Round(FCADImg.AbsHeight);
sgPaintBox.Invalidate;
<b>end</b>;
<b>function</b> TForm1.AddEntityToLayout(AEntity: TsgDXFEntity; <b>const</b> ALayoutIndex: Integer): Boolean;
<b>begin</b>
Result := False;
<b>if</b> ALayoutIndex < FCADImg.LayoutsCount <b>then
begin
if</b> Assigned(FCADImg.Converter.OnCreate) <b>then</b>
FCADImg.Converter.OnCreate(AEntity);
FCADImg.Converter.Loads(AEntity);
FCADImg.Layouts[ALayoutIndex].AddEntity(AEntity);
Result := True;
<b>end</b>;
<b>end</b>;
Please post questions to the forum or write to support@cadsofttools.com