Alhazred Posted July 19, 2010 Posted July 19, 2010 Hi all, I'm new to this forum and to AutoLISP programming. I've studied a tutorial and now I'm trying to do something by myself. I have a 2D drawing with a square made using a polyline, now I want to create a routine which asks me to select a polyline and simply tells me that I have selected it correctly. This is my code (defun c:polysel(/ ent_name element) (setq ent_name (car(entsel "\n Select a polyline:"))) (setq element (entget ent_name)) (if (= (cdr(assoc 0 element)) "POLYLINE") (print "\n Polyline selected!") ) (princ) ) I select the polyline, but the message "Polyline selected!" doesn't appear, what's wrong? Quote
Tharwat Posted July 19, 2010 Posted July 19, 2010 Chech this out; (defun c:polysel (/ ent_name element) (setq ent_name (car(entsel "\n Select a polyline:"))) (setq element (entget ent_name)) (if (= (cdr(assoc 0 element)) "POLYLINE") (alert " Your have selected POLYLINEs.") (alert (strcat "Your Selection is .." " "(cdr (assoc 0 element))".")) ) (princ) ) Welcome to CADTutor Tharwat Quote
Alhazred Posted July 19, 2010 Author Posted July 19, 2010 Thanks, it says I have selected a LWPolyline, so I suppose I have to check for LWPolyline and not POLYLINE since I'm working on 2D drawings. Quote
Tharwat Posted July 19, 2010 Posted July 19, 2010 Thanks, it says I have selected a LWPolyline, so I suppose I have to check for LWPolyline and not POLYLINE since I'm working on 2D drawings. Yes try to select any other entity, so it will give you the name of the selected entity.... Regards Tharwat Quote
jammie Posted July 19, 2010 Posted July 19, 2010 Welcome to the forum! Just a slightly different test expression from your code Alhazred (if (wcmatch (setq etype (cdr(assoc 0 element))) "*POLYLINE") (princ (strcat "\n[" etype "] selected")) ) Quote
Recommended Posts
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.