Author Topic: Question of the day #4  (Read 1927 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Question of the day #4
« on: November 30, 2004, 07:42:06 AM »
Write the necessary code to return the entity type of that selected.

pseudo code:
prompt the user> Select an entity
determine entity type and save in variable 'typ'
return to the user> The entity you selected is of type 'typ'
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Question of the day #4
« Reply #1 on: November 30, 2004, 09:36:35 AM »
HUH? No takers?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

David Bethel

  • Swamp Rat
  • Posts: 656
Question of the day #4
« Reply #2 on: November 30, 2004, 09:58:47 AM »
this is taken from a program I wrote in the '90s and keep modifing it as ACAD evolves.  -David

Code: [Select]
(defun c:info (/ ss en ed)
  (while (or (not ss)
             (> (sslength ss) 1))
         (princ "\nSelect An Entity To Describe:   ")
         (setq ss (ssget)))
  (setq en (ssname ss 0)
        ed (entget en))
  (textpage)
  (princ "\nSelected Entity  ")
  (prin1 en)
  (terpri)
  (princ (strcat "\nType (0) = "
               (cdr (assoc 0 ed))))
  (if (assoc 1 ed)
      (princ (strcat "\nText (1) = " (cdr (assoc 1 ed)))))
  (if (assoc 2 ed)
      (princ (strcat "\nName (2) = " (cdr (assoc 2 ed)))))
  (princ (strcat "\nHandle (5) = "
               (if (assoc 5 ed)
                   (cdr (assoc 5 ed))
                   "Disabled")))
  (princ (strcat "\nLinetype (6) = "
               (if (assoc 6 ed)
                   (cdr (assoc 6 ed))
                   "ByLayer")))
  (if (assoc 7 ed)
      (princ (strcat "\nStyle (7) = " (cdr (assoc 7 ed)))))
  (princ (strcat "\nLAyer (8) = "
               (cdr (assoc 8 ed))))
  (princ (strcat "\nThickness (39) = "
               (if (assoc 39 ed)
                   (rtos (cdr (assoc 39 ed)) 2)
                   "0.0")))
  (princ (strcat "\nLTScale (48) = "
               (if (assoc 48 ed)
                   (rtos (cdr (assoc 48 ed)) 2)
                   "1.0")))
  (princ (strcat "\nVisibilty (60) = "
               (cond ((not (assoc 60 ed))         "Visible")
                     ((zerop (cdr (assoc 60 ed))) "Visible")
                     (T                         "Invisible"))))
  (princ (strcat "\nColor (62) = "
               (cond ((not (assoc 62 ed))         "ByLayer")
                     ((zerop (cdr (assoc 62 ed))) "ByBlock")
                     (T           (itoa (cdr (assoc 62 ed)))))))
  (princ (strcat "\nSpace (67) = "
               (cond ((not (assoc 67 ed))         "ModelSpace")
                     ((= (cdr (assoc 67 ed)) 0)   "ModelSpace")
                     (T                           "PaperSpace"))))
  (princ (strcat "\nUCS (210) = "
               (cond ((not (assoc 210 ed))         "WCS")
                     ((equal (cdr (assoc 210 ed))
                             '(0 0 1) 1e-11)       "WCS")
                     (T                            "OCS"))))

(prin1))

R12 Dos - A2K

ImaJayhawk

  • Guest
Question of the day #4
« Reply #3 on: November 30, 2004, 10:29:32 AM »
Code: [Select]

(setq typ (cdr (assoc 0 (entget (car (entsel "\nSelect Object:   "))))))
(princ (strcat "The entity you selected is of type " typ))





--ImaJayhawk

ImaJayhawk

  • Guest
Question of the day #4
« Reply #4 on: November 30, 2004, 10:36:58 AM »
Code: [Select]

(vl-load-com)
(setq typ (vlax-get-property (vlax-ename->vla-object (car (entsel)))'objectname))
(princ (strcat "The entity you selected is of type " typ))



--ImaJayhawk