Author Topic: Trapping Nentsel  (Read 2441 times)

0 Members and 1 Guest are viewing this topic.

Didge

  • Bull Frog
  • Posts: 211
Trapping Nentsel
« on: March 21, 2007, 08:01:26 AM »
I've coded the following to allow multiple entity selections from xrefs, I would like the loop to continue adding enames to the selection set until the user right clicks.

All works well except for one little annoyance, namely the loop also ends if the user left clicks on nothing by mistake.

Does anybody know of any other solutions to distinguish between a left and right mouse click?

Code: [Select]
(setq SS (ssadd))
(while (setq ENT (nentsel "\nSelect Objects."))
  (if (member (cdr (assoc 0 (entget (car ENT)))) (list "POLYLINE" "LWPOLYLINE" "LINE" "ARC" "CIRCLE" "ELLIPSE" "SPLINE"))
    (progn
      (redraw (car ENT) 3)
      (setq SS (ssadd (car ENT) SS))
    )
    (prompt "\nUnable to process selected object.")
  )
)
Think Slow......

whdjr

  • Guest
Re: Trapping Nentsel
« Reply #1 on: March 21, 2007, 08:30:42 AM »
Check out the "ErrNo" system variable.

Didge

  • Bull Frog
  • Posts: 211
Re: Trapping Nentsel
« Reply #2 on: March 21, 2007, 11:18:24 AM »
Thats fixed it, I didn't give ERRNO a second thought because I'd always believed that is was a read-only variable.

Many thanks Whdjr.

Code: [Select]
(setq SS (ssadd))
(setvar "ERRNO" 0)
(while (/= (getvar "ERRNO") 52)
  (if (setq ENT (nentsel "\rSelect Objects.                         "))
    (if (member (cdr (assoc 0 (entget (car ENT)))) (list "POLYLINE" "LWPOLYLINE" "LINE" "ARC" "CIRCLE" "ELLIPSE" "SPLINE"))
      (progn
        (redraw (car ENT) 3)
        (setq SS (ssadd (car ENT) SS))
      )
      (progn
(prompt (strcat "\rUnable to process " (cdr (assoc 0 (entget (car ENT)))) " objects."))
(prompt "\n ")
      )
    )
  )
)
Think Slow......

whdjr

  • Guest
Re: Trapping Nentsel
« Reply #3 on: March 21, 2007, 11:43:15 AM »
Glad it worked for you.