Looking for a lisp file to change a dynamic block visibility.

Looking for a lisp file to change a dynamic block visibility.

gmclellanT542G
Contributor Contributor
1,481 Views
2 Replies
Message 1 of 3

Looking for a lisp file to change a dynamic block visibility.

gmclellanT542G
Contributor
Contributor

Hello,

I'm currently looking for a lisp routine to change the visibility of a dynamic block.

 

My dynamic blocks name are "ansi_a", "ansi_b" & "arch_d"

The visibility parameter is called "VIS_LOGO"

The visibility state is called "FILTER VESSEL"

 

In another post, @Lee_Mac had stated if all these were known, you could use, "set dynamic block visibility state" by itself. This is what I think it should look like using his code, but I have no idea. I don't need to insert the blocks, just modify the visibility. I also don't know what I need to change in the code, like all the "blk" instances, do they need to be changed to the block name, "ansi_a"? and so on for "vis" and "var"?

 

Thanks in advance!

 

(defun c:changevis ( / idx lst obj sel vis )
(setq lst
'(
("ANSI_A" . "FILTER VESSEL")
("ANSI_B" . "FILTER VESSEL")
("ARCH_D" . "FILTER VESSEL")
)
)
(if
(setq sel
(ssget "_X"
(append
'(
(000 . "INSERT")
(-04 . "<OR")
(002 . "`*U*")
)
(mapcar '(lambda ( x ) (cons 2 (car x))) lst)
'(
(-004 . "OR>")
(410 . "~Model")
)
)
)
)
(repeat (setq idx (sslength sel))
(if (setq idx (1- idx)
obj (vlax-ename->vla-object (ssname sel idx))
vis (cdr (assoc (strcase (LM:blockname obj)) lst))
)
(LM:SetVisibilityState obj vis)
)
)
)
(princ)
)

;; 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)
)

 

0 Likes
Accepted solutions (1)
1,482 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this. Post a test drawing if negative result.

 

(vl-load-com)

(defun c:VislogoVessel ( / n s i e )

  (if (setq n "ansi_a,ansi_b,arch_d"
	    s (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," n)))))
    (repeat (setq i (sslength s))
      (and (setq e (ssname s (setq i (1- i))))
	   (wcmatch (getpropertyvalue e "BlockTableRecord/Name") n)
	   (vl-catch-all-apply 'setpropertyvalue (list e "AcDbDynBlockPropertyVIS_LOGO" "FILTER VESSEL")))))
  (princ)
  )

 

Message 3 of 3

gmclellanT542G
Contributor
Contributor

Thank you soo much @BeekeeCZ!! Worked perfectly!

 

I have to take a course on this stuff, lol.

0 Likes