Author Topic: Some routines have seen better days..  (Read 2777 times)

0 Members and 1 Guest are viewing this topic.

Water Bear

  • Guest
Some routines have seen better days..
« on: May 06, 2004, 10:29:59 AM »
This little routine was once used alot to peruse a foreign drawing, and it worked great..alas it no longer does :cry: Can anyone see why,it doesn't clear the command line when you move to a new item (the descriptions overlap)
Code: [Select]
;;;===============================================================================
;;;     INSPECT - Inspect entities by running crosshairs over them                
;;;===============================================================================

(defun C:INSPECT (/ INPUT INPUT_COORD
 ENTITY_FOUND ENTITY_NAME ENTITY_LIST
 ENTITY_TYPE BLOCK_NAME
 )

  (prompt
    "\nINSPECT - Inspect entities by running crosshairs over them."
    )
  (prompt "\nHit any key to exit the program ...\n")

  (while (and (setq INPUT (grread T))
     (= (car INPUT) 5)
     )
    (setq INPUT_COORD  (cadr INPUT)
 ENTITY_FOUND (ssget INPUT_COORD)
 )
    (if ENTITY_FOUND
      (progn
(setq ENTITY_NAME (ssname ENTITY_FOUND 0)
     ENTITY_LIST (entget ENTITY_NAME)
     ENTITY_TYPE (cdr (assoc 0 ENTITY_LIST))
     )
(redraw ENTITY_NAME 2)
(if (equal ENTITY_TYPE "INSERT")
 (progn
   (setq BLOCK_NAME (cdr (assoc 2 ENTITY_LIST)))
   (prompt (strcat "\rEntity > BLOCK   Name > " BLOCK_NAME))
   )
 (prompt (strcat "\rEntity > " ENTITY_TYPE))
 )
(redraw ENTITY_NAME 1)
)
      )
    )
  (prompt "\nProgram complete.")
  (princ)
  )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Some routines have seen better days..
« Reply #1 on: May 06, 2004, 10:49:41 AM »
Change \r to \n
see if that works.

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Some routines have seen better days..
« Reply #2 on: May 06, 2004, 10:57:06 AM »
Hey that worked! thanx   Happy days are here again!

SMadsen

  • Guest
Some routines have seen better days..
« Reply #3 on: May 11, 2004, 10:11:55 AM »
The return character changed somewhere around A2K from clearing the entire line to only clearing the characters that follows. But you can call a string of spaces prefixed with a return character to maintain the behaviour, e.g.:

Code: [Select]

...
    (if ENTITY_FOUND
      (progn
        (prompt "\r                            ") ;<- enough spaces to clear?
        (setq ENTITY_NAME (ssname ENTITY_FOUND 0)
              ENTITY_LIST (entget ENTITY_NAME)
              ENTITY_TYPE (cdr (assoc 0 ENTITY_LIST))
        )
...


It gives a little flicker at the command line, though.

I noticed the routine is heavy on selection sets. It takes a while to run out of them, but you might want to consider using NENTSELP instead? Of course, the drawback is that you'd need to decipher each return value because it returns subentities. It's easily done by checking the length of the return value but subentities such as vertices would require more work to show properly. The one below checks for blocks (including nested blocks) and main entities but it doesn't handle oldstyle plines very well (it only displays vertices).
It doesn't use return characters but saves the last shown entity to prevent it from cluttering the screen while dragging.

Code: [Select]
(defun C:INSPECT2 (/ entity_found entity input input_coord last_found str)
  (prompt
    "\nInspect - inspect entities by running crosshairs over them."
  )
  (prompt "\nHit any key to exit the program ...\n")
  (while (= (car (setq input (grread t))) 5)
    (setq input_coord  (cadr input)
          entity_found (nentselp input_coord)
          str ""
    )
    (and entity_found
         (not (eq (car entity_found) last_found))
         (setq last_found (car entity_found))
         (if (> (length entity_found) 2)
           (and (setq entity (car (last entity_found)))
                (prompt (strcat
                          "\nEntity > "
                          (cdr (assoc 0 (entget (car entity_found))))
                          (foreach n (last entity_found)
                            (setq str (strcat str " > in block > "
                                              (cdr (assoc 2 (entget n))))
                            )
                          )
                        )
                )
           )
           (prompt (strcat "\nEntity > "
                           (cdr (assoc 0 (entget (car entity_found)))))
           )
         )
    )
  )
  (prompt "\nProgram complete")
  (princ)
)