Subscribe to this thread
Home - General / All posts - Run a query on manually selected objects
menicoll6 post(s)
#20-Mar-17 19:51

I manually select a number of lines in a drawing, by clicking on the with the mouse.

I then want to create a list of all the IDs of the selected lines.

E.g. I'd like to run a query like: SELECT ID FROM <selection>

How do I do that?


230 post(s)
#20-Mar-17 20:00

select [ID] from [Drawing] where [Selection (I)]

8,009 post(s)
#21-Mar-17 02:00

It's also worth being aware of the (possible) effect of writing a query where ID values are returned as the first (or only) column in the result table. Even though it has no effect in this particular case (see below).

The behaviour is governed by the setting Tools > Options > Miscellaneous > Automatically select query records.

If the setting is enabled, then running a query that returns the IDs of drawing objects in the first column will cause the corresponding drawing objects to become selected (just as if they had been manually selected in the GUI).

(This has nothing to do with the SQL word SELECT--the correspondence with selection in the GUI is there, but it is a red herring.)

The reason why automatic selection has no effect in this case is that you are listing IDs for objects that are already selected--so, no change.

By contrast, assuming that the option is enabled, the complementary query

SELECT [ID] FROM [Drawing] WHERE NOT [Selection (I)]

will list the IDs of all unselected objects--and then cause those objects to become selected in the drawing--and all other objects to become unselected. So the selection is inverted.

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.