moving a hatch
Posted: 26 Nov 2014, 19:13
Hello to everyone.
I post code to create a hatch in a drawing - after having loaded a dwg under a drawingnavigator.
This code works.
Now I need to programmatically change the position of the hatch, or the shape (size).
For example I want to move just 1 vertex, or maybe move the whole hatch x units to the left.
but for example
vpoly.Points[0].X := vpoly.Points[0].X-30;
does not work, because X is read only
color I can change it, just do vhatch.color:=clNavy; fsgpaintbox.repaint;
How can I do it?
thank you
Alan
I post code to create a hatch in a drawing - after having loaded a dwg under a drawingnavigator.
This code works.
Code: Select all
....
private
FsgPaintBox: TsgDrawingNavigator;
....
public
property sgPaintBox: TsgDrawingNavigator read GetFsgPaintBox;
.........................
procedure TForm1.AddHatchClick(Sender: TObject);
var VHPData: PsgHatchPatternData;
vhatch:tsgcadhatch;
v2dblist: tsg2dboundarylist;
vpoly:tsg2dpolyline;
vlayout:TsgDXFLayout;
begin
vhatch:=tsgcadhatch.Create;
vHatch.HatchName := 'ANSI31';
v2DBList:=vHatch.AddBoundaryList(7);
vPoly := Tsg2DPolyline.Create;
v2DBList.Add(tsg2dpolyline(vPoly));
with vpoly do
begin
Closed := True;
AddVertex(MakeF2DPoint(100,100);
AddVertex(MakeF2DPoint(100,150);
AddVertex(MakeF2DPoint(200,125);
AddVertex(MakeF2DPoint(100,100);
end;
vHatch1.SetColor(clRed);
New(vHPData);
with VHPData do
begin
BaseP := MakeFPoint(0, 0, 0);
Offset := MakeFPoint(-1, 1, 0);
LineAngle := 45.0;
IsDash := False;
Lines := nil;
DashNum := 0;
end;
vHatch.HatchPatternData.Add(vHPData);
with TsgCADImage(FsgPaintBox.Picture.Graphic) do
begin
vlayout:=converter.Layouts[0];
converter.Loads(vhatch);
vlayout.AddEntity(vhatch);
fsgpaintbox.repaint;
end;
end;
For example I want to move just 1 vertex, or maybe move the whole hatch x units to the left.
but for example
vpoly.Points[0].X := vpoly.Points[0].X-30;
does not work, because X is read only
color I can change it, just do vhatch.color:=clNavy; fsgpaintbox.repaint;
How can I do it?
thank you
Alan