Author Topic: looping and undo functions  (Read 5864 times)

0 Members and 1 Guest are viewing this topic.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
looping and undo functions
« Reply #15 on: August 31, 2005, 03:32:01 AM »
Hi Dan

To help to understand, I've attached some comments...
Code: [Select]
;
; -- Function MeExtEntSel

; Extended (entsel) function.
; Arguments [Typ]:
;   Pmt = Prompt [STR]
;         eg. "\nSelect Arc or Circle: "
;   Lst = Entity filter list (uppercase) [LIST]
;         eg. '("ARC" "CIRCLE")
; Return [Typ]:
;   > List of (ENAME '(PickPoint)) [LIST]
;   > nil if user press enter/space key
; Notes:
;   None
;
(defun MeExtEntSel (Pmt Lst / CurEnt ExLoop TmpStr)
 ;while not exit loop...
 (while (not ExLoop)
  ;allow enter/space key
  (initget " ")
  ;select entity
  (setq CurEnt (entsel Pmt))
  (cond
   ;case enter/space key... exit loop & set return to nil
   ((= CurEnt "") (setq ExLoop T CurEnt nil))
   ;case entity...
   (CurEnt
    (if (member (cdr (assoc 0 (entget (car CurEnt)))) Lst)
     ;if entity name in filter list exit loop
     (setq ExLoop T)
     ;else build and show error message
     (progn
      (setq TmpStr (apply 'strcat
                    (cons
                     (car Lst)
                     (mapcar
                     '(lambda (l)
                       (strcat " or " l)
                      ) (cdr Lst)
                     )
                    )
                   )
      )
      (princ (strcat "selected entity is not a " TmpStr ". "))
     )
    )
   )
   ;case nothing selected... show message
   ((princ "1 selected, 0 found"))
  )
 )
 ;return entsel list (or nil)
 CurEnt
)
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

ELOQUINTET

  • Guest
looping and undo functions
« Reply #16 on: August 31, 2005, 09:30:47 AM »
that's helpful jurg thanks. i still need to get a grip on alot of functions and how to structure code so it behaves properly. i guess that come with time and practice.