handasa Posted January 7, 2016 Share Posted January 7, 2016 Greetings everybody i have this lisp routine (vl-load-com) (defun c:COMBINELAYERS(/ doc blocks blk eo layers lay) ;CHANGE BY LAYER COLOR TO OVERRIDE COLOR ;; Get the ActiveX object of the current dwg (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)) blocks (vla-get-Blocks doc) ;Get the blocks collection layers (vla-get-Layers doc) ;Get the layers collection ) ;_ end of setq ;; Step through all blocks (including Model Space & Layouts) (vlax-for blk blocks ;; Step through all contained entities in block (vlax-for eo blk ;; Get the layer the entity is placed on (setq lay (vla-Item layers (vla-get-Layer eo))) (vla-put-Layer eo (getvar "CLAYER")) ;Change the entity to the current layer (if (= (vla-get-Color eo) 256) ;;If its colour bylayer, change it to overridden color to match (vla-put-Color eo (vla-get-color lay)) ) ;_ end of if (if (= (strcase (vla-get-Linetype eo)) "BYLAYER") ;;If its linetype bylayer, change it to overridden linetype to match (vla-put-Linetype eo (vla-get-Linetype lay)) ) ;_ end of if (if (= (vla-get-Lineweight eo) -1) ;;If its lineweight bylayer, change it to overridden lineweigth to match (vla-put-Lineweight eo (vla-get-Lineweight lay)) ) ;_ end of if ) ;_ end of vlax-for ) ;_ end of vlax-for (princ) ) ;_ end of defun which move all objects including blocks subentites to layer 0 or the current layer ..and change all bylayer colored objects to irrespective color but i apply for all the drawing with no selection i want the lisp to ask the user to select objects to apply to ... thanks in advance Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted January 8, 2016 Share Posted January 8, 2016 try this :- You can only change selected objects... Note- Objects within blocks won't be change, it will change the block color (if you have set to by block) and layer only. Cant change block entities as it will change the block definition and will reflect impact on other blocks too apart from selected blocks. Hope you got my point (defun c:test (/ a b i) (if (setq a (ssget)) (repeat (setq i (sslength a)) (setq b (vlax-ename->vla-object (ssname a (setq i (1- i))))) (vla-put-layer b "sat") ;Replace "0" with (getvar "CLAYER") for current layer (vla-put-color b 256) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
handasa Posted January 8, 2016 Author Share Posted January 8, 2016 (edited) @ satishrajdev thanks for your reply ... can you just modify my lisp to ask the user to select objects from drawing ? iam fairly new to lisps and its coding ... thanks in advacne Edited January 8, 2016 by handasa 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.