kimmmmm 0 Posted April 8 (edited) hi. first of all,i don't know about lisp. really beginer i found some lisp and changed some command but i want to change layer inside blocks could you please give me advice ? or does someone have lisp for changing layer inside blocks? (DEFUN C:lll () (setvar "cmdecho" 1) (setq olderr *error* *error* CHGTERR) (if (tblsearch "ltype" "DASHED") (progn (command "._chprop" (ssget "X" '((6 . "DASHED"))) "" "LT" "ByLayer" "s" "0.2" "la" "HIDDEN" "") );end progn );end if ; (if (tblsearch "ltype" "CENTER") (progn (command "._chprop" (ssget "X" '((6 . "CENTER"))) "" "LT" "ByLayer" "s" "0.2" "la" "CENTER" "") );end progn );end if ; (if (tblsearch "ltype" "PHANTOM") (progn (command "._chprop" (ssget "X" '((6 . "PHANTOM"))) "" "LT" "ByLayer" "s" "0.2" "la" "PHANTOM" "") );end progn );end if ; (if (tblsearch "ltype" "CONTINUOUS") (progn (command "._chprop" (ssget "X" '((6 . "CONTINUOUS"))) "" "LT" "ByLayer" "s" "0.2" "la" "0" "") );end progn );end if ; (COMMAND "-PURGE" "ALL" "" "N") (COMMAND "REGEN") ; );END DEFUN Edited April 8 by kimmmmm Quote Share this post Link to post Share on other sites
Lee Mac 471 Posted April 8 When operating on objects nested within block definitions in addition to primary objects, it typically becomes easier to iterate over the ActiveX Block Collection, e.g.: (defun c:fixlay ( / doc lay lst ltp lyr ) (setq lst '( "DASHED" "CENTER" "PHANTOM" ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) lyr (vla-get-layers doc) ) (vlax-for blk (vla-get-blocks doc) (if (= :vlax-false (vla-get-isxref blk)) (vlax-for obj blk (if (and (member (setq ltp (strcase (vla-get-linetype obj))) lst) (vlax-write-enabled-p obj) (or (member ltp lay) (and (vla-add lyr ltp) (setq lay (cons ltp lay)) ) ) ) (progn (vla-put-linetype obj "bylayer") (vla-put-linetypescale obj 0.2) (vla-put-layer obj ltp) ) ) ) ) ) (princ) ) (vl-load-com) (princ) 2 Quote Share this post Link to post Share on other sites
kimmmmm 0 Posted April 11 (edited) thank you so much . DASHED have to be changed layer [HIDDEN] layer with line type DSHED change to DASHED. Edited April 11 by kimmmmm Quote Share this post Link to post Share on other sites
Lee Mac 471 Posted April 12 16 hours ago, kimmmmm said: thank you so much . DASHED have to be changed layer [HIDDEN] layer with line type DSHED change to DASHED. You're welcome To account for cases in which the target layer differs from the source linetype, consider the following: (defun c:fixlay ( / doc itm lay lst lyr ) (setq lst '( ;; Source Linetype Target Layer ("DASHED" "HIDDEN" ) ("CENTER" "CENTER" ) ("PHANTOM" "PHANTOM") ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) lyr (vla-get-layers doc) ) (vlax-for blk (vla-get-blocks doc) (if (= :vlax-false (vla-get-isxref blk)) (vlax-for obj blk (if (and (setq itm (cadr (assoc (strcase (vla-get-linetype obj)) lst))) (vlax-write-enabled-p obj) (or (member itm lay) (and (vla-add lyr itm) (setq lay (cons itm lay)) ) ) ) (progn (vla-put-linetype obj "bylayer") (vla-put-linetypescale obj 0.2) (vla-put-layer obj itm) ) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Share this post Link to post Share on other sites
kimmmmm 0 Posted April 13 This is perfect. I can dance now Thanks a lot. It was lisp I had been searching for a long time Quote Share this post Link to post Share on other sites