Home -
General /
All posts - Refresh after Selections
|
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
|
|
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;
|
|
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;
|