Dynamic Block - Block Properties Table setting question

Dynamic Block - Block Properties Table setting question

rapidcad
Collaborator Collaborator
1,320 Views
3 Replies
Message 1 of 4

Dynamic Block - Block Properties Table setting question

rapidcad
Collaborator
Collaborator

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.

 

 

ADN CAD Developer/Operator
0 Likes
1,321 Views
3 Replies
Replies (3)
Message 2 of 4

rapidcad
Collaborator
Collaborator

I was kinda afraid that nobody knows much about these...

ADN CAD Developer/Operator
0 Likes
Message 3 of 4

rapidcad
Collaborator
Collaborator

The more I think about it, I start wondering if the program isn't hanging up on the block property table object as it cycles through different dynamic properties. If I am correct and the block property table is a safearray, while the rest of the dynamic properties are not, then it would probably hang up while trying to process it. Maybe I can find a way to exclude it from the list of properties to check and change. I actually do not change the table objet itself, just every property listed in the table gets changed and AutoCAD automatically recognizes that one line in the table is correct and AutoCAD lights up that line in the table wen you check the grip.

 

I wonder if anyone else ever uses lisp to change these...

ADN CAD Developer/Operator
0 Likes
Message 4 of 4

rapidcad
Collaborator
Collaborator

By trial and error I am finding that the real slowdown seems to be with the use of "USER PARAMETERS". If I stop setting only them, these blocks go in smoothly with the Lisp setting the rest of the dynamic block property values. So why do these hang up like that?

User ParametersUser Parameters

I have the tables set like so, but that is the only way they work correctly when you set the table anyway...

 

Block Property Table SettingsBlock Property Table Settings

So is there something about User Parameters that needs to be handled differently? The Lisp does set their values but they are quite slow in bigger drawings.

 

 

ADN CAD Developer/Operator
0 Likes