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

SelectionSet from ObjectIds

13 REPLIES 13
Reply
Message 1 of 14
HJohn1
2632 Views, 13 Replies

SelectionSet from ObjectIds

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? 

13 REPLIES 13
Message 2 of 14
DiningPhilosopher
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...

Message 3 of 14
amanero
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
Message 4 of 14
HJohn1
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.

Message 5 of 14
BlackBox_
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. 

 



"How we think determines what we do, and what we do determines what we get."

Message 6 of 14
HJohn1
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.

Message 7 of 14
jeff
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
Message 8 of 14
DiningPhilosopher
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).

Message 9 of 14
Alexander.Rivilis
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! Smiley Very Happy

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 10 of 14
BlackBox_
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! Smiley Very 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



"How we think determines what we do, and what we do determines what we get."

Message 11 of 14
HJohn1
in reply to: DiningPhilosopher

DP thank you.  Unexpectedly I manage to get something working.  I am not sure how it works but it works.  I am only using the command line wrapper to create polylines.  This code works on AutoCAD 2012 vanilla, perhaps it did not work before because I was running the code in AutoCAD 2012 Mechanical.  I am having an issue with the DIMSCALE for dimensions in AutoCAD 2012 Mechanical, so may be the problem with selectionsets is just in AC Mech.

 

SS = SelectionSet.FromObjectIds(ids)

Ed.SetImpliedSelection(SS)

Ed.GetSelection()

CommandLine.Command("_.PEDIT", "_m", "_p", "", "_y", "_join", "", "")

 

 

Message 12 of 14
happyliulin1015
in reply to: amanero

I used this function SetImpliedSelection() in my programme,but there was something wrong on this function use:when the programme run at this function,the cad seemed busy on doing something background as it took a long time to finish the background transaction till it come back on my programme,and meanwhile on the cad screen the result I wanted had been got,but the cad was under no response till many seconds was gone,that's why?

the codes is below:

using (DocumentLock docloc = AcApp.DocumentManager.MdiActiveDocument.LockDocument())
using (Transaction trans = AcApp.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
{
AcApp.DocumentManager.MdiActiveDocument.Editor.SetImpliedSelection(new ObjectId[0]);
AcApp.DocumentManager.MdiActiveDocument.Editor.SetImpliedSelection(targetIds);
trans.Commit();
}

 

and I have added the codes below in front of the fuction which used SetImpliedSelection()

[CommandMethod("9527", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]

Message 13 of 14

 

I don't see any need for the first call to SetImpliedSelection().

 

 


@happyliulin1015 wrote:

I used this function SetImpliedSelection() in my programme,but there was something wrong on this function use:when the programme run at this function,the cad seemed busy on doing something background as it took a long time to finish the background transaction till it come back on my programme,and meanwhile on the cad screen the result I wanted had been got,but the cad was under no response till many seconds was gone,that's why?

the codes is below:

using (DocumentLock docloc = AcApp.DocumentManager.MdiActiveDocument.LockDocument())
using (Transaction trans = AcApp.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
{
AcApp.DocumentManager.MdiActiveDocument.Editor.SetImpliedSelection(new ObjectId[0]);
AcApp.DocumentManager.MdiActiveDocument.Editor.SetImpliedSelection(targetIds);
trans.Commit();
}

 

and I have added the codes below in front of the fuction which used SetImpliedSelection()

[CommandMethod("9527", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]


 

Message 14 of 14

Dear ActivistInvestor:

As your suggestions,i have deleted the first call to that function,but the situation is not improved at all.it is not a bug of the CAD,is it? i've been upset very much,and have to give up using the function.

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