.NET

Reply
Valued Mentor
jeff
Posts: 321
Registered: ‎05-12-2009
Message 11 of 14 (79 Views)

Re: Failed to get selectionresult

08-30-2013 05:42 PM in reply to: greg

First off by changing one line of code in last example and tested it with looping 300 times and no problems.

 

I have to get going but and I have seen other people have problems that are similiar so will type up a better explanation and concepts to show what is happening.

 

I probably should rephrase the first sentence that I changed one line and no problems. It still a bad approach for the task and there are better ways but understanding why it is not a good approach helps to see what a better one would be.

 

If you want to start taking a look at what is going on look at methods 

with ILSPY or Reflector you see what they do, and notice calls to methods that are explained in docs -  acedSSGet, acedSSAdd, acedSSSetFirst, acedSSFree as they all play a role in it.

 

In the .NET API you actully never will use an instance of a SelectionSet object, one reason would be it is impossible since it is an abstract class.

 

You actually are using a SelectionSetDelayMarshalled object and there use to be a SelectionSetFullyMarshalled object but was removed in 2010 or 2011 or earlier.

 

Except for the SelectionSetDelayMarshalled constuctors that take ObjectIds as a argument, the other constructors pass the selection set to a internal class UnmanagedResources method AddSelectionSet which adds it to a key value pair collection, which passes it into constructor of a DisposableSelectionSet object.

 

 

I know that is a little jumbled but will make a better explanation later tonight or tommorrow .

 

Anyway the only change made was commented out first line and added second.

                    'Autodesk.AutoCAD.Internal.Utils.SelectObjects(ObjectIDs)
                    ed.SetImpliedSelection(ObjectIDs)

 

 

 

 

 

 

 

You can also find your answers @ TheSwamp
Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 12 of 14 (73 Views)

Re: Failed to get selectionresult

08-30-2013 06:27 PM in reply to: jeff

HI Jeff,

 

I greatly appreciate your time with your response.  You have indeed fixed my issue with that little change.  I am not sure I understand much in your message or why this one little change makes the difference but it does.  Perhaps I can figure out why someday.

 

Have a great weekend,

Valued Mentor
jeff
Posts: 321
Registered: ‎05-12-2009
Message 13 of 14 (67 Views)

Re: Failed to get selectionresult

08-30-2013 07:24 PM in reply to: greg

I will do post will explanation but the Utils.SelectObjects calls acedSSAdd(null,null,...) which creates a new selection set in each loop without a matching acedSSFree().

 

 

You can also find your answers @ TheSwamp
Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 14 of 14 (57 Views)

Re: Failed to get selectionresult

08-31-2013 04:21 AM in reply to: jeff

Okay, That makes a bit of sense to me.  Never would have thought about that when troubleshooting my code.  I looked at that line numerous times while troubleshooting but just wasnt sure what else to use.

 

Thanks so much for your help!  Greatly appreciated!

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community