Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamic Blocks Change Visibility State

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mid-awe
2532 Views, 3 Replies

Dynamic Blocks Change Visibility State

Hi all,

 

I've been ignoring an issue and now I must solve this. I have 4 Dynamic Blocks with the same name, but each are on different layout pages. 

 

I need to change the visibility state of all 4 to the same value. So far every attempt of mine has failed.

 

My process at this point is to:

  1. build a selectionset of all 4 Dynamic Blocks with the same effective name,
  2. convert the selectionset to a list of entity names, then
  3. use a foreach to change the visibility states one at a time.

Currently, I get "error: bad argument type: lselsetp <Entity name: 7ffff7b6c90>". <Entity name: 7ffff7b6c90> is the entity name of the first block in the list. I'm guessing it's because the block is found on a non-current tab.

 

(defun chgdynprop (e propname newval / obj v vval sal tot i)
  (setq	obj (if	(= (type e) 'vla-object) e (vlax-ename->vla-object e)))
  (if (= (vlax-get-property obj 'isdynamicblock) :vlax-true)
    (progn
      (setq v	 (vla-getdynamicblockproperties obj)
	    vval (vlax-variant-value v)
	    sal	 (vlax-safearray->list vval)
	    tot	 (length sal)
	    i	 0
      )
      (while (< i tot)
	(if (= (vlax-get-property (nth i sal) "PropertyName") propname)
	  (progn
	    (vlax-put-property (nth i sal) "Value" newval)
	    (setq i tot)
	  )
	  (setq i (1+ i))
	)
      )
    )
  )
) ;|I do not know the author of this function in order to give credit - it's an oldie|;

The solution would be to enable the above function to operate on the named entity no matter which layout tab it is located on.

 

How can I modify this function?

 

Thank you in advance.

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: mid-awe

Try

 

(if YourSelectionSet
  (vlax-for n (vla-get-activeselectionset
		(vla-get-activedocument
		  (vlax-get-acad-object)
		)
	      )
    (chgdynprop n "Prop Name" "New value")
  )
)

 Henrique

EESignature

Message 3 of 4
mid-awe
in reply to: hmsilva

Thank you Henrique =D
That did it. Thank you so very much.
Message 4 of 4
hmsilva
in reply to: mid-awe

You're welcome, mid-awe
glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost