In this article:
- Opening a Project, Adding a Source, and Saving the Project
- Opening a Project, Adding a Source and Creating a Project MPT
- Publishing an MPT File to SkylineGlobe Server
- Adding All Folder Files of a Specific Type to a Project
- Handling Errors
Opening a Project, Adding a Source, and Saving the Project
This example demonstrates how to open an existing project, add a source, and then save the project and exit the TerraBuilder application. This example uses the TerraBuilder70 (OpenProject, ExitWhenFinished), TBLayers70 (InsertLayer) and TBProject70 (Save) properties and methods.
var project = TerraBuilder.OpenProject("C:\\Users\\Administrator\\Documents\\USA\\USA.tbp");
var layer = project.layers.InsertLayer("C:\\Users\\Administrator\\Documents\\imagery\\NewYork.tif", "Imagery");
project.Save();
TerraBuilder.ExitWhenFinished();
Opening a Project, Adding a Source and Creating a Project MPT
This example demonstrates how to open an existing project, add a source, and create a project MPT. This example uses the TerraBuilder70 (OpenProject), TBLayers70 (InsertLayer) and TBProject70 (CreateMPT, Save) properties and methods.
var project = TerraBuilder.OpenProject("C:\\Users\\Administrator\\Documents\\USA\\USA.tbp");
var layer = project.layers.InsertLayer("C:\\Users\\Administrator\\Documents\\imagery\\NewYork.tif", "Imagery")
project.CreateMPT();
project.Save();
Publishing an MPT File to SkylineGlobe Server
This example demonstrates how to publish an MPT file to SkylineGlobe Server. This example uses the TerraBuilder70 (OpenProject, SGServer), TBSGServer70 (Connect), and TBProject70 (PublishMPTToSG) properties and methods.
var project = TerraBuilder.OpenProject("C:\\Users\\Administrator\\Documents\\USA\\USA.tbp");
TerraBuilder.SGServer.Connect("http://www.skylineglobe.com/SG", "UserJon", "SamplePass");
project.PublishMPTToSG();
Adding All Folder Files of a Specific Type to a Project
This example demonstrates how to use the File System Object to add all files of a certain file type in a folder to a project. This example uses the TerraBuilder70 (OpenProject, GetFileSystemObject) and TBLayers70 (InsertLayer) properties and methods.
var project = TerraBuilder.OpenProject("C:\\Users\\Administrator\\Documents\\USA\\USA.tbp ");
var FsObject=TerraBuilder.GetFileSystemObject();
var folder = FsObject.GetFolder("C:\\Users\\Administrator\\Documents\\imagery");
fc = new Enumerator(folder.files);
for (; !fc.atEnd(); fc.moveNext())
{
if (myFsObject.GetExtensionName(fc.item().Name) == "sid")
project.Layers.InsertLayer(fc.item().Path, "Imagery")
}
Handling Errors
This example demonstrates how to handle errors using JavaScript’s try and catch statements.
try
{
TerraBuilder.OpenProject("C:\\DoesNotExist.tbp");
}
catch(error)
{
alert(error.message);
}