.NET

Reply
Distinguished Contributor
HJohn1
Posts: 170
Registered: ‎09-26-2008
Message 1 of 11 (397 Views)

SelectionSet from ObjectIds

397 Views, 10 Replies
05-30-2013 07:46 AM

I can create a SelectionSet by using SelectionFilters and the Editor select functions.  When I create SelectionSets this way I can use them in a command by calling the Previous selection.  However, if I create entities, store their objectids and then create a SelectionSet by using the SelectionSet.FromObjectIds function, when I call the previous selection on a command nothing is selected.  Is there a way to create a SelectionSet from ObjectIds that would be available to commands? 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 2 of 11 (374 Views)

Re: SelectionSet from ObjectIds

05-30-2013 01:34 PM in reply to: HJohn1

The Previous selection set is created by acedSSGet(), which isn't used by FromObjectIds(), so there is no native selection set in that case.

 

The only way to solve the problem is to avoid the SendStringToExecute() kludge-o-rama and use the Editor's RunCommand() method, if you're targeting releases that support it.

 

This post has a C# wrapper for the RunCommand method:

 

http://forums.autodesk.com/t5/NET/Send-Command-Executes-after-exiting-command-method/m-p/3882929/hig...

Valued Contributor
amanero
Posts: 75
Registered: ‎12-03-2003
Message 3 of 11 (346 Views)

Re: SelectionSet from ObjectIds

05-31-2013 03:59 AM in reply to: HJohn1

Hello,

 

Another aproach is to literally select the entities usin the Editor's method "SetImpliedSelection" which receives an array of ObjectId and selects the entities in the drawing.

Luis Alberto Manero, Geograma.com
Distinguished Contributor
HJohn1
Posts: 170
Registered: ‎09-26-2008
Message 4 of 11 (339 Views)

Re: SelectionSet from ObjectIds

05-31-2013 05:55 AM in reply to: DiningPhilosopher

DP thank you.  I am not clever enough to figure how to how about passing a selection created from objectids to a command using the runcommand wrapper.  I am using a great command wrapper created by Tony Tanzillo which allows me to execute commands.  To select entities for command I was just creating selectionsets and calling the previous selection.  However, now that I am creating the entities and I know their objectids I thought that there was no need to select them again, but may be I am wrong.

Amanero, thanks to you too. I tried that and the entities are selected but when I call the previous selectionset nothing is selected.

Distinguished Mentor
BlackBox_
Posts: 785
Registered: ‎02-25-2013
Message 5 of 11 (333 Views)

Re: SelectionSet from ObjectIds

05-31-2013 07:03 AM in reply to: HJohn1

HJohn1 wrote:

DP thank you.  I am not clever enough to figure how to how about passing a selection created from objectids to a command using the runcommand wrapper.  I am using a great command wrapper created by Tony Tanzillo which allows me to execute commands. 


... This is the funniest thing I've read all day... And for that, I thank you. 

 



"Potential has a shelf life." - Margaret Atwood


Autodesk Exchange Apps ~ Autoloader ~ AutoCAD Security


AutoCAD® 2014, and Civil 3D® 2014 Certified Professional ~ Autodesk® Authorized Developer

Distinguished Contributor
HJohn1
Posts: 170
Registered: ‎09-26-2008
Message 6 of 11 (324 Views)

Re: SelectionSet from ObjectIds

05-31-2013 08:23 AM in reply to: BlackBox_

Hey BlackBoxCAD I am so glad I made your day a bit happier.  On the other hand, may be I did not explained myself clear enough.  I meant/intended to say that the suggested wrapper seem to execute commands perhaps the same way as Tony's and I don't know how to create the selectionset from the objectids and pass it to the command I am executing, so there is no difference to me.  I tried the impliedselection and it didn't work either.  So, after you finish laughing, take your time, could you please help me solve this issue.

Valued Mentor
jeff
Posts: 335
Registered: ‎05-12-2009
Message 7 of 11 (301 Views)

Re: SelectionSet from ObjectIds

05-31-2013 05:09 PM in reply to: HJohn1

You just pass the selectionset as one of the arguments to RunCommand that DinningPhilosopher mentioned.

 

The CommandLine class Tony posted a while back was a example to show how to call acedcmd from managed code.

 

The RunCommand mentioned does the same thing as Tony example,

 

Tony was gracious enough to add the most of the Result type codes in example, but I think you might have to add Result type for a SelectionSet. They are listed in the docs.

 

It would take same amount of time to add SelectionSet result code to Tony's example as it would to copy and paste RunCommand example DinningPhilosopher mentioned.

 

I can't tell you which one would be better because DinningPhilosopher is just as talented and knowledgeable as Tony.

 

Could you imagine how great it would be if DinningPhilosopher & Tony got together and wrote a book, but the rumor is they do not like each other and do not get along.

 

 

You can also find your answers @ TheSwamp
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 8 of 11 (292 Views)

Re: SelectionSet from ObjectIds

05-31-2013 06:34 PM in reply to: HJohn1

The wrapper that calls RunCommand() is a drop-in replacement for the wrapper I wrote that uses acedCmd().

 

The difference is that the RunCommand() method supports selection set arguments, while acedCmd() does not.

 

Use the wrapper for RunCommand() and just pass the selection set as an argument, exactly as you would using the LISP (command) function (with a "" after it to end object selection).

Moderator
Alexander.Rivilis
Posts: 1,449
Registered: ‎04-09-2008
Message 9 of 11 (282 Views)

Re: SelectionSet from ObjectIds

06-01-2013 08:47 AM in reply to: jeff

jeff wrote:

... Could you imagine how great it would be if DinningPhilosopher & Tony got together and wrote a book, but the rumor is they do not like each other and do not get along...


Gorgeous joke! :smileyvery-happy:


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Distinguished Mentor
BlackBox_
Posts: 785
Registered: ‎02-25-2013
Message 10 of 11 (258 Views)

Re: SelectionSet from ObjectIds

06-01-2013 03:18 PM in reply to: HJohn1

HJohn1 wrote:

Hey BlackBoxCAD I am so glad I made your day a bit happier... So, after you finish laughing, take your time, could you please help me solve this issue.


I assure you that my comment has nothing to do with the difficulty you're experiencing, and had everything to do with your references to both DiningPhilosopher's, and Tony Tanzillo's different approaches.

 

This is why your comment was funny to me:


Alexander.Rivilis wrote:

jeff wrote: 

... Could you imagine how great it would be if DinningPhilosopher & Tony got together and wrote a book, but the rumor is they do not like each other and do not get along...


Gorgeous joke! :smileyvery-happy:


 ... As to solving your issue, you're in very capable hands given the talent already participating in this thread; it would be a disservice, if not a distraction, for me to attempt to contribute at this time.

 

Cheers



"Potential has a shelf life." - Margaret Atwood


Autodesk Exchange Apps ~ Autoloader ~ AutoCAD Security


AutoCAD® 2014, and Civil 3D® 2014 Certified Professional ~ Autodesk® Authorized Developer

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!