Dynamic Block - Block Properties Table setting question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, I've been using a function from Mark Douglas from long ago with a few tweaks to modify dynamic block properties immediately after insertion -it works well for me with one exception: Block Property Tables. Now ya'll Know that Block Property Tables are different than lookup tables - those get processed quickly. However, when one of my blocks has a Block Property Table, modifying the settings just churns and churns for about 50x the time it rakes to run the program on any other set of properties.
I can tell that block property tables are safearrays (or that's what they seem to be to me). Somehow the code I use can change them but it is much slower than any other dynamic property. And more interestingly, I tried subbing in Lee Mac's LM:setdynpropvalue function instead of Mark Douglass' and with a little rewriting it works, but it actually seems a little slower yet.
Any Ideas why?
Here's a link to Lee's functions: http://www.lee-mac.com/dynamicblockfunctions.html
and here is the good old Mark Douglass code I have been using...
;_____________________________________________________________________________________________________________| ; ; Function for modifying dynamic blocks by: Mark Douglas (http://mdouglas.blogs.com/in_the_dynamic_interface/dynamic_blocks/page/2/) ; Tweeks by RapidCAD 2011 ; Modifies Prop values within the ModifyDynBlk function ;_____________________________________________________________________________________________________________| (defun setPropValue (oProps sProp Val / i oSBReferenceProperty sPName iFound) (setq i (vlax-safearray-get-l-bound oProps 1)) (setq iFound 0) (while (and (<= i (vlax-safearray-get-u-bound oProps 1)) (= iFound 0)) (setq oSBReferenceProperty (vlax-safearray-get-element oProps i)) (setq sPName (vla-get-PropertyName oSBReferenceProperty)) (if (= (strcase sPName) sProp);strcasex (progn (princ (vlax-variant-value (vla-get-value oSBReferenceProperty))) (vla-put-value oSBReferenceProperty (vlax-make-variant Val (vlax-variant-type (vla-get-value oSBReferenceProperty)) ) ) (princ (vlax-variant-value (vla-get-value oSBReferenceProperty))) (setq iFound 1) ) ) (setq i (1+ i)) ) (princ) ) ;_____________________________________________________________________________________________________________| ; ; Main function for modifying dynamic blocks by: Mark Douglas (http://mdouglas.blogs.com/in_the_dynamic_interface/dynamic_blocks/page/2/) ; Tweeks by RapidCAD 2011 ; this needs to be fed a two item list (but not a dotted pair) comprised of the dynamic block parameter ; followed by the desired value for that parameter. ; Called by every POI program after TPINSERT and after (SETQ ss (SSGET "L")) by embedment in (loopprops) ;_____________________________________________________________________________________________________________| (defun ModifyDynBlk ( lstProp / index cnt oBkRef oProps i j oSBReferenceProperty e) (vl-load-com) (setq index 0 cnt (sslength ss) ) (while (< index cnt) (setq e (ssname ss index)) (setq oBkRef (vlax-ename->vla-object e)) (setq oProps (vlax-variant-value (vla-GetDynamicBlockProperties oBkRef))) (setq i (vlax-safearray-get-l-bound oProps 1)) (while (<= i (vlax-safearray-get-u-bound oProps 1)) (setq oSBReferenceProperty (vlax-safearray-get-element oProps i)) (setq i (1+ i)) ) (setq j 0) (while (< j (length lstProp)) (setq sProp (strcase (nth j lstProp)));strcasex (setPropValue oProps sProp (nth (+ 1 j) lstProp));(LM:setdynpropvalue oBkRef (vla-get-PropertyName oSBReferenceProperty) (nth (+ 1 j) lstProp)) (setq j (+ 2 j)) ) (setq index (1+ index)) ) (princ) ) ;_____________________________________________________________________________________________________________| ; ; Main Function to loop through dynamic block properties - must point to exact known property names and push ; correct values in the correct type of value (integer, real, string). Must be fed dbpl (a list of lists of ; block properties followed by their values (list (list "typ_width_bf" "28\"")(list "geo_nominal_width" "28"))) ;_____________________________________________________________________________________________________________| (defun loopprops (/ lcnt llen dbp) (setq lcnt 0) (setq llen (length dbpl)) (while (< lcnt llen) (setq dbp (nth lcnt dbpl)) (ModifyDynBlk dbp) (if (= lcnt llen) (ModifyDynBlk dbp) ) (setq lcnt (+ lcnt 1)) (princ)) )
Any help greatly appreciated.