Tripledot Posted June 22, 2016 Share Posted June 22, 2016 Been Using this colour changing lisp. So far its good. But found that some lines will not change & encounter error instead. Command: 4 To assign to object(s) color 4 (Cyan), Select objects: Specify opposite corner: 2 found Select objects: Unknown command "P". Press F1 for help. Unknown command "C". Press F1 for help. 4 Unknown command "4". Press F1 for help. Assigned color to 2 object(s). Attached is dwg. Left side of line cannot change. Right side can what is problem? ;; ColorCommandNames.lsp ;; Function name: CCN; command names 0 through 256 ;; Defines commands for all color numbers. ;; Type color number as command, select objects, and ;; they will have that color assigned as entity override. ;; Based on okc.lsp by Tommy Shumpert at Cadalyst CAD ;; Tips, Tip #3645, "Change Entity Colors," 15 May 2011 ;; Slightly altered, and expanded on, by Kent Cooper, ;; 13 September 2012, to add to original's colors 1-255: ;; 0 = ByBlock ;; 256 = ByLayer ;; Enhanced 17 September 2013 [prompt including color names, ;; notifications, locked-Layer prevention, operation only with ;; valid selection, command-echo suppression.] (setq i 0) (while (<= i 256) (eval (read (strcat "(defun c:" (itoa i) "() (ccn " (itoa i) "))"))) (setq i (1+ i)) ) (defun ccn (color / ss cmde); = Color Command Name (prompt (strcat "\nTo assign to object(s) color " (itoa color) (cond ((< color (strcat " (" (nth color '("ByBlock" "Red" "Yellow" "Green" "Cyan" "Blue" "Magenta" "White/Black")) ")" ); strcat ); ByBlock-or-named-color condition ((= color 256) " (ByLayer)") (""); add nothing for 1 through 255 ); cond "," ); strcat ); prompt (if (setq ss (ssget "_:L")); User selection, excluding object(s) on locked Layer(s) (progn ; then (setq cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "._change" ss "" "p" "c" (cond ((= color 0) "byblock") ((= color 256) "bylayer") (color) ); cond "" ); command (setvar 'cmdecho cmde) (prompt (strcat "\nAssigned color to " (itoa (sslength ss)) " object(s).")) ); progn (prompt "\nNo changeable objects selected."); else ); if (princ) ) cannot change colour.dwg Quote Link to comment Share on other sites More sharing options...
BKT Posted June 22, 2016 Share Posted June 22, 2016 That LISP uses the "Change" command. If you run "Change" on the polyline on the left side it will throw a "not parallel to ucs" error. You could run the "Flatten" command on the lines first, then run the LISP and see if that works for you. BKT Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 22, 2016 Share Posted June 22, 2016 Try a vl solution (repeat (setq x (sslength ss)) (vla-put-color (vlax-ename->vla-object (ssname ss (setq x (- x 1)))) 4) ) Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 22, 2016 Author Share Posted June 22, 2016 Try a vl solution (repeat (setq x (sslength ss)) (vla-put-color (vlax-ename->vla-object (ssname ss (setq x (- x 1)))) 4) ) Which part to insert this code? Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 22, 2016 Author Share Posted June 22, 2016 That LISP uses the "Change" command. If you run "Change" on the polyline on the left side it will throw a "not parallel to ucs" error. You could run the "Flatten" command on the lines first, then run the LISP and see if that works for you. BKT Possible but prefer not to. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted June 22, 2016 Share Posted June 22, 2016 Try changing: "._change" ss "" "p" "c" To: "._chprop" ss "" "c" Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 22, 2016 Author Share Posted June 22, 2016 Try changing: "._change" ss "" "p" "c" To: "._chprop" ss "" "c" Thanks dude!! That worked!! Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted June 22, 2016 Share Posted June 22, 2016 Try this function (defun ccn (col / a i) (if (setq a (ssget "_:L")) (progn (repeat (setq i (sslength a)) (vla-put-color (vlax-ename->vla-object (ssname a (setq i (1- i)))) col ) ) (prompt (strcat "\nAssigned " (cond ((< col (nth col '("ByBlock" "Red" "Yellow" "Green" "Cyan" "Blue" "Magenta" "White/Black" ) ) ) ((= col 256) "bylayer") ((itoa col)) ) " color to " (itoa (sslength a)) " object(s)." ) ) ) (prompt "\nNo changeable objects selected.") ) ) Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 22, 2016 Author Share Posted June 22, 2016 Try this function Tried. but when pressing numbers it do not register a command. The present code when press 2 or 10 then select object & enter will change object to red colour. If press 3 or 100, will change to green colour. Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted June 22, 2016 Share Posted June 22, 2016 Color 2 & 10 are not same... they are different shades of same color... same with 3 & 100 YOu can see the difference in color index Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 22, 2016 Author Share Posted June 22, 2016 (edited) Color 2 & 10 are not same... they are different shades of same color... same with 3 & 100 YOu can see the difference in color index That's correct . I meant how it visually look in its base colour. wanted to emphasie that the colour will change according to its number indicated which as you have mention, the colour index. by the way how does your code works? Edited June 22, 2016 by Tripledot Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 23, 2016 Share Posted June 23, 2016 vla-put-color does exactly that changes object colour. 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.