bigmaz Posted August 22, 2012 Posted August 22, 2012 Hi guys, I am using this lisp: ;;published by kpblc ;;http://www.arcada.com.ua/forum/viewtopic.php?t=526 (defun c:normblocks (/ adoc answer lays lock lay *error* ans0 atype cnt) (defun *error* (msg)(princ msg) (if lock (foreach x lock (vla-put-lock x :vlax-true)))(vl-cmdf "_.Redraw")) (vl-load-com)(setq cnt 0) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (setq lays (vla-get-layers adoc)) (vla-startundomark adoc) (initget "LType LWeight Color All _ T W C A") (if (null (setq answer (getkword "\nIn blocks to lead to norm [LType/LWeight/Color/All] <All> : "))) (setq answer "A")) ;_ end of if (initget "byLayer byBlock") (setq atype (getkword "\nSet contents inside the block to [byLayer/byBlock] <byBlock>:")) (initget "Yes No") (setq ans0 (getkword "\nChange entities layer's to 0? [Yes/No] <No>:")) (vlax-for item (vla-get-blocks adoc) (if (not (wcmatch (strcase (vla-get-name item) t) "*_space*")) (progn (setq cnt (1+ cnt)) (grtext -1 (strcat "Modyfied " (vla-get-name item))) (vlax-for sub_item (vla-item (vla-get-blocks adoc) (vla-get-name item)) (setq lay (vla-item lays (vla-get-layer sub_item))) (if (= (vla-get-lock lay) :vlax-true) (progn (vla-put-lock lay :vlax-false)(setq lock (cons lay lock)))) (if (= ans0 "Yes")(vla-put-Layer sub_item "0")) (cond ((= answer "W") (vla-put-LineWeight sub_item (if (= atype "byLayer") acLnWtByLayer aclnwtbyblock)) ) ((= answer "T") (vla-put-linetype sub_item (if (= atype "byLayer") "ByLayer" "ByBlock")) ) ((= answer "C") (vla-put-color sub_item (if (= atype "byLayer") acByLayer acByBlock)) ) (t (vla-put-LineWeight sub_item (if (= atype "byLayer") acLnWtByLayer aclnwtbyblock)) (vla-put-linetype sub_item (if (= atype "byLayer") "ByLayer" "ByBlock")) (vla-put-color sub_item (if (= atype "byLayer") acByLayer acByBlock)) ) ) ;_ end of cond ) ;_ end of vlax-for ) ) ;_ end of if ) ;_ end of vlax-for (if lock (foreach x lock (vla-put-lock x :vlax-true))) (vla-regen adoc acallviewports) (vla-endundomark adoc)(vl-cmdf "_.Redraw") (princ (strcat "\nModyfied " (itoa cnt) " blocks")) (princ) ) ;_ end of defun It works great, but I want to add the ability to select what blocks I want to use the lisp on. Could someone please help me with this? Thanks Quote
bigmaz Posted August 22, 2012 Author Posted August 22, 2012 Anyone? Does what I said make sense by the way? Quote
BIGAL Posted August 23, 2012 Posted August 23, 2012 Just a guess change below. You will need to add myblockname request. (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) to (if (= (wcmatch (strcase (vla-get-name block) t) myblockname)) Quote
bigmaz Posted August 23, 2012 Author Posted August 23, 2012 I get an error when I use that "bad argument type: VLA-OBJECT nil" All I want is to modify the lisp so I am able to select manually what blocks the lisp effects. At the moment, it does every block in the drawing, I want to be able to choose what ones I want to change. Quote
BIGAL Posted August 24, 2012 Posted August 24, 2012 What did you do for myblockname was it "partasdf" or did you set as a variable using setq this is a string "*_space*" any block with a _space in its name if so dont change you can do "partasdf" Quote
bigmaz Posted August 24, 2012 Author Posted August 24, 2012 Sorry, not sure what you mean. will this let me choose what blocks I want to change manually with the cursor? 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.