.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get current selection

5 REPLIES 5
Reply
Message 1 of 6
fyathyrio8
2127 Views, 5 Replies

Get current selection

This should be pretty simple - but I haven't been able to find the answer anywhere.

How can I get the current selection set? Editor.GetSelection() will prompt for a new selection, but I would like to check if the user has selected objects before running the command.

Thanks,
Mike
5 REPLIES 5
Message 2 of 6

First, you have to have the right command flag(s) set. If you only want to consume the PickFirst Set, and want the selection to clear after your command, then you set the UsePickSet Command Flag. If you want to Add to or Modify the Pickset, leaving the grips or selection on after your command then you use the flag Redraw.

If you do not use either of those flags, then the pickfirst set is cleared immediately when you enter your command.

After that, you can do:
Dim psr As PromptSelectionResult = Editor.SelectImplied

which will give you the pickfirst set if there is one and do nothing if there is not.

or you can do:
Dim psr As PromptSelectionResult = Editor.GetSelection

which will give you the pickfirst set if there is one without prompting the user, or it will prompt the user for selection if there is no pickfirst.
Dave O.                                                                  Sig-Logos32.png
Message 3 of 6
Anonymous
in reply to: fyathyrio8

Add the CommandFlags.UsePickSet flag to your CommandMethod attribute,
and GetSelection() will return the pickfirst selection or prompt for a selection
if there's no pickfirst selection.

Do NOT use the SelectImplied() method, because Autodesk screwed up
when they revised it in AutoCAD 2009, and as a result, it no longer sets the
returned selection set to the Previous selection set (as the user expects).

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6343685@discussion.autodesk.com...
This should be pretty simple - but I haven't been able to find the answer
anywhere.

How can I get the current selection set? Editor.GetSelection() will prompt for
a new selection, but I would like to check if the user has selected objects
before running the command.

Thanks,
Mike
Message 4 of 6
fyathyrio8
in reply to: fyathyrio8

[CommandMethod("mycommand", CommandFlags.UsePickSet)] and Editor.GetSelection() worked out perfectly.

Thanks for your help.
- Mike -
Message 5 of 6
gjmanuel
in reply to: fyathyrio8

I'm trying to check if a Selection Set exist...but I don't want to prompt the user if there isn't...Is there a way to do this?

 

Thanks for any guidance!

 

Gary

Message 6 of 6
Jeff_M
in reply to: gjmanuel

What version?

I know Tony said 2009 had a problem, but I've used the SelectImplied() method in 2010 without any issues that I've seen.

Jeff_M, also a frequent Swamper
EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost