georeference.org
Subscribe to this thread
Home - General / All posts - Refresh after Selections
njengler109 post(s)
#23-Dec-05 08:53

I am developing an add-in and have the following code (2 drawings, I want to select points that fall within an area created by a buffered line):

xQuery = theApplication.ActiveDocument.NewQuery("TempQuery", False) xQuery.Text = "SELECT * FROM [" + theStationDrawing + "], [" + theProfileDrawing + "] WHERE [" + theProfileDrawing + "].[Selection (I)] AND Contains(Buffer([" + theProfileDrawing + "].[ID],1000), [" + theStationDrawing + "].[ID]);"

xQuery.RunEx(True) xStations.Refresh() xProfiles.Refresh()

The selection is not updated in the map as expected. The query does work fine: if i run the query from the query window that is created in the project through this code, the selection is made and the map updates.

What am I missing to make the map update through my code?

Thanks

N

adamw


4,662 post(s)
#23-Dec-05 22:14

Selecting objects and records returned by a query is a purely UI thing, done for the user's convenience. You can turn it off in Tools - Options, Miscellaneous (uncheck the "Automatically select query records" option). To select objects returned by a query from within a script, convert a SELECT query into an equivalent UPDATE query which sets the [Selection (I)] column, eg:

--SQL

UPDATE (SELECT [Stations].[Selection (I)] FROM ... WHERE ...) SET [Selection (I)] = True;

Prior to running the above query, unselect all objects using:

--SQL

UPDATE [Stations] SET [Selection (I)] = False;

njengler109 post(s)
#26-Dec-05 12:03

Excellent, thanks adamw!

A further note for others using this SQL: If your SQL statement contains multiple tables you must explicitly reference the table from which the Selection(I) column is derived after the SET command.

i.e. [TableName].[Selection (I)] = True;

1 msec Copyright (C) 2007-2008 Manifold.net. All rights reserved.