Author Topic: Locked layer causes interface IAcadSelectionSet error  (Read 1086 times)

0 Members and 1 Guest are viewing this topic.

sovby

  • Mosquito
  • Posts: 9
Locked layer causes interface IAcadSelectionSet error
« on: September 28, 2020, 03:25:24 PM »
I have a routine that changes some colors on some entities and wblocks them out using a window selection. I found out that if there is a locked layer in the selection set i get this message.

** Error: Automation Error. Calling method Clear of interface IAcadSelectionSet failed **
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.

Has anyone had anything similar to this? If i unlock the layer everything is fine so it has something to do with the locked layer as far as i can tell

jtoverka

  • Newt
  • Posts: 127
Re: Locked layer causes interface IAcadSelectionSet error
« Reply #1 on: September 28, 2020, 03:29:13 PM »
What method are you using to change the colors?
Commands?
entmod?
vl-put-?

sovby

  • Mosquito
  • Posts: 9
Re: Locked layer causes interface IAcadSelectionSet error
« Reply #2 on: September 28, 2020, 03:52:30 PM »
Code - Auto/Visual Lisp: [Select]
  1. (cond (ss
  2.             (setq ass (vla-get-activeselectionset cdoc)
  3.                   dfile (strcat (getvar 'dwgprefix) dnme ".dwg")
  4.             );end_setq
  5.             (vlax-for itm ass (vlax-put itm 'color 7))
  6.             (vlax-invoke cdoc 'wblock dfile ass)
  7.             (setq dcnt (1+ dcnt) dnme (strcat dnme (itoa dcnt)))
  8.           )
  9.           (t (alert "Nothing Selected"))
  10.     )



EDIT (John): Added code tags.
« Last Edit: September 29, 2020, 03:23:16 PM by John Kaul (Se7en) »

jtoverka

  • Newt
  • Posts: 127
Re: Locked layer causes interface IAcadSelectionSet error
« Reply #3 on: September 29, 2020, 08:18:20 AM »
So I tried this with entmod and no errors are thrown, however, locked layers cannot be modified by any means AFAIK. You will have to unlock the layer within your code prior to modifying it.
Code: [Select]
((lambda ( / ss count i ent et)
  (if (setq ss (cadr (ssgetfirst)))
    (progn
      (setq count (sslength ss))
      (setq i 0)
      (while (< i count)
        (setq ent (ssname ss i))
        (setq et (entget ent))
        (entmod
          (subst
            '(62 . 7)
            (assoc 62 et)
            et
          )
        )
        (entupd ent)
        (setq i (1+ i))
      )
    )
  )
  (princ)
))