Jump to content

Getting error message "exceeded maximum number of selection sets"


Baber62

Recommended Posts

Need assistance with the code below, using it to toggle my viewports (open and close). However, after a few times of using it throws up the message "exceeded maximum number of selections" and doesn't do nothing resulting in me having to close down and restart AutoCAD. Not sure if it this routine which is doing it but when I select a grip and try to move it grip turns red and stays in same position.

 

; Toggle the "Display Locked" Variable of selected viewports based on the first view port selected

(defun c:vplocktoggle (/ Ename ss )
 (princ "\nSelect Viewport...")
 ;Get selection set, allow only viewports
 (setq ss (ssget '((0 . "viewport")))) 
 (if (IsVpLocked (setq Ename (ssname ss 0)))
   ;Viewport is locked.  Run Unlock commands
   (progn
     (princ "\nViewport selected is Locked")
     ;Unlock viewport
     (command "mview" "Lock" "OFF" ss "")
     ;Change viewport color to red to indicate it is Unlocked
     (command ".change" ss "" "p" "c" "1" "")
     (princ "\nViewport is now Unlocked")
   )
   ;Viewport is unlocked. Run Lock commands
   (progn
     (princ "\nViewport selected is Unlocked")
     ;Lock viewport
     (command "mview" "Lock" "ON" ss "")
     ;Change viewport color to ByLayer to indicate it is Locked
     (command ".change" ss "" "p" "c" "bylayer" "")
     (princ "\nViewport is now Locked")
   )
 )
 (princ)
)


; Return: T if locked, Nil otherwise
(defun IsVpLocked (Ename)
(eq 16384 (logand 16384 (cdr (assoc 90 (entget Ename)))))
)

Link to comment
Share on other sites

Interesting issue, could you provide more assistance by running this code and post the result here?

(defun C:DumpSSets ( / SSets )
(setq SSets (vla-get-SelectionSets (vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-dump-object SSets T)
(princ)
) (vl-load-com) (princ)

Link to comment
Share on other sites

The following is from help.

 

The selected objects are highlighted only when ssget is used with no arguments. Selection sets consume AutoCAD temporary file slots, so AutoLISP is not permitted to have more than 128 open at one time. If this limit is reached, AutoCAD cannot create any more selection sets and returns nil to all ssget calls. To close an unnecessary selection set variable, set it to nil.
Link to comment
Share on other sites

@Hippe013:

Since ss is a local variable its value will be nil when the function finishes. So I doubt if this will solve the problem. Maybe some other function is the culprit.

Related:

https://www.theswamp.org/index.php?topic=48908.msg540453#msg540453

 

Thanks all will get back to you after the weekend as I am on site currently.

Link to comment
Share on other sites

Hi Grrr,

 

Here's the result from running the code that you provided:

 

Command: DUMPSSETS

; IAcadSelectionSets: The collection of all selection sets in the drawing

; Property values:

; Application (RO) = #

; Count (RO) = 0

; Methods supported:

; Add (1)

; Item (1)

Command:

Link to comment
Share on other sites

Try leaving the VLIDE window open whilst you work on a drawing, ensuring that the Debug > Break on Error option is enabled (as described here); then, when the error is encountered, go to Debug > Last Break Source to identify the cause.

Link to comment
Share on other sites

Hi Grrr,

 

Here's the result from running the code that you provided:

 

Command: DUMPSSETS

; IAcadSelectionSets: The collection of all selection sets in the drawing

; Property values:

; Application (RO) = #

; Count (RO) = 0

; Methods supported:

; Add (1)

; Item (1)

Command:

 

Thanks,

Damn I thought/expected that the SS collection would act as the "trash" container that would need to be empten, but I was wrong.

Meaning that the "Count" property would have some high value.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...