Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TransCAD 7 Help
Home / Welcome to GISDK Help
// Define the fields in the network as length and travel time. The
// first element in the array is the field name you assign in the
// network. The second and third elements are the field names in
// the highway database in the forward and reverse directions.
linkflds = {{"Length", line_layer+".Length", line_layer+".Length"},
{"[Travel Time]", line_layer+".[Travel Time]",
line_layer+".[Travel Time]"}}
// Share the network as you will need it in other macros in this file.
shared net
mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017
Lesson 2: Adding a Toolbox Página 2 de 6
mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017
Lesson 2: Adding a Toolbox Página 3 de 6
mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017
Lesson 2: Adding a Toolbox Página 4 de 6
return()
end
// Calculate the shortest path between the subject and target point
// using the first network field (distance). Only do this if the
// two nodes are not the same, otherwise, network_distance = 0.
// Also, gather the list of link IDs and directions that form the
// best network path.
if node1 <> node2 then do
sp = ShortestPath(net, {node1, node2}, 1, )
network_distance = sp[1]
links = sp[2]
directions = sp[3]
end
else
network_distance = 0
// Add data to the output array. To add data from a current record
// for a layer use a "field specification", which is the layer name
// in a variable + "." + field name, e.g. layer.city, not
// Place.city.
data[i]={network_distance, distance, search_layer.city,
search_layer.state, target_point, links, directions}
SetLayer(search_layer)
end // end of record handles loop
// Reset the layer and return the data array to the calling program
SetLayer(curr_layer)
return(data)
EndMacro
mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017
Lesson 2: Adding a Toolbox Página 5 de 6
Note: This updated macro includes an intentional typo on line 29 (an extra close parenthesis in the RunDbox()
command), to show you what happens when GISDK encounters a syntax error during compilation. Let’s go ahead and
compile the new version.
2. From TransCAD, click in the GISDK Toolbox to display the Compile File dialog box.
3. From the GISDK\SAMPLES folder, choose the file named LESSON2.RSC and click Open.
GISDK compiles the file. When the GISDK compiler encounters a syntax error, it creates an error file listing each error
that was encountered. The error file has the same name as the resource file and an extension of .ERR, and is always
placed in the same folder as the resource file itself. GISDK also displays the contents of the error file. (If you don’t see
the error message, it is possible that someone else may already have run this tutorial and fixed the typo.)
For those of you who use a programmers’ editor, the error file is in the standard format that is created by most
compilers, so you can hot-key through the error and resource files.
5. Click in the GISDK Toolbox to display the Compile File dialog box.
Note that GISDK compiles programs that are stored in files. This means that you must save your file using your text
editor program before you can compile and run it with GISDK. Note also that you do not actually need to be running
your text editor to compile or run a GISDK program. However, if you get into the habit of running GISDK and your text
editor at the same time, you’ll find you can modify your files and compile them very efficiently.
2. Click in the GISDK Toolbox to display the Test an Add-In dialog box.
5. Click OK. The add-in starts running and displays the "Get Best Route" toolbox in the center of the screen.
6. Click the Click on Map tool , then click on the map within 5 miles of a place. The add-in displays the arrays of
data for the nearest points.
7. Change the search distance to 1 mile and click over a mile away from any places. The add-in displays the "no
mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017
Lesson 2: Adding a Toolbox Página 6 de 6
points" message.
8. Click the X in the upper right hand corner to close the toolbox.
You have proven that the toolbox is working. Again, leave the map open. You’ll be using it again in a few minutes.
mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017