kimmmmm Posted April 8, 2021 Posted April 8, 2021 (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, 2021 by kimmmmm Quote
Lee Mac Posted April 8, 2021 Posted April 8, 2021 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
kimmmmm Posted April 11, 2021 Author Posted April 11, 2021 (edited) thank you so much . DASHED have to be changed layer [HIDDEN] layer with line type DSHED change to DASHED. Edited April 11, 2021 by kimmmmm Quote
Lee Mac Posted April 12, 2021 Posted April 12, 2021 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) 1 1 Quote
kimmmmm Posted April 13, 2021 Author Posted April 13, 2021 This is perfect. I can dance now Thanks a lot. It was lisp I had been searching for a long time Quote
kimmmmm Posted July 15, 2021 Author Posted July 15, 2021 hello.Lee MAC. I need your help one more time. please It was helpful that you made this lisp. and I wonder that it is possible to change the layer of the selected block ? not all of layer. Quote
BIGAL Posted July 15, 2021 Posted July 15, 2021 (edited) Lee can be very busy but if you want to ask him direct then go to his web site www.Lee-Mac.com and contact him there. Else "I have this great lisp done by lee-mac and I wonder that it is possible to change the layer of the selected block ? not all of layer." Edited July 15, 2021 by BIGAL Quote
Lee Mac Posted July 15, 2021 Posted July 15, 2021 Try something like this (untested): (defun c:fixlay ( / blk def doc ent itm lay lst lyr obj ) (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) blk (vla-get-blocks doc) ) (while (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil ) ( (/= "INSERT" (cdr (assoc 0 (entget ent)))) (princ "\nThe selected object is not a block.") ) ( (progn (setq obj (vlax-ename->vla-object ent) def (vla-item blk (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name))) ) (= :vlax-true (vla-get-isxref def)) ) (princ "\nThe selected block is an external reference.") ) ( t (vlax-for obj def (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) ) ) ) (vla-regen doc acactiveviewport) ) ) ) ) (princ) ) (vl-load-com) (princ) 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.