sense Posted December 27, 2010 Share Posted December 27, 2010 thank you:) Quote Link to comment Share on other sites More sharing options...
markv Posted December 27, 2010 Share Posted December 27, 2010 Here is some code that is useful for dynamic blocks. I may have gotten this from here but I don't remember for sure. ;----------------------------------------------------------- DynamicProps ----- ; Function retrieve or set properties from a dynamic block ; (DynamicProps (car (entsel)) "Visibility" nil) get the visibility states from a dynamic block ; (DynamicProps (car (entsel)) "Visibility" "Construction") set the visibility from a dynamic block ; (DynamicProps (car (entsel)) "" nil) get the properties from a dynamic block ; (DynamicProps (car (entsel)) "Pipe length" 2000.0) set the properties from a dynamic block (defun DynamicProps (ename propname value / obj prpL cla cll prp) (setq obj (if (= (type ename) 'VLA-OBJECT) ename (vlax-ename->vla-object ename))) (setq prpL (vlax-invoke obj 'getdynamicblockproperties)) (setq return (if (setq prp (vl-remove-if-not (function (lambda(x)(= (vlax-get-property x 'PropertyName) propname))) prpL)) (mapcar (function (lambda(v) (if (and (/= value nil)(vlax-property-available-p v 'Value)(/= (type value)'LIST)) (progn (vlax-put-property v 'Value value)(vla-update obj)) ) (if (and (vlax-property-available-p v 'AllowedValues) (vlax-get v 'AllowedValues)) (list (vlax-get v 'Value)(vlax-get v 'AllowedValues)) (vlax-get v 'Value) ) )) prp) (mapcar (function (lambda(v)(list (vla-get-propertyName v)(vlax-get v 'Value) v))) prpL) ) ) return ) ;------------------------------------------------ MWE:GetDBlockNames ------------------ ; Function for filtering dynamic blocks ; Arguments: 1 ; arglst = list met names ; Syntax: (MWE:GetDBlockNames '("Issue Stamp")) --> (("ISSUE STAMP" "*U833" "*U841") ;function by James Allen. ;;; Returns all names used for a dynamic block, including ;;; the actual block name and all anonymous instances. ;;; ;;; (setq names (MWE:GetDBlockNames (list bname))) ;;; ;;; bname = Str - Dynamic block name ;;; names = List - List of all inserted blocks whose ;;; EffectiveName = bname ;;; ;;; (setq names (MWE:GetDBlockNames '("TestDBlock"))) ;;; ("TestDBlock" "*U4" "*U5" "*U6") ;;; ;;; James Allen - 26Apr07 ;;; Malicoat-Winslow Engineers, P.C. ;;; ;;; Thanks to Joe Burke for pointing out code 331 ;;; and to Tony Tanzillo for prodding in that direction. ;;; (defun MWE:GetDBlockNames (arglst / blk edt enm ins name names) (mapcar 'set '(name) arglst) (setq names (list name) name (strcase name)) (vl-load-com) (vlax-for blk (vla-get-Blocks (vlax-get (vlax-get-Acad-Object) 'ActiveDocument)) (if (and (setq enm (tblobjname "block" (vla-get-Name blk))) (setq edt (entget enm)) (= (logand (cdr (assoc 70 edt)) 1) 1)) (if (and (setq edt (entget (vlax-vla-object->ename blk))) (setq enm (cdr (assoc 331 edt))) (setq ins (vlax-ename->vla-object enm)) (eq (vla-get-ObjectName ins) "AcDbBlockReference") (wcmatch (strcase (vla-get-EffectiveName ins)) name)) (setq names (cons (vla-get-Name blk) names)) ) ) ) (reverse names) ) ;end ;------------------------------------------------ BlockNamesFilter ------------------ ;; Argument example: ("TestDBlock" "*U4" "*U5" "*U6") ;; Returns: "TestDBlock,`*U4,`*U5,`*U6," (defun BlockNamesFilter (strlst) (apply 'strcat (mapcar '(lambda (x) (if (wcmatch x "`**,`?*")(strcat "`" x ",")(strcat x ","))) strlst) ) ) ;----------------------------------------------------------- ChangeVisibility ----- ;; Argument example: (ChangeVisibility "Issue Stamp" "Review") ;; Returns: number of changed states (defun ChangeVisibility (BlkName state / names ss ssl tempEnt) (setq names (MWE:GetDBlockNames (list BlkName))) (if (and (setq ss (ssget "P" (list '(0 . "INSERT")(cons 2 (BlockNamesFilter names))))) (> (setq ssl (sslength ss)) 0)) (progn (while (setq tempEnt (ssname ss 0)) (DynamicProps (vlax-ename->vla-object tempEnt) "Visibility" state) (ssdel tempEnt ss) ) (princ (strcat "\nChanged "(itoa ssl) " inserts to the visibility <" state ">.")) ssl ) (princ (strcat "\nInsert " BlkName " not found.")) ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 27, 2010 Author Share Posted December 27, 2010 Thanks Mark - I have this set of functions, but haven't dealt with visibility states in Dynamic Blocks too much is all. Quote Link to comment Share on other sites More sharing options...
spin Posted February 23, 2011 Share Posted February 23, 2011 hello after this line: Table? [Yes/No/Settings] : y i have error: ** Error: Too many actual parameters ** win7 64bit, autocad 2011 64bit, i use it on blocks with attributes Quote Link to comment Share on other sites More sharing options...
sadhu Posted February 23, 2011 Share Posted February 23, 2011 Just tried it got the same result as spin xf_D1...................................|.......5xf_D1-b.................................|.......1 xf_D3...................................|.......1 xf_D4...................................|.......1 xf_DA...................................|.......2 xf_E....................................|.......1 xf_E-a..................................|.......1 xf_E1...................................|.......3 xf_EA...................................|.......1 xf_ED...................................|.......1 xf_ED-a.................................|.......1 xf_door_ext_FIX.........................|.......1 zf_216..................................|.......1 zf_PARAPETTO-108........................|.......2 ----------------------------------------|-------- Table? [Yes/No/Settings] : y ** Error: Too many actual parameters ** The previous version is excellent. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2011 Author Share Posted February 23, 2011 I'll look into it guys Sadhu, Are you also running 64-bit? Quote Link to comment Share on other sites More sharing options...
Sittingbull Posted February 23, 2011 Share Posted February 23, 2011 Lee Codes... got to luv them !!! Definitly going ninja on this. Thanks a lot Lee. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2011 Author Share Posted February 23, 2011 Haha! Cheers Sittingbull Quote Link to comment Share on other sites More sharing options...
SPACECADET Posted February 24, 2011 Share Posted February 24, 2011 Hi Lee, looks to be a great script. and if it produces a legend with pictures of blocks then I will be held in high regard at the office...ha ha. but at the moment I also get the Too many actual parameters error as 'spin' got and when picking fewer blocks as a test i get an empty table. AutoCAD 2011 win7 64 bit. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 24, 2011 Author Share Posted February 24, 2011 Ok, Thanks for the reports guys - it looks to be a 64-bit issue. The methods for the table are different for 32-bit and 64-bit systems, so I'll take a look into it and see if I can provide a fix in the near future. Thanks for the feedback! Lee Quote Link to comment Share on other sites More sharing options...
Croftyno1 Posted February 25, 2011 Share Posted February 25, 2011 Great lisp LEE, you are the DON!!! Im learning alot from your programs Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 25, 2011 Author Share Posted February 25, 2011 Great lisp LEE, you are the DON!!! Im learning alot from your programs Cheers Croftyno1 Glad to hear the program works for your system Quote Link to comment Share on other sites More sharing options...
sadhu Posted February 27, 2011 Share Posted February 27, 2011 Sadhu, Are you also running 64-bit? Yes, I am. Looking forward to your posts. [Autocad 2010 OS win Vista] Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 28, 2011 Author Share Posted February 28, 2011 Following these bug reports, I decided to heavily update the program. For this version I have completely rewritten the program to update the layout and code formatting, and furthermore added the ability to write the output data to a Text or CSV file of the user's choice. This version is a 'Beta' version however, since I have changed the method to create a Table Block Preview and I don't have a 64-bit system on which the test the code, so there might well be some error's for users running 64-bit machines. If you are using a 64-bit environment, if possible I would kindly ask if you could test the Beta program (as linked in the first post), and, if the program works, please let me know the ACAD Version you are using; or, if the program errors, please post the error message (and the Line# of the error if possible), and again, which ACAD Version you are using. I hope the program can benefit your workflow. Kind Regards, Lee Quote Link to comment Share on other sites More sharing options...
SPACECADET Posted March 1, 2011 Share Posted March 1, 2011 Lee, Have just done quick test. It does seem to label and count all the blocks correctly and list them in the autocad text window, but when I output to a table with preview to create legend I get a blank table with the following error. Specify Point for Table: ; error: Exception occurred: 0xC0000005 (Access Violation) ; warning: unwind skipped on exception ; error: Exception occurred: 0xC0000005 (Access Violation) AutoCAD 2011 Win 7 64 Bit Hope this helps your development. Quote Link to comment Share on other sites More sharing options...
spin Posted March 1, 2011 Share Posted March 1, 2011 I tested beta version on win 7 64bit, autocad 2011 64bit. Export to csv works good, export to table without block preview works good, export to table with block preview ends with bugs: Command: COUNT Select Blocks to Count <All> : Block Name.............................................Count ------------------------------------------------------------ CPEL_2814..................................................1 el - glosnik...............................................1 el - sap centrala pozarowa.................................1 el - sap czujka dymu.......................................4 el - sap czujka dymu 520...................................1 el - sap czujka dymu miedzystropowa........................5 el - sap czujka dymu miedzystropowa 2......................1 el - sap czujka dymu miedzystropowa 3......................1 el - sap czujka dymu miedzystropowa 4......................1 el - sap przelacznik wentylacji............................1 el - sap rop...............................................2 el - sap rop 2.............................................1 el - sap rpo...............................................2 el - sap sygnalizator akustyczny...........................1 el - sap sygnalizator optyczny.............................1 ------------------------------------------------------------ Output [Table/File/Settings] <Exit>: s Output [Table/File/Settings] <Exit>: t Specify Point for Table: ; error: Exception occurred: 0xC0000005 (Access Violation) ; warning: unwind skipped on exception ; error: Exception occurred: 0xC0000005 (Access Violation) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 1, 2011 Author Share Posted March 1, 2011 Thanks for the feedback guys - I'm working on it Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 2, 2011 Share Posted March 2, 2011 Tested on Win 7 64 bit autocad2010 Export to file works with and without Block Preview / tableTitle activated. While "table" works with "Block Preview" not activated. "table" with "Block Preview" activated I get empty table with this message ximpianti elettrico.......................................29zf_108.....................................................1 zf_216.....................................................2 ------------------------------------------------------------ Output [Table/File/Settings] : s Output [Table/File/Settings] : t Specify Point for Table: ; error: Exception occurred: 0xC0000005 (Access Violation) ; warning: unwind skipped on exception ; error: Exception occurred: 0xC0000005 (Access Violation) Command: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 2, 2011 Author Share Posted March 2, 2011 Thanks for the report Sadhu, appreciated. Its the method to implement the Block Preview on 64-bit systems that is causing the problems - everything is working fine on my 32-bit system. I'm still working on it and will hopefully have it sorted soon. Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 2, 2011 Author Share Posted March 2, 2011 Please try the updated code (Version 1.3) My thanks go to Jeff_M at theSwamp for helping me hopefully fix the issues with the Block Preview. Lee 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.