AccuGlobe Desktop 2007 Digital Data Technologies, Inc.

Sample 1

This sample uses the .NET System.Windows.Forms namespace to display a message box. The number of layers in the active map is displayed in the message box.
import clr
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import *

MessageBox.Show(ActiveMap.Layers.Count.ToString())


Sample 2

This sample turns on the map layer with a layer index of 0.
ActiveMap.Layers.Item(0).Visible = True
ActiveMap.Redraw()


Sample 3

Shows how to create a custom search dialog and perform an attribute query on a map layer. This example returns the selection as a recordset.
import clr
clr.AddReference('System.Drawing')
clr.AddReference('System.Windows.Forms')
clr.AddReference('DDTI.AccuGlobe.MapEngine')
 
from System.Windows.Forms import *
from System.Drawing import *
from DDTI.AccuGlobe.MapEngine.Layers import *
from DDTI.AccuGlobe.MapEngine.Layers.SupportingFiles import *
 
class LayerSearch(Form):
 
    def __init__(self):
        self.Text = 'Layer Search'
        self.Name = 'frmLayerSearch'
        label = Label()
        label.Text = "Criteria:"
        label.Location = Point(50, 50)
        label.Height = 24
        label.Width = 200
 
        button = Button()
        button.Text = "Search"
        button.Location = Point(50, 150)
 
        button.Click += self.buttonPressed
 
        self.text = TextBox()
        self.text.Location = Point(50, 75)
        self.text.Width = 150
        self.text.Height = 24
 
        self.Controls.Add(label)
        self.Controls.Add(button)
        self.Controls.Add(self.text)
 
    def buttonPressed(self, sender, args):
        layer = ActiveMap.Layers.Item(0)
        count = 0
        for record in layer.Records:
            count += 1
        MessageBox.Show('Searching %s records' % count)
        oFilter = DTFilter()
        oFilter.LeftOperand = 'NAME'
        oFilter.Predicate = Predicate.Equals
        oFilter.RightOperand = self.text.Text
 
        oQuery = DTQuery(oFilter)
 
        oRecords = DTRecords()
 
        oRecords = layer.ExecuteRecordsQuery(oQuery)
 
        MessageBox.Show('Found %s records' % oRecords.Count)
 
form = LayerSearch()
Form.ShowDialog(form)


Sample 4

Shows how to create a custom search dialog and perform an attribute query on a map layer. This example shows the results as selected on the map.
import clr
clr.AddReference('System.Drawing')
clr.AddReference('System.Windows.Forms')
clr.AddReference('DDTI.AccuGlobe.MapEngine')
 
from System.Windows.Forms import *
from System.Drawing import *
from DDTI.AccuGlobe.MapEngine.Layers import *
from DDTI.AccuGlobe.MapEngine.Layers.SupportingFiles import *
 
class LayerSearch(Form):
 
    def __init__(self):
        self.Text = 'Layer Search'
        self.Name = 'frmLayerSearch'
        label = Label()
        label.Text = "Criteria:"
        label.Location = Point(50, 50)
        label.Height = 24
        label.Width = 200
 
        button = Button()
        button.Text = "Search"
        button.Location = Point(50, 150)
 
        button.Click += self.buttonPressed
 
        self.text = TextBox()
        self.text.Location = Point(50, 75)
        self.text.Width = 150
        self.text.Height = 24
 
        self.Controls.Add(label)
        self.Controls.Add(button)
        self.Controls.Add(self.text)
 
    def buttonPressed(self, sender, args):
        layer = ActiveMap.Layers.Item(0)
        count = 0
        for record in layer.Records:
            count += 1
        MessageBox.Show('Searching %s records' % count)
        oFilter = DTFilter()
        oFilter.LeftOperand = 'NAME'
        oFilter.Predicate = Predicate.Equals
        oFilter.RightOperand = self.text.Text
 
        oQuery = DTQuery(oFilter)
 
        layer.ExecuteSelectionQuery(oQuery, True, True)
 
form = LayerSearch()
Form.ShowDialog(form)