Script Buttons

Top  Next

SCRIPT~1_img1

Script Buttons

 

SCRIPT~1_img2

 

Script Buttons is a feature available in all our spatial products that allows you to write your own scripts for various buttons, with various functions, you would like to create. Within the spatial pane itself you are able to add your own tools. The following is the layout of the dialogue it brings up:

 

SCRIPT~1_img3

 

To import already created scripts you would use the Import button, that is what I will be doing in this example:

 

SCRIPT~1_img4

 

SCRIPT~1_img5

 

As you can see my scripts have now been imported.

 

Now, I will start by going over the Button grid, which is where you set up the buttons. In the first row I have set up a button called Rectangle which will draw rectangles of a predefined height and width when you click at a point in the scene. In the second row is the Rectangle Settings button that I have set up which will bring up a dialogue where you can set the parameters of the rectangle:

 

SCRIPT~1_img6

 

The Category is what kind of tool it is; you can select from the dropdown list or type in your own:

 

SCRIPT~1_img7

 

The Page is what tab you would like the tool to appear in. You can select from existing tabs or type in your own to create a new tab:

 

SCRIPT~1_img8

 

The Caption is the name of the button which will be displayed. Language is what scripting language you would like to use, right now we only support JavaScript:

 

SCRIPT~1_img9

 

Image is where you can choose an image to be displayed next to the button, dropdown and then right click to load an image:

 

SCRIPT~1_img10

 

ToolTip is the tooltip you would like to be displayed for the button. Publish is whether you would like the button to be published when you are publishing Geoscope files. And Visible is whether you would like the button to be visible or not in the tab:

 

SCRIPT~1_img11

 

Now that I have set up these buttons here, if you go to your spatial pane you will see the buttons there:

 

SCRIPT~1_img12

 

Now, next we come to the script. When you select one of the buttons in the grid the corresponding script for the button comes up in the script box, or if there was no script for it you would write it in the box below making sure you first select the button in the grid. I have selected the Rectangle button and its associated script has come up:

 

SCRIPT~1_img13

 

The script created for this draw rectangle button goes like this:

 

SCRIPT~1_img14

 

SCRIPT~1_img15

 

Then when I select my Rectangle Settings button its associated script will come up. This script creates the dialogue box where I can set the parameters for my rectangle. And its script goes like this:

 

SCRIPT~1_img16

 

Let’s now look at these buttons in action. First, I click on the Rectangle Settings button and set the parameters for my rectangle, which will be 500 metres width and 1000 metres height:

 

SCRIPT~1_img17

 

SCRIPT~1_img18

 

I can then go ahead and click my Rectangle button and then click on the point on the scene where I would like to have a rectangle, of the dimensions set, drawn:

 

SCRIPT~1_img19

 

I clicked the tool but then got this error message because I don’t have any active layer set for the rectangle to be drawn to. This is what I set up in my script to happen if no active layer was set:

 

SCRIPT~1_img20

 

I will therefore set an active layer. I then click on the tool again and now it is ready to work as shown in the status bar in the spatial pane (a prompt which was set up to happen in the script as well):

 

SCRIPT~1_img21

 

I click in my scene at the desired point and my rectangle has been drawn:

 

SCRIPT~1_img22

 

I am able to export these scripts using the Export Selected button which will export the selected button’s script, I browse to where I’d like to save it and it will be saved as a .scripts file:

 

SCRIPT~1_img23

 

SCRIPT~1_img24

 

To delete any of the buttons you created select the button in the grid and click Delete Selected:

 

SCRIPT~1_img25

 

You can view and manage the events that have happened in relation to a specific script by clicking on the View Events button which will bring up a Handlers dialogue with the different events; here you can clear any handlers currently active (which will be shown by a tick next to it). In here you can see I have a handler for the Click event which is when I click in my scene for the rectangle to be drawn, and the handler is the DrawRect function that I set up in my script:

 

SCRIPT~1_img26

 

SCRIPT~1_img27

 

The Check Syntax button will do a check of the syntax of your script and if good will give the following message:

 

SCRIPT~1_img28

 

SCRIPT~1_img29