Another post for the really hard core users out there.
Developers can never fully predict what their users are going to need, but we can figure out a way to let users solve their own problems. One of the ways we do that is by adding extensibility to the product, and one great way to extend any product is through scripting.
The scripting feature in TrueNorth has just been added!
Scripting in TrueNorth is done through coding in C#. The underlying product is written in C#, so it’s very easy to read, compile, and execute a file or several files of code. An example of a script written for TrueNorth is below; it loads, writes out the parameters, prompts the user for a file, and loads it.
The “Controller” object is how the script accesses the functionality of TrueNorth. The Controller contains all of the functionality of TrueNorth, including loading and saving all file formats, drawing, printing, panning, zooming, and examining the maps, layers and features that are currently loaded.
Expect more news on this feature in the future as we develop the documentation.
using System; using System.Windows.Forms; using TrueNorth.Script; namespace TrueNorth.ScriptTest { public class Script : ScriptBase { public override int Execute(string[] args) { foreach (var arg in args) Console.WriteLine(arg); if (this.Controller!=null) Console.WriteLine("The controller looks OK"); try { OpenFileDialog ofd = new OpenFileDialog() { Title = "Open File" }; if (ofd.ShowDialog(this.Form) != DialogResult.OK) Console.WriteLine("Script cancelled"); Controller.OpenFile(ofd.FileName); Console.WriteLine("Script finished"); } catch (Exception ex) { MessageBox.Show(string.Format("Error:\r\n{0}", ex)); } return 1; } } }
[…] the map footprints were placed, we wrote a script to iterate through them, and print reports for each one, exporting it to PDF. The PDFs were […]
[…] the map footprints were placed, we wrote a script to iterate through them, and print reports for each one, exporting it to PDF. The PDFs were […]