(car (entsel)) Posted October 27, 2016 Share Posted October 27, 2016 Hello everybody, The following works with circle, line but not with lwpolyline, spline: (defun C:RT ( / ent data ) (if (setq ent (car (entsel "\nSelect object to change its color"))) (progn (if (not (assoc 62 (setq data (entget ent)))) (setq data (append (list (cons 62 1)) data)) (setq data (subst (cons 62 1) (assoc 62 data) data)) ) (entupd (cdr (assoc -1 (entmod data)))) ) ) (princ) ) Is there an easy fix for this? Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted October 27, 2016 Share Posted October 27, 2016 Try this :- (defun c:test ( / a b i) (if (setq a (ssget '((0 . "*line,circle,ellipse,point")))) (repeat (setq i (sslength a)) (setq b (vlax-ename->vla-object (ssname a (setq i (1- i))))) (vla-put-color b 1) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 27, 2016 Share Posted October 27, 2016 Another: (defun c:rt ( / e ) (if (setq e (car (entsel))) (entmod (append (entget e) '((62 . 1)))) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
tombu Posted October 27, 2016 Share Posted October 27, 2016 (edited) One more! (defun C:RT ( / EOBJ ) (setq EOBJ (entsel "\nSelect object to change its color")) (if EOBJ (vl-catch-all-apply 'vla-put-Color (list (vlax-ename->vla-object (car EOBJ)) 1))) (princ) ) Edited October 27, 2016 by tombu Updated to avoid error for a null argument Lee Mac pointed out. Quote Link to comment Share on other sites More sharing options...
(car (entsel)) Posted October 27, 2016 Author Share Posted October 27, 2016 Thanks guys, now I see the problem in my code: (setq data (append (list (cons 62 1)) data)) must be: (setq data (append data (list (cons 62 1)))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 27, 2016 Share Posted October 27, 2016 One more!(defun C:RT ( / EOBJ ) (if (setq EOBJ (vlax-ename->vla-object (car (entsel "\nSelect object to change its color")))) (vl-catch-all-apply 'vla-put-Color (list EOBJ 1)) ) (princ) ) Careful - vlax-ename->vla-object will error for a null argument Quote Link to comment Share on other sites More sharing options...
tombu Posted October 27, 2016 Share Posted October 27, 2016 Careful - vlax-ename->vla-object will error for a null argument Fixed code above. Thanks, Quote Link to comment Share on other sites More sharing options...
(car (entsel)) Posted October 27, 2016 Author Share Posted October 27, 2016 Thanks, now I know how its done with visual lisp. 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.