Author Topic: Cycle thru selection one object at a time with cmd-line ID/info.  (Read 1309 times)

0 Members and 1 Guest are viewing this topic.

ScottMC

  • Newt
  • Posts: 191
Must be a way to cycle thru all objects selected [using space/click] giving micro ID and/or coords. Been searchin but convinced there's others with 'built-in' super-cerebrum.  http://www.theswamp.org/Smileys/black/idea.gif

mhupp

  • Bull Frog
  • Posts: 250
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #1 on: January 22, 2022, 03:29:05 AM »
What is it your trying to do?

ScottMC

  • Newt
  • Posts: 191
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #2 on: January 22, 2022, 08:40:33 AM »
Would like to use this to evaluate my objects being 3dsolid, polylines and regions just to mention a couple. This helps to understand and/or select the object desired.

mhupp

  • Bull Frog
  • Posts: 250
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #3 on: January 22, 2022, 09:46:38 AM »
You can filter at the selection itself. I use this to filter down my selections to a type of entity.
Also look at selection cycling

Code - Auto/Visual Lisp: [Select]
  1. ;;----------------------------------------------------------------------------;;
  2. ;; Select Polylines: Filter Down Selection to Polylines only or select only polylines
  3. (defun C:SP ()
  4.   (if (ssget "_I")  ; If there are preselected objects [= Implied selection]
  5.     (sssetfirst nil (ssget "_I" '((0 . "*POLYLINE"))))  
  6.     (sssetfirst nil (ssget "_:L" '((0 . "*POLYLINE"))))  
  7.   )
  8.   (princ)
  9. )




ScottMC

  • Newt
  • Posts: 191
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #4 on: January 22, 2022, 06:48:41 PM »
In using selection cycling with my A2k, my option for window/filter viewing selection w/properties <to cycle> is a Not. We all have the option to select, and filter in the properties window for type.. but I cannot get it's property while ctrl+click cycling. Q: is this an AutoDesk exclusive as deserving with some of the others?
Just would be nicer to have the object type/layer info visible [as y'all might] when ctrl+click cycling or however.. Could this be a "programmers challenge?" Consider it Elpanov.
« Last Edit: January 23, 2022, 10:36:25 PM by ScottMC »

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #5 on: January 22, 2022, 11:39:58 PM »
The only thing I can think of is pick lots of objects a mixture of entity types then select which ones to keep. A 2 step process compared to using ssget filter.

Maybe this as a front end.



Almost forgot you can pass the Multi toggle.lsp a list of object names so could look inside a selection get object names that are in the selection, but again adding multiple steps to the overall process. So it might be like LINE PLINE 3DSOLID displayed.
« Last Edit: January 22, 2022, 11:47:00 PM by BIGAL »
A man who never made a mistake never made anything

ScottMC

  • Newt
  • Posts: 191
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #6 on: January 26, 2022, 11:50:34 PM »
Here's what I was looking for! Yet having added 'Radius - assoc 40' causes crash
with: ** Error: bad argument type: numberp: nil ** now when LINE is evaluated/included.
When ENTITY_RAD of progn is removed, all's OK. Why/how does it crash? Is there a solution?
... Added an 'if' to filter out the line but still crashes when eval..

Code: [Select]
;;*****************************************************************************
;; INSPECTOR - Command to Inspect Objects by Moving the Crosshairs Over Them. *
;; =========                                                                  *
;;             Didge, 2006.                                                   *
;;   https://www.theswamp.org/index.php?topic=12813.msg166947#msg166947       *
;;                                                                            *
;;*****************************************************************************

(defun c:ins (/             *error*       cosm
              INPUT         INPUT_COORD   ENTITY_FOUND  ENTITY_NAME
              ENTITY_LIST   ENTITY_TYPE   ENTITY_LAYER  ENTITY_RAD
             )
   (vl-load-com)
   (setq cosm (getvar 'osmode))
   (defun *error* (msg) ;_ error trap
      (if (= 8 (logand 8 (getvar 'undoctl)))
         (vla-EndUndoMark doc)
      ) ;_ end of if
      (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
          (princ (strcat "\n** Error: " msg " **"))
      ) ;_ end of or
      (setvar 'osmode cosm)
      (redraw)
      (princ)
   ) ;_ end of defun
   (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

   (vla-StartUndoMark doc)
   (prompt
      "\n   Inspect Objects by Moving the Cross-hairs Over Them..\n"
   ) ;_ end of prompt
   (while (and (setq INPUT (grread T)) (= (car INPUT) 5))
      (setq INPUT_COORD (cadr INPUT))
      (setq ENTITY_FOUND (ssget INPUT_COORD)) ;;
      (vla-StartUndoMark doc)
      (if ENTITY_FOUND
         (progn
            (setq ENTITY_LIST (entget (ssname ENTITY_FOUND 0)))
            (setq ENTITY_TYPE (cdr (assoc 0 ENTITY_LIST)))
            (setq ENTITY_LAYER (cdr (assoc 8 ENTITY_LIST)))
            (if (not (equal (assoc 40 ENTITY_LIST) '(0. LINE))) ;;;<< how to test ??
                (setq ENTITY_RAD (rtos (cdr (assoc 40 ENTITY_LIST)) 2 3))
               (setq ENTITY_RAD (rtos 0))
             )
            (prompt (strcat "\r Object: "    ENTITY_TYPE
                            "  Layer: "      ENTITY_LAYER
                            "  Radius: "     ENTITY_RAD
                            "        "
                           ) ;_ end of strcat

            ) ;_ end of prompt
            ;;
         ) ;_ end of progn
         (vla-EndUndoMark doc)
      ) ;_ end of if
   ) ;_ end of while
   (vla-EndUndoMark doc)
   (setvar 'osmode cosm)
   (princ)
) ;_ end of defun
                                                  ;(c:ins)
;|«Visual LISP© Format Options»
(72 3 50 2 T "end of " 60 9 0 1 0 nil T nil T)
;*** DO NOT add text below the comment! ***|;

« Last Edit: January 27, 2022, 03:47:30 PM by ScottMC »

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #7 on: January 27, 2022, 10:24:48 PM »
Your getting entity type so use a cond that looks at type and the relevant properties, layer would be considered a global answer, so a ARC and CIRCLE can have a radius but a line does not. Change your prompt to add radius or not, remove code from the if not part.

Code: [Select]
(setq str  (strcat "Object: "    ENTITY_TYPE "  Layer: "      ENTITY_LAYER))
(if  (or (= (cdr (assoc 0 ENTITY_LIST)) "ARC")(= (cdr (assoc 0 ENTITY_LIST)) "CIRCLE"))
  (setq str  (strcat str "  Radius: " (rtos (cdr (assoc 40 ENTITY_LIST)) 2 3)  ))
)
(alert str)
A man who never made a mistake never made anything

ScottMC

  • Newt
  • Posts: 191
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #8 on: January 28, 2022, 10:45:27 AM »
Excellence BIGAL! just changed the 'str' after strcat and as you will see, and (setq str "") in the IF!
..It is really handy + [transparent!] Reads all now (blocks too!) Please consider testing.

Code: [Select]

;;*****************************************************************************
;; INSPECTOR - Command to Inspect Objects by Moving the Crosshairs Over Them. *
;; =========                                                                  *
;;             Didge, 2006.                                                   *
;;   https://www.theswamp.org/index.php?topic=12813.msg166947#msg166947       *
;;                                                                            *
;;*****************************************************************************

(defun c:ins (/             *error*       cosm          str
              INPUT         INPUT_COORD   ENTITY_FOUND  ENTITY_NAME
              ENTITY_LIST   ENTITY_TYPE   ENTITY_LAYER  ENTITY_RAD
             )
   (vl-load-com)
   (setq cosm (getvar 'osmode))
   (defun *error* (msg) ;_ error trap
      (if (= 8 (logand 8 (getvar 'undoctl)))
         (vla-EndUndoMark doc)
      ) ;_ end of if
      (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
          (princ (strcat "\n** Error: " msg " **"))
      ) ;_ end of or
      (setvar 'osmode cosm)
      (redraw)
      (princ)
   ) ;_ end of defun
   (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

   (vla-StartUndoMark doc)
   (prompt
      "\n   Inspect Objects by Moving the Cross-hairs Over Them..\n"
   ) ;_ end of prompt
   (while (and (setq INPUT (grread T)) (= (car INPUT) 5))
      (setq INPUT_COORD (cadr INPUT))
      (setq ENTITY_FOUND (ssget INPUT_COORD)) ;;
      (vla-StartUndoMark doc)
      (if ENTITY_FOUND
         (progn
            (setq ENTITY_LIST (entget (ssname ENTITY_FOUND 0)))
            (setq ENTITY_TYPE (cdr (assoc 0 ENTITY_LIST)))
            (setq ENTITY_LAYER (cdr (assoc 8 ENTITY_LIST)))
                (if  (or (= (cdr (assoc 0 ENTITY_LIST)) "ARC")
                         (= (cdr (assoc 0 ENTITY_LIST)) "CIRCLE"))
                  (setq str  (strcat "  Radius: " (rtos (cdr (assoc 40 ENTITY_LIST)) 2 1) ))
                   (setq str "")
                   )
            (prompt (strcat "\r Object: "    ENTITY_TYPE
                            "  Layer: "      ENTITY_LAYER
                            str
                                       "                    "
                           ) ;_ end of strcat
            ) ;_ end of prompt
            ;;
         ) ;_ end of progn
         (vla-EndUndoMark doc)
      ) ;_ end of if
   ) ;_ end of while
   (vla-EndUndoMark doc)
   (setvar 'osmode cosm)
   (princ)
) ;_ end of defun

« Last Edit: January 28, 2022, 12:27:59 PM by ScottMC »

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: Cycle thru selection one object at a time with cmd-line ID/info.
« Reply #9 on: January 29, 2022, 06:18:06 PM »
Tried it out very nice could add more like length, color, linetype note circle is circumference.

This is something similar

A man who never made a mistake never made anything