cadamrao Posted December 12, 2011 Posted December 12, 2011 Hi This lisp collected from other, but I need to little modify; while I apply command ColorX select color (index dialog box) displayed. After select ok, I need to ask select object at command line; which means I need to change the color selecting window. Thanks venki defun C:ColorX( / doc col) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark doc) (mip:layer-status-save) (if (setq col (acad_colordlg 7 t)) (ChangeAllObjectsColor doc col);_ col — color number ) (mip:layer-status-restore) (vla-endundomark doc) (princ) ) (princ "\nType ColorX in command line") color change in all layers.lsp Quote
Tharwat Posted December 12, 2011 Posted December 12, 2011 Something like this ... ? (defun c:TesT (/ color ss i obj) (vl-load-com) ;;; Tharwat 12. Dec. 2011 ;;; (cond ((not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object))))) (if (and (setq color (acad_colordlg 7 t)) (setq ss (ssget "_:L"))) (progn (vla-startundomark acdoc) (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vla-put-color obj color) ) (vla-endundomark acdoc) ) (princ) ) (princ) ) Quote
cadamrao Posted December 13, 2011 Author Posted December 13, 2011 Something like this ... ? (defun c:TesT (/ color ss i obj) (vl-load-com) ;;; Tharwat 12. Dec. 2011 ;;; (cond ((not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object))))) (if (and (setq color (acad_colordlg 7 t)) (setq ss (ssget "_:L"))) (progn (vla-startundomark acdoc) (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vla-put-color obj color) ) (vla-endundomark acdoc) ) (princ) ) (princ) ) Sorry,can't change block objects.pls check ur code. Quote
Tharwat Posted December 13, 2011 Posted December 13, 2011 Anyway , check this out ... (defun c:TesT (/ color ss i sn obj lst name) (vl-load-com) ;;; Tharwat 13. Dec. 2011 ;;; (cond ((not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object))))) (if (and (setq color (acad_colordlg 7 t)) (setq ss (ssget "_:L"))) (progn (vla-startundomark acdoc) (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))))) (if (eq (cdr (assoc 0 (entget sn))) "INSERT") (vlax-for block (setq blk (vla-item (vla-get-blocks acdoc) (setq name (vla-get-EffectiveName obj)))) (if (and (eq :vlax-false (vla-get-isLayout blk)) (eq :vlax-false (vla-get-isXref blk)) (if (not (member name lst)) (setq lst (cons name lst)) ) ) (vlax-for x blk (if (not (eq "AcDbBlockReference" (vla-get-objectname x))) (vla-put-color x color) ) ) ) ) (vla-put-color obj color) ) ) (vla-regen acdoc acAllViewports) (vla-endundomark acdoc) ) (princ) ) (princ) ) Quote
pBe Posted December 13, 2011 Posted December 13, 2011 HiThis lisp collected from other, but I need to little modify; while I apply command ColorX select color (index dialog box) displayed. After select ok, I need to ask select object at command line; which means I need to change the color selecting window. Are you wanting to change the color of the enity or the color of the layer of the entity selected? Quote
Arin9916 Posted December 13, 2011 Posted December 13, 2011 (defun c:aa( / doc bl ss co ) (PTE:subload-111213-g) (setq doc (vla-get-activedocument (vlax-get-acad-object)) bl (vla-get-blocks doc) ss (PTE:ss->obj(ssget)) co (acad_colordlg 256 t) ) (foreach ob ss (if (= (vla-get-objectname ob) "AcDbBlockReference") (PTE:changeC_ ob bl co) (vla-put-color ob co) ) )(vla-regen doc acAllViewports) (princ) )(vl-load-com) (defun PTE:subload-111213-g nil ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; ;; Sub Function - 01 ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; (defun PTE:ss->obj ( ss / i re ) (if ss (repeat (setq i (sslength ss)) (setq re (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) re)) ) ) ) ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; ;; Sub Function - 02 ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; (defun PTE:changeC_ ( obj bl co ) (vlax-for obj (vla-item bl (vla-get-name obj)) (if (= (vla-get-objectname obj) "AcDbBlockReference") (PTE:changeC_ obj bl co) (vla-put-color obj co) ) ) ) ) Quote
pBe Posted December 13, 2011 Posted December 13, 2011 Guys, I dont see the logic why the need for a lisp code if the OP only wants the entiy to be on specificied color , wherein the color properties will be not be "Bylayer" Same goes for Block entities: You dont really need a code for that. Besdes with the code you guys written will change all instances of the block and not just the selected block entity Thats the reason why im asking the OP to clarify his request I would think changing the color of the layer where the entity is currently assigned is more likely what the OP wants (or so i think ) perhaps something like this (defun c:test (/ LayerColl e ss lst) (vl-load-com) (setq LayerColl (vla-get-Layers (vla-get-activedocument (vlax-get-acad-object)) ) ) (if (and (setq color (acad_colordlg 7 t)) (setq ss (ssget))) (repeat (sslength ss) (setq e (cdr (assoc 8 (entget (ssname ss 0))))) (if (not (member e lst)) (progn (vla-put-color (vla-item LayerColl e) color) (setq lst (cons e lst)) ) ) (ssdel (ssname ss 0) ss) ) ) ) Granting all the enities color properties are "Bylayer" Quote
cadamrao Posted December 15, 2011 Author Posted December 15, 2011 (defun c:aa( / doc bl ss co ) (PTE:subload-111213-g) (setq doc (vla-get-activedocument (vlax-get-acad-object)) bl (vla-get-blocks doc) ss (PTE:ss->obj(ssget)) co (acad_colordlg 256 t) ) (foreach ob ss (if (= (vla-get-objectname ob) "AcDbBlockReference") (PTE:changeC_ ob bl co) (vla-put-color ob co) ) )(vla-regen doc acAllViewports) (princ) )(vl-load-com) (defun PTE:subload-111213-g nil ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; ;; Sub Function - 01 ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; (defun PTE:ss->obj ( ss / i re ) (if ss (repeat (setq i (sslength ss)) (setq re (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) re)) ) ) ) ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; ;; Sub Function - 02 ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; (defun PTE:changeC_ ( obj bl co ) (vlax-for obj (vla-item bl (vla-get-name obj)) (if (= (vla-get-objectname obj) "AcDbBlockReference") (PTE:changeC_ obj bl co) (vla-put-color obj co) ) ) ) ) Hi good morning!!!!!!! (defun c:aa( / doc bl ss co ) (PTE:subload-111213-g) (setq doc (vla-get-activedocument (vlax-get-acad-object)) bl (vla-get-blocks doc) ss (PTE:ss->obj(ssget)) co (acad_colordlg 256 t) ) (foreach ob ss (if (= (vla-get-objectname ob) "AcDbBlockReference") (PTE:changeC_ ob bl co) (vla-put-color ob co) ) )(vla-regen doc acAllViewports) (princ) )(vl-load-com) (defun PTE:subload-111213-g nil ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; ;; Sub Function - 01 ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; (defun PTE:ss->obj ( ss / i re ) (if ss (repeat (setq i (sslength ss)) (setq re (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) re)) ) ) ) ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; ;; Sub Function - 02 ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;; (defun PTE:changeC_ ( obj bl co ) (vlax-for obj (vla-item bl (vla-get-name obj)) (if (= (vla-get-objectname obj) "AcDbBlockReference") (PTE:changeC_ obj bl co) (vla-put-color obj co) ) ) ) ) Thanks for code,great work.This one works perfect,after change my color (including blocks) again I need to change back by layer that time code not working in blocks (block color can't change). Thanks once again for great works venki Quote
pBe Posted December 15, 2011 Posted December 15, 2011 (edited) Hi good morning!!!!!!!Thanks for code,great work.This one works perfect,after change my color (including blocks) again I need to change back by layer that time code not working in blocks (block color can't change). I stand corrected Curious, if thats the case why not just use _properties? Another case of ---end justifies the means--- Edited December 15, 2011 by pBe Quote
SLW210 Posted December 15, 2011 Posted December 15, 2011 Please read CODE POSTING GUIDELINES. cadamrao, Were the code posting instructions not clear enough for you? Quote
VVA Posted December 16, 2011 Posted December 16, 2011 Hi I need to ask select object at command line; which means I need to change the color selecting window. ColorA - Color Area - - Changes in the color of selected items in the area 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.