Grrr Posted November 10, 2016 Share Posted November 10, 2016 Thank you Grrr An alternative could be to use mapcar with two separate argument lists, i.e.: (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) ls1 (cons obj ls1) ls2 (cons (vla-get-color obj) ls2) ) Then: (mapcar 'vla-put-color ls1 ls2) Thats right, now I remember! I might need revise again your mapcar & lambda tutorial, incase I forgot something. I did a big progress from there, the only problem is that very very careful reading is required. BTW the recent pause discovery inspired me to write some simple subfunction: ; Example: (PromptPause "\nPaused, press any key to continue.") (defun PromptPause ( msg ) (and (= 'STR (type msg)) (princ msg) (vl-catch-all-apply 'grread) ) ) (and (setq e (car (entsel "\nSelect object: "))) (setq o (vlax-ename->vla-object e)) (setq c (vla-get-Color o)) (not (vla-put-Color o 1)) (PromptPause "\nPaused, press any key to continue.") (not (vla-put-Color o c)) ) As I remember that once someone asked "How to pause a code?", but I think the answers he got were with using the get*** functions. Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 18, 2016 Share Posted November 18, 2016 Sorry for bumping this thread, but just found this code from LM (from theswamp) : (defun c:test ( / col idx sel ) (if (and (setq sel (ssget "_:L")) (setq col (acad_truecolordlg 1)) ) (repeat (setq idx (sslength sel)) (entmod (append (entget (ssname sel (setq idx (1- idx)))) col)) ) ) (princ) ) So I thought if he "merged" it with his suggestion here, the end result would be more "complete": (defun c:tempcolor ( / col idx lst obj sel ) (if (and (setq sel (ssget "_:L")) (setq col (acad_truecolordlg 1)) ) (progn (repeat (setq idx (sslength sel)) (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) lst (cons (list obj (vla-get-color obj)) lst) ) (vla-put-color obj (cdar col)) ) (princ "\nPress any key to exit...") (vl-catch-all-apply 'grread) (foreach itm lst (apply 'vla-put-color itm)) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
jim78b Posted November 25, 2016 Author Share Posted November 25, 2016 It could not change color after I initiated a command? Quote Link to comment Share on other sites More sharing options...
jim78b Posted November 12, 2018 Author Share Posted November 12, 2018 Is it possible to make the color change after i start a command ...example...i make move command select a object or a block and them will color .color that i choosed in my 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.