Syntax

code

Function: GetPropertyResultAsFloat(ItemPath, PropertyName: String; Default: Double = 0): Double;

Description

Attempts to return the given property value as a floating point value. If the calculated property value can not be converted, the value supplied by Default is returned.

Code Reference

  • 1. Navigate to Plugin Store->Tool Manager and create a new Plugin
  • 2. Set the plugin type to Script Code and open the Editor
  • 3. Copy Code into the editor
  • 4. press run

code

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

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