Ocron Posted December 16, 2009 Share Posted December 16, 2009 Hello, The problem I have been having is trying to find a way to select all the polylines on my drawing, and then to turn the Ltype Regeneration to "ON" on all of them. I have a little experience with autolisp, but can't seem to get this to work. This is basically what my lisp looks like right now, but for some reason when it gets to the "pedit" command it cannot use the "ss" for my selection and instead makes each letter command after that unknown. (defun C:exd () (setq CE-SAV (getvar "cmdecho")) (setvar "cmdecho" 0) (setq ss (ssget "x" '((0 . "*polyline")) )) (command "pedit" ss "" "l" "on" "") (setq ss nil) (setvar "cmdecho" CE-SAV) (princ) ) ;_ end of defun Please help me out if you can, cause this is frustrating the heck out of me. lol Thank you Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 16, 2009 Share Posted December 16, 2009 This should work: (defun C:exd (/ *error* vl ov ss) ;; Localise Variables! ;; Error Handler to Reset Sys Vars in case User hits Esc! (defun *error* (msg) (and ov (mapcar 'setvar vl ov)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) ;; Get Sysvars and store them (setq vl '("CMDECHO" "PEDITACCEPT") ov (mapcar 'getvar vl)) ;; Set sys vars to what we want (mapcar 'setvar vl '(0 1)) ;; Include IF statment to allow for a null SelectionSet (if (setq ss (ssget "_X" '((0 . "*POLYLINE")))) (command "_.pedit" "_M" ss "" "_L" "ON" "")) ;; Reset Sys Vars (mapcar 'setvar vl ov) (princ)) Please read the comments, if you have questions, just ask Lee Quote Link to comment Share on other sites More sharing options...
Ocron Posted December 16, 2009 Author Share Posted December 16, 2009 Lee Mac You are a god among men. lol Thank you that worked perfectly. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 16, 2009 Share Posted December 16, 2009 Lee Mac You are a god among men. lol Thank you that worked perfectly. Hehe thanks Ocron After thinking about it, I suppose the code doesn't really need the error handler, as there is no pause for user input, but its good practice anyway, as we are tampering with Sys Vars. Lee Quote Link to comment Share on other sites More sharing options...
Ocron Posted December 16, 2009 Author Share Posted December 16, 2009 Actually it's good for me to see that and start using it. When I learned Lisp it was back during ACAD2004 and they didn't even teach us to do that. Most of it was Initget commands and such which was a pain. lol Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 16, 2009 Share Posted December 16, 2009 Actually it's good for me to see that and start using it. When I learned Lisp it was back during ACAD2004 and they didn't even teach us to do that. Most of it was Initget commands and such which was a pain. lol Hehe, I always say the forums are by far the best place to learn Quote Link to comment Share on other sites More sharing options...
alanjt Posted December 16, 2009 Share Posted December 16, 2009 Is this the same thing? (defun c:Test (/ #SS) (and (setq #SS (ssget "_X" '((0 . "*POLYLINE")))) (foreach x (mapcar 'cadr (ssnamex #SS)) (vl-catch-all-apply 'vla-put-linetypegeneration (list (vlax-ename->vla-object x) :vlax-true) ) ;_ vl-catch-all-apply ) ;_ foreach ) ;_ and (princ) ) ;_ defun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 16, 2009 Share Posted December 16, 2009 Is this the same thing? Most probably Quote Link to comment Share on other sites More sharing options...
JONTHEPOPE Posted December 16, 2009 Share Posted December 16, 2009 Very Clean Quote Link to comment Share on other sites More sharing options...
alanjt Posted December 17, 2009 Share Posted December 17, 2009 Actually, I think I could have scaled it down to this: (defun c:Test (/ #SS) (and (setq #SS (ssget "_X" '((0 . "*POLYLINE")))) (foreach x (ssnamex #SS) (vl-catch-all-apply 'vla-put-linetypegeneration (list (vlax-ename->vla-object (cadr x)) :vlax-true) ) ;_ vl-catch-all-apply ) ;_ foreach ) ;_ and (princ) ) ;_ defun Quote Link to comment Share on other sites More sharing options...
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.