procedure TForm1.GetSetPoint(sender: TObject);
var
ps: IPlanSwift;
area,sect: IItem;
xs,cx,cy: Extended;
pgw,pgh,p1x,p1y,p2x,p2y,p3x,p3y,p4x,p4y: Extended;
begin
//Create the planswift interface
ps := coPlanswift.Create;
//Create a new Area Item
area := ps.GetItem('Job\Takeoff');
area := area.NewItem('Area','SetPointArea');
//Add a Section to the new Area
sect := area.NewSection('SetPoint Area Section');
//Get the page width and height
pgw := ps.GetPropertyResultAsInteger(ps.Selectedpage.guid,'PageWidth',0);
pgh := ps.GetPropertyResultAsInteger(ps.SelectedPage.guid,'PageHeight',0);
//Get the scale of the page... needed to draw area to scale
xs := ps.GetPropertyResultAsFloat(ps.SelectedPage.guid,'ScaleX',0);
//Get the Center X and Y pos of the page
cx := pgw /2;
cy := pgh /2;
//Set First point of area of Square
p1x := cx - 20 * xs;
p1y := cy - 10 * xs;
sect.NewPoint(p1x,p1y);
// Add Second Point
p2x := cx + 10 * XS;
p2y := p1y;
sect.NewPoint(p2x,p2y);
//Add Third Point
p3x := p2x;
p3y := cy + 10 * xs;
sect.NewPoint(p3x,p3y);
//Add Fourth Point
p4x := cx - 10 * xs;
p4y := p3y;
sect.NewPoint(p4x,p4y);
//Show Message to fix first point to create a true square box
ShowMessage('Now will fix the first point by using set point');
//Set the proper position of the first point
p1x := cx - 10 * XS;
// pass that point to planswift using setpoint
ps.SetPoint(sect.guid,0,p1x,p1y);
//Free Planswift
ps := nil;
end |