Jump to content

Getting the selected objects type


rborn

Recommended Posts

I have looked all over for this but can't find it. I want to know if there is a way to determine what the currently selected objects type is in AutoLISP. I don't want to prompt the user to select something, I want to know what the name of currently selected object is. The user selected an object or objects in AutoCAD using whatever method and I want to know what type they are. I am interested in just TEXT objects and will do a comparison for that. Hope that makes sense.

 

Russell

Link to comment
Share on other sites

quick and dirty

(defun c:type? (/ typ)
 (while
   (setq typ (cdr (assoc 0 (entget (car (entsel))))))
   (princ (strcat "\nThe selected entity is a(n) " typ))
   )
 )

Link to comment
Share on other sites

Or for ssget retrieval:

 

(defun c:test (/ ss1 ssl cnt ent1 entyp)
   (setq ss1 (ssget))
   (setq ssl (sslength ss1)
         cnt 0
   ) ; end setq
   (repeat ssl
       (setq     ent1 (entget (ssname ss1 cnt))
                 entyp (cdr (assoc 0 ent1))
       ) ; end setq
       (princ (strcat "\n Entity is a(n) " entyp))
       (setq cnt (+ cnt 1))
   )
   (princ)
)

Hope this helps :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...