notredave Posted August 20, 2019 Share Posted August 20, 2019 Good morning all, We work with drawings that go thru status cycles. We send drawings to the client for approval and then we flip the drawings for construction. My question is, since this happens a lot, would there be a way to change dynamic stamp attached from "IFA" to "IFC". I will be going in manually next week into 82 drawings to change dynamic stamp after and if we receive any client comments back. I have used Lee Mac's bfind to change date on stamp with success, so date is not an issue. If someone will please help, I would so much appreciate it. Thank you, David STAMP.dwg Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted August 20, 2019 Share Posted August 20, 2019 I'm not sure what you asking from us. Sure, I can make a lisp routine that will change the visibility state to value "IFC". Is that all you're asking? Because using the button is just as easy as loading the routine and executing it. Or do you want a routine that opens all 82 drawings and auto performs that routine (which is harder)? Quote Link to comment Share on other sites More sharing options...
notredave Posted August 20, 2019 Author Share Posted August 20, 2019 Emmanuel, thank you for replying. I would like a lisp to change dynamic stamp from IFA to IFC. I, then can use Lee Mac's script writer to open all the drawings in directory, load the lisp and execute. If lisp can include the date I need would be a bonus but that might be asking to much. I appreciate your reply. Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted August 20, 2019 Share Posted August 20, 2019 (edited) Okay, like this Command SDSV, for Set Dynamic Stamp Value (bottom function) It will change all the stamps in the dwg. Perhaps you have a stamp on each Layout, but you're currently on model space. Regardless, it will change all. (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GET ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Dynamic Block Property Allowed Values - Lee Mac ;; Returns the allowed values for a specific Dynamic Block property. ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; Returns: [lst] List of allowed values for property, else nil if no restrictions (defun LM:getdynpropallowedvalues ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'allowedvalues))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Visibility Parameter Name - Lee Mac ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Name of Visibility Parameter, else nil (defun LM:getvisibilityparametername ( blk / vis ) (if (and (vlax-property-available-p blk 'effectivename) (setq blk (vla-item (vla-get-blocks (vla-get-document blk)) (vla-get-effectivename blk) ) ) (= :vlax-true (vla-get-isdynamicblock blk)) (= :vlax-true (vla-get-hasextensiondictionary blk)) (setq vis (vl-some '(lambda ( pair ) (if (and (= 360 (car pair)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair))))) ) (cdr pair) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary blk)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget vis))) ) ) ;; Get Dynamic Block Visibility State - Lee Mac ;; Returns the value of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Value of Visibility Parameter, else nil (defun LM:getvisibilitystate ( blk / vis ) (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SET ;; Set Dynamic Block Visibility State - Lee Mac ;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed) ;; blk - [vla] VLA Dynamic Block Reference object ;; val - [str] Visibility State Parameter value ;; Returns: [str] New value of Visibility Parameter, else nil (defun LM:SetVisibilityState ( blk val / vis ) (if (and (setq vis (LM:getvisibilityparametername blk)) (member (strcase val) (mapcar 'strcase (LM:getdynpropallowedvalues blk vis))) ) (LM:setdynpropvalue blk vis val) ) ) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Effective Block Name - Lee Mac ;; obj - [vla] VLA Block Reference object (defun LM:effectivename ( obj ) (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set Dynamic Stamp Value (defun c:sdsv ( / ss blockname val i obj) ;; settings (setq blockname "Dynamic Stamp") (setq val "IFC") (setq ss (ssget "_X" (list '(0 . "INSERT") ))) ;; selection of all blocks on the dwg, even if you're not on the right layout (model/paper) (setq i 0) (repeat (sslength ss) (setq obj (vlax-ename->vla-object (ssname ss i))) (if (= blockname (LM:effectivename obj)) ;; for dynamic blocks you need to know the effective name, (assoc 2 entity) doesn't get you what you need (LM:SetVisibilityState obj val) ) (setq i (+ i 1)) ) (princ) ) Edited August 20, 2019 by Emmanuel Delay 1 Quote Link to comment Share on other sites More sharing options...
notredave Posted August 20, 2019 Author Share Posted August 20, 2019 Emmanuel, you are awesome. It works like a charm! Could a line be added to code to include date? I'm sorry for being picky but it would eliminate me using Lee's bfind. If it's to much trouble, please don't worry at all. Thank you much!!! 1 Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted August 20, 2019 Share Posted August 20, 2019 Sure. In case you want month/day/year (I'm not sure), change in function current_date: (setq txt (strcat day "/" mth "/" yer)) to (setq txt (strcat mth "/" day "/" yer)) (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GET ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Dynamic Block Property Allowed Values - Lee Mac ;; Returns the allowed values for a specific Dynamic Block property. ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; Returns: [lst] List of allowed values for property, else nil if no restrictions (defun LM:getdynpropallowedvalues ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'allowedvalues))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Visibility Parameter Name - Lee Mac ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Name of Visibility Parameter, else nil (defun LM:getvisibilityparametername ( blk / vis ) (if (and (vlax-property-available-p blk 'effectivename) (setq blk (vla-item (vla-get-blocks (vla-get-document blk)) (vla-get-effectivename blk) ) ) (= :vlax-true (vla-get-isdynamicblock blk)) (= :vlax-true (vla-get-hasextensiondictionary blk)) (setq vis (vl-some '(lambda ( pair ) (if (and (= 360 (car pair)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair))))) ) (cdr pair) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary blk)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget vis))) ) ) ;; Get Dynamic Block Visibility State - Lee Mac ;; Returns the value of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Value of Visibility Parameter, else nil (defun LM:getvisibilitystate ( blk / vis ) (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SET ;; Set Dynamic Block Visibility State - Lee Mac ;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed) ;; blk - [vla] VLA Dynamic Block Reference object ;; val - [str] Visibility State Parameter value ;; Returns: [str] New value of Visibility Parameter, else nil (defun LM:SetVisibilityState ( blk val / vis ) (if (and (setq vis (LM:getvisibilityparametername blk)) (member (strcase val) (mapcar 'strcase (LM:getdynpropallowedvalues blk vis))) ) (LM:setdynpropvalue blk vis val) ) ) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set Attribute Value - Lee Mac ;; Sets the value of the first attribute with the given tag found within the block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; val - [str] Attribute Value ;; Returns: [str] Attribute value if successful, else nil. (defun LM:vl-setattributevalue ( blk tag val ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (progn (vla-put-textstring att val) val) ) ) (vlax-invoke blk 'getattributes) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Effective Block Name - Lee Mac ;; obj - [vla] VLA Block Reference object (defun LM:effectivename ( obj ) (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun current_date () (setq cd (getvar "CDATE") dte (rtos cd 2 4) ;; yer (substr dte 1 4) ;; in case you want the full year yer (substr dte 3 2) ;; in case you want the 2 digits year mth (substr dte 5 2) day (substr dte 7 2) ) (setq txt (strcat day "/" mth "/" yer)) ) ;; Set Dynamic Stamp Value (defun c:sdsv ( / ss blockname val i obj datetag) ;; settings (setq blockname "Dynamic Stamp") (setq val "IFC") (setq datetag "DATE") (setq ss (ssget "_X" (list '(0 . "INSERT") ))) ;; selection of all blocks on the dwg, even if you're not on the right layout (model/paper) (setq i 0) (repeat (sslength ss) (setq obj (vlax-ename->vla-object (ssname ss i))) (if (= blockname (LM:effectivename obj)) ;; for dynamic blocks you need to know the effective name, (assoc 2 entity) doesn't get you what you need (progn (LM:SetVisibilityState obj val) (LM:vl-setattributevalue obj datetag (current_date)) ) ) (setq i (+ i 1)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
notredave Posted August 20, 2019 Author Share Posted August 20, 2019 Emmanuel, I changed this like you said (defun current_date () (setq cd (getvar "CDATE") dte (rtos cd 2 4) ;; yer (substr dte 1 4) ;; in case you want the full year yer (substr dte 3 2) ;; in case you want the 2 digits year mth (substr dte 5 2) day (substr dte 7 2) ) (setq txt (strcat 09 "/" 05 "/" 19)) ) But, i get this error: ; error: bad argument type: stringp 9 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 20, 2019 Share Posted August 20, 2019 Hi, This should be more than enough I believe. (defun c:Stamp ( / sel int ent obj) ;; Tharwat - Date: 20.Aug.2019 ;; (and (setq int -1 sel (ssget "_X" '((0 . "INSERT") (66 . 1)))) (while (setq int (1+ int) ent (ssname sel int)) (and (= (vla-get-EffectiveName (setq obj (vlax-ename->vla-object ent))) "Dynamic Stamp") (vl-some '(lambda (x) (if (= (vla-get-propertyname x) "Visibility1") (progn (vlax-put x 'Value "IFC") t))) (vlax-invoke obj 'getdynamicBlockproperties)) (foreach att (vlax-invoke obj 'getattributes) (and (= (vla-get-tagstring att) "DATE") (vla-put-textstring att "20/08/19")) ) ) ) ) (princ) ) (vl-load-com) 1 Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted August 20, 2019 Share Posted August 20, 2019 (edited) The error you're getting, is because you cannot string concatenate (function strcat) numbers. Nor do you want to put that in the function current_date If you want a fixed date (for example 09/05/19), (LM:vl-setattributevalue obj datetag "09/05/19") Edited August 20, 2019 by Emmanuel Delay Quote Link to comment Share on other sites More sharing options...
notredave Posted August 20, 2019 Author Share Posted August 20, 2019 Unbelievable!!! I want to thank you very much Tharwat and Emmanuel for you contribution, you just have no idea how much time and effort this will save me next week and going into the future! You guys are awesome and so darn smart!!! They both work great and does exactly what I want it to do. Consider this thread closed. Thank you very much again, David 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 20, 2019 Share Posted August 20, 2019 Why are you not using an xref for this? Make a change in one place and 82 drawings are done... Quote Link to comment Share on other sites More sharing options...
notredave Posted August 20, 2019 Author Share Posted August 20, 2019 ronjonp, that would make it a lot easier, lol. WOW, I feel like an idiot, thank you very much for suggestion and responding! I really appreciate it. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 20, 2019 Share Posted August 20, 2019 10 minutes ago, notredave said: ronjonp, that would make it a lot easier, lol. WOW, I feel like an idiot, thank you very much for suggestion and responding! I really appreciate it. Hahaha ... well maybe for the next project . Do you use an xref for your titleblock? If so then this could still work! Quote Link to comment Share on other sites More sharing options...
notredave Posted August 20, 2019 Author Share Posted August 20, 2019 no, title blocks are not xrefed Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 20, 2019 Share Posted August 20, 2019 35 minutes ago, notredave said: no, title blocks are not xrefed Next project use xrefs .. they are prefect for this type of work. Quote Link to comment Share on other sites More sharing options...
notredave Posted August 20, 2019 Author Share Posted August 20, 2019 ronjonp, are you saying that I can't xref all 82 drawings and change dynamic stamp data? If so, do you recall a post where making a change that will fix all drawings xrefed? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 20, 2019 Share Posted August 20, 2019 6 minutes ago, notredave said: ronjonp, are you saying that I can't xref all 82 drawings and change dynamic stamp data? If so, do you recall a post where making a change that will fix all drawings xrefed? I just figured you have a workable lisp solution so next time around you'll maybe think to organize differently and you won't need code to do this. If this project is ongoing, you might want to convert to xrefs. Don't know your situation though. Quote Link to comment Share on other sites More sharing options...
3D Jack Posted March 20, 2020 Share Posted March 20, 2020 I created programs that display every attribute in a title block available to edit in a dialog box. The user makes the changes and picks okay and whatever they changed is updated. I also have a batch processing routine that allows you to do a SETUP of what you want changed in a title block and then it processes all of the dwgs in the folder and makes those changes. If you go to youtube and look for "3djackfoster" you can see a short video that shows some of what the programs do. What I have done for a couple of companies is take their title block and a copy of my program. I then substitute their attribute names in my program so it works on their title blocks. The few I have done it for have loved it. If you want to check out comments about this I am on the Autodesk Services Marketplace and there are some 5 star comments. It can take several hours and over a day to do this so I do charge. I totally agree if you can get something for free that does what you want then go for it. I do the same thing but when I developed these programs I was working with huge title blocks with 100+ attributes and it was pure hell to edit them manually. Hope this doesn't offend or PO anyone. Trying to help if I can you just have to decide how big of a problem it is. I can tell you one company had 75 dwgs that needed 5 revisions added to all of them. They were looking at nearly a day to do such. Did a setup with my program and batch ran it. Went back to work on main computer and checked a half hour later and all were done. MUCH EASIER. Good luck to you whatever you do. Quote Link to comment Share on other sites More sharing options...
issor10 Posted February 22 Share Posted February 22 ;;-----------=={ Updating Template Files }==------------------;; ;; ;; ;; ;; ;;------------------------------------------------------------;; ;; https://www.cadtutor.net/forum/topic/68530-can-this-be-done-with-dynamic-block/ ;; ;; All functions created by Lee Mac ;; (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GET ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Dynamic Block Property Allowed Values - Lee Mac ;; Returns the allowed values for a specific Dynamic Block property. ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; Returns: [lst] List of allowed values for property, else nil if no restrictions (defun LM:getdynpropallowedvalues ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'allowedvalues))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Visibility Parameter Name - Lee Mac ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Name of Visibility Parameter, else nil (defun LM:getvisibilityparametername ( blk / vis ) (if (and (vlax-property-available-p blk 'effectivename) (setq blk (vla-item (vla-get-blocks (vla-get-document blk)) (vla-get-effectivename blk) ) ) (= :vlax-true (vla-get-isdynamicblock blk)) (= :vlax-true (vla-get-hasextensiondictionary blk)) (setq vis (vl-some '(lambda ( pair ) (if (and (= 360 (car pair)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair))))) ) (cdr pair) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary blk)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget vis))) ) ) ;; Get Dynamic Block Visibility State - Lee Mac ;; Returns the value of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Value of Visibility Parameter, else nil (defun LM:getvisibilitystate ( blk / vis ) (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SET ;; Set Dynamic Block Visibility State - Lee Mac ;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed) ;; blk - [vla] VLA Dynamic Block Reference object ;; val - [str] Visibility State Parameter value ;; Returns: [str] New value of Visibility Parameter, else nil (defun LM:SetVisibilityState ( blk val / vis ) (if (and (setq vis (LM:getvisibilityparametername blk)) (member (strcase val) (mapcar 'strcase (LM:getdynpropallowedvalues blk vis))) ) (LM:setdynpropvalue blk vis val) ) ) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Effective Block Name - Lee Mac ;; obj - [vla] VLA Block Reference object (defun LM:effectivename ( obj ) (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set Dynamic Stamp Value (defun c:sdsv ( / ss blockname val i obj) ;; settings (setq blockname "TITLEBLOCK") (setq val "24X36") (setq ss (ssget "_X" (list '(0 . "INSERT") ))) ;; selection of all blocks on the dwg, even if you're not on the right layout (model/paper) (setq i 0) (repeat (sslength ss) (setq obj (vlax-ename->vla-object (ssname ss i))) (if (= blockname (LM:effectivename obj)) ;; for dynamic blocks you need to know the effective name, (assoc 2 entity) doesn't get you what you need (LM:SetVisibilityState obj val) ) (setq i (+ i 1)) ) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Return Paper Size ;; (defun pssize ( / CHECKINPUT VAL) ;; Get Input from the User (while (= CHECKINPUT "false") (setq VAL (getstring "\nWhat size sheet will you be using (22x34(22), 24x36(24), 30x42(30))?:")) (if (or (= VAL "22") (= VAL "24") (= VAL "30")) (setq CHECKINPUT "true") ) (if (= CHECKINPUT "false") (princ "\nEnter 22 for 22x34, 24 for 24x36, or 30 for 30x42\n") ) ) ;; Assign the correct layout name (cond ((= VAL "22") (setq VAL "22x34") ) ((= VAL "24") (setq VAL "24x36") ) ((= VAL "30") (setq VAL "30x42") ) ) ) ;; I did this to test it, but nothing is happening, and I don't know why (defun c:test10 ( / VAL ) (setq VAL pssize) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set X-BDRY ;; (defun c:bdry234 ( / SS BLOCKNAME VAL i OBJ CHECKINPUT) ;; settings (setq CHECKINPUT "false") ;; Get Input from the User (while (= CHECKINPUT "false") (setq VAL (getstring "\nWhat size sheet will you be using (22x34(22), 24x36(24), 30x42(30))?:")) (if (or (= VAL "22") (= VAL "24") (= VAL "30")) (setq CHECKINPUT "true") ) (if (= CHECKINPUT "false") (princ "\nEnter 22 for 22x34, 24 for 24x36, or 30 for 30x42\n") ) ) ;; Assign the correct layout name (cond ((= VAL "22") (setq VAL "22x34") ) ((= VAL "24") (setq VAL "24x36") ) ((= VAL "30") (setq VAL "30x42") ) ) (setq BLOCKNAME "TITLEBLOCK") (setq ss (ssget "_X" (list '(0 . "INSERT") ))) ;; selection of all blocks on the dwg, even if you're not on the right layout (model/paper) (setq i 0) (repeat (sslength SS) (setq obj (vlax-ename->vla-object (ssname SS i))) (if (= blockname (LM:effectivename OBJ)) ;; for dynamic blocks you need to know the effective name, (assoc 2 entity) doesn't get you what you need (LM:SetVisibilityState obj val) ) (setq i (+ i 1)) ) (princ) ) I am trying to use the above code to update my company's template drawings for multiple sheet sizes (22x34, 24x36, and 30x42). I ultimately want to create something similar to below with functions to easily update each of the different types of sheets that could be easily updated if there are any changes that occur-new blocks, new layout setups, etc. (defun c:x-bdry-update ( / papersize ) ;; Return 22x34, 24x36, or 30x42 - There could be other sizes/descriptions, but I can easily add those (setq papersize PSSIZE) ;; Update blocks based on paper size ;; Is it possible to create a function for this so that I can easily call it up ;; from setq BLOCKNAME "TITLEBLOCK" ;; I could have multiple blocks to update depending on the drawing I have open (function setblock ("blockname" papersize) ;; Set correct page setup ;; code below from Lee Mac (already works) (applypstolayouts papersize) (princ) ) (defun applypstolayouts ( cfg / doc rtn ) (if (setq rtn (not (vl-catch-all-error-p (setq cfg (vl-catch-all-apply 'vla-item (list (vla-get-plotconfigurations (setq doc (vla-get-activedocument (vlax-get-acad-object) ) ) ) cfg ) ) ) ) ) ) (vlax-for lay (vla-get-layouts doc) (if (= :vlax-false (vla-get-modeltype lay)) (vla-copyfrom lay cfg) ) ) ) (princ) ) Thanks for the help. 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.