Exceeded Maximum Selection Sets in a .Net / Lisp Combo

Exceeded Maximum Selection Sets in a .Net / Lisp Combo

Anonymous
Not applicable
687 Views
5 Replies
Message 1 of 6

Exceeded Maximum Selection Sets in a .Net / Lisp Combo

Anonymous
Not applicable

First of all, I know what I am doing is not practical, but it is necessary Smiley Very Happy

 

Scenario
I have a production lisp routine that uses .Net API's to bolster its functionality. During some tasks (primarily large models), I may use these routines a LOT. Eventually it starts spitting out "maximum number of selection sets" errors. A Close/Save on the drawing and re-opening it does resolve the issue just fine, but these are frequently very large drawings that take some time to save/close/open. Ultimately I really just want to squash the bug moving forward!

 

LISP

Within the lisp routines I am localizing the SelectionSet variables and for good measure I am setting those variables to Nil when I am done with them. In addition to that I am calling the (GC) function directly after nulling those variables. Couple more things to note are the Document/SelectionSets VLA object has a Count of zero and the manual act of (setq ss (ssget)) would actually put a SelectionSet into the ss variable. So, at this point I don't think the problem technically has anything to do with lisp....

 

.NET

The SelectionSet is typically provided by lisp in a ResultsBuffer to the .Net functions. From there I convert those TypedValues to actual Selection Sets. Once I have completely finished working with that .Net SelectionSet I immediately call the Dispose() method on it; every time..... I didn't find any kind of SelectionSet Manager while using the search features of the Visual Studio Object Browser. So, at this point I really don't know how to clean house more than I currently am.

 

Anybody have any ideas?

 

FYI: I did already see the other Maximum SS thread

0 Likes
688 Views
5 Replies
Replies (5)
Message 2 of 6

BKSpurgeon
Collaborator
Collaborator

.NET

My understanding is that calling .Dispose() doesn't actually dispose the object right away, but marks it ready for disposal - and the garbage collector release those resources when it sees fit. which might be today, or next Christmas.

 

I cannot solve the fundamental problem - because i don't know the intriciate internal workings of AutoCad, but I might suggest something which you might not have previously considered:

 

  • Why not store the selections in a more persistent form: XML, JSON etc - that way you can have a million selection sets if you want. use the object's handle to refer to the object. You'll have to store and read but there are libraries that are readily available, and it might alleviate the immediate problem somewhat.
  • Or perhaps you could redesign your code to more efficiently use resources? 

 

Im afraid those are the only things i can suggest.

 

good luck. would be interested to hear the solution if you do manage to find it.

 

 

 

 

 

Message 3 of 6

Anonymous
Not applicable

BK, you have an interesting way of thinking and I was certainly considering some home grown version of your brilliant alternative if I couldn't find the root of the problem.

 

What you did do is have me digging super deep into typed values to see if there was another way to get to the "selected object" without actually casting it into a SelectionSet type and that was a cool exercise. I tried just about every version of enumerating I could muster, but eventually it was me bypassing everything to see if just sending (many) selection sets into a lisp function in the first place was the source of the problem..... Then I found it Smiley Frustrated

 

The source of the problem was (one of) my return results buffers. I was creating my own typed value of 5007 SelectionSet and sending that back as my function result. After creating that typed value I was indeed disposing the original selection set, but it apparently didn't matter....

 

Resolution: NEVER send a typed value of type SelectionSet back in a result buffer!!! AutoCAD will not release the reference even when it gets Nil'd on the receiving lisp end. So, I just decided to return a list of ObjectID's (enames) and used (Acet-List-To-SS) to quick convert it into a selection set that lisp could continue operating with.

0 Likes
Message 4 of 6

kerry_w_brown
Advisor
Advisor

 


JHoward_HOB wrote:

 

< .. >

 

The source of the problem was (one of) my return results buffers. I was creating my own typed value of 5007 SelectionSet and sending that back as my function result. After creating that typed value I was indeed disposing the original selection set, but it apparently didn't matter....

 

Resolution: NEVER send a typed value of type SelectionSet back in a result buffer!!! AutoCAD will not release the reference even when it gets Nil'd on the receiving lisp end. So, I just decided to return a list of ObjectID's (enames) and used (Acet-List-To-SS) to quick convert it into a selection set that lisp could continue operating with.


JHoward_HOB,

Would you please do us all a favour and post a project with the minimum working code to demonstrate the issue you describe.

I would expect that someone from AutoDesk will pass the issue to their technical people. ( Perhaps it could be passed via any ADN contacts you have).

If the situation you outline can be confirmed/reproduced consistently, that may go a long way towards getting the issue fixed.

 

Regards,

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 5 of 6

Anonymous
Not applicable

Well, this is a production routine, but I can probably whip something up that will replicate the problem. I have some tight deadlines on a project to worry about for a while, but I will put that on my to do list.

0 Likes
Message 6 of 6

BKSpurgeon
Collaborator
Collaborator

for those looking at this post in future:

 

http://adndevblog.typepad.com/autocad/2012/08/lispfunction-examples-for-autolisp-to-net.html

 

it seems that Gilles had suggested the very same solution - if you read the comment at the bottom of the link. 

 

HTH

 

0 Likes