Baber62 Posted November 23, 2016 Posted November 23, 2016 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))))) ) Quote
Grrr Posted November 23, 2016 Posted November 23, 2016 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) Quote
Hippe013 Posted November 23, 2016 Posted November 23, 2016 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. Quote
Roy_043 Posted November 24, 2016 Posted November 24, 2016 @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 Quote
Baber62 Posted November 24, 2016 Author Posted November 24, 2016 @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. Quote
Baber62 Posted November 28, 2016 Author Posted November 28, 2016 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: Quote
Lee Mac Posted November 28, 2016 Posted November 28, 2016 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. Quote
Grrr Posted November 28, 2016 Posted November 28, 2016 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. Quote
Recommended Posts
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.