<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Setting multiple visibility states to a group of items? in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9942404#M66367</link>
    <description>&lt;P&gt;Has anyone come up with a way to pick a group of objects and assign them as "Visible" in several visibility states at once?&amp;nbsp; I am doing a lot of very-involved dynamic block authoring.&amp;nbsp; All of my blocks have at least eight visibility states, and it would be great to (for example) select a rectangle inside a block, then say "I need this 'VISIBLE' in these 6 states only" in one fell swoop.&amp;nbsp; Thanks for any advice!&lt;/P&gt;</description>
    <pubDate>Tue, 15 Dec 2020 21:08:52 GMT</pubDate>
    <dc:creator>matthew_neesley</dc:creator>
    <dc:date>2020-12-15T21:08:52Z</dc:date>
    <item>
      <title>Setting multiple visibility states to a group of items?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9942404#M66367</link>
      <description>&lt;P&gt;Has anyone come up with a way to pick a group of objects and assign them as "Visible" in several visibility states at once?&amp;nbsp; I am doing a lot of very-involved dynamic block authoring.&amp;nbsp; All of my blocks have at least eight visibility states, and it would be great to (for example) select a rectangle inside a block, then say "I need this 'VISIBLE' in these 6 states only" in one fell swoop.&amp;nbsp; Thanks for any advice!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 21:08:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9942404#M66367</guid>
      <dc:creator>matthew_neesley</dc:creator>
      <dc:date>2020-12-15T21:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple visibility states to a group of items?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9942971#M66368</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5074605"&gt;@matthew_neesley&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sounds like layering will be your best friend here. Have you tried that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 04:41:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9942971#M66368</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2020-12-16T04:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple visibility states to a group of items?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9943468#M66369</link>
      <description>&lt;P&gt;Here is something simple... quickly done.&lt;/P&gt;
&lt;P&gt;Two limitations...&lt;/P&gt;
&lt;P&gt;- since I don't know how to retrieve the name of the block currently being edited in the Block Editor (unless is typed&amp;nbsp; manually) - you need to use &lt;STRONG&gt;BEditSaveName&lt;/STRONG&gt; to enter the block editor&lt;/P&gt;
&lt;P&gt;- secondly, don't know how to get the current visible state. So the routine always sets the top one of the list when finished.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:&lt;STRONG&gt;BEditSaveName&lt;/STRONG&gt; ( / s blk vis nam)
  
  (princ "\nSelect a block, ")
  
  (if (and (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
	   (setq blk (vlax-ename-&amp;gt;vla-object (ssname s 0)))
	   (setq vis (LM:getvisibilityparametername blk))
	   (setq *ebn-lst* (LM:getdynpropallowedvalues blk vis))
	   (setq nam (LM:blockname blk))
	   )
    (command "_.bedit" nam))
  (princ)
  )


(defun c:&lt;STRONG&gt;VisibleStates&lt;/STRONG&gt; ( / *error* cmd s)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if cmd (setvar 'cmdecho cmd))
    (princ))
  
  (setq cmd (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  
  (if (and (setq s (ssget))
	   *ebn-lst*)
    (progn
      (foreach e *ebn-lst*
	(initget "No")
	(or (getkword (strcat "\nAdd object to '" e "' state [No] &amp;lt;yes&amp;gt;: "))
	    (command "_.bvstate" "_set" e
		     "_.bvshow" s "" "_current")))
      (command "_.bvstate" "_set" (car *ebn-lst*))))
  (setvar 'cmdecho 1)
  (princ)
  )


;; Block Name  -  Lee Mac
;; Returns the true (effective) name of a supplied block reference

(defun LM:blockname ( obj )
  (if (vlax-property-available-p obj 'effectivename)
    (defun LM:blockname ( obj ) (vla-get-effectivename obj))
    (defun LM:blockname ( obj ) (vla-get-name obj))
    )
  (LM:blockname obj)
  )


;; Get Dynamic Block Property Value  -  Lee Mac
;; Returns the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)

(defun LM:getdynpropvalue ( blk prp )
  (setq prp (strcase prp))
  (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
	   (vlax-invoke blk 'getdynamicblockproperties)
	   )
  )


;; Get Dynamic Block Properties  -  Lee Mac
;; Returns an association list of Dynamic Block properties &amp;amp; values.
;; blk - [vla] VLA Dynamic Block Reference object
;; Returns: [lst] Association list of (( . ) ... )

(defun LM:getdynprops ( blk )
  (mapcar '(lambda ( x ) (cons (vla-get-propertyname x) (vlax-get x 'value)))
	  (vlax-invoke blk 'getdynamicblockproperties)
	  )
  )


;; Get Dynamic Block Property Allowed Values  -  Lee Mac
;; Returns the allowed values for a specific Dynamic Block property.
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; Returns: [lst] List of allowed values for property, else nil if no restrictions

(defun LM:getdynpropallowedvalues ( blk prp )
  (setq prp (strcase prp))
  (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'allowedvalues)))
	   (vlax-invoke blk 'getdynamicblockproperties)
	   )
  )


;; Get Visibility Parameter Name  -  Lee Mac
;; Returns the name of the Visibility Parameter of a Dynamic Block (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; Returns: [str] Name of Visibility Parameter, else nil

(defun LM:getvisibilityparametername ( blk / vis )
  (if
    (and
      (vlax-property-available-p blk 'effectivename)
      (setq blk
	     (vla-item
	       (vla-get-blocks (vla-get-document blk))
	       (vla-get-effectivename blk)
	       )
	    )
      (= :vlax-true (vla-get-isdynamicblock blk))
      (= :vlax-true (vla-get-hasextensiondictionary blk))
      (setq vis
	     (vl-some
	       '(lambda ( pair )
		  (if
		    (and
		      (= 360 (car pair))
		      (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair)))))
		      )
		    (cdr pair)
		    )
		  )
	       (dictsearch
		 (vlax-vla-object-&amp;gt;ename (vla-getextensiondictionary blk))
		 "ACAD_ENHANCEDBLOCK"
		 )
	       )
	    )
      )
    (cdr (assoc 301 (entget vis)))
    )
  )


;; Get Dynamic Block Visibility State  -  Lee Mac
;; Returns the value of the Visibility Parameter of a Dynamic Block (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; Returns: [str] Value of Visibility Parameter, else nil

(defun LM:getvisibilitystate ( blk / vis )
  (if (setq vis (LM:getvisibilityparametername blk))
    (LM:getdynpropvalue blk vis)
    )
  )

;; 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)
    )
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 16:37:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9943468#M66369</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-11-16T16:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple visibility states to a group of items?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9943616#M66370</link>
      <description>&lt;P&gt;The site removed me the &amp;lt;yes&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(or (getkword (strcat "\nAdd object to '" e "' state [No] &lt;STRONG&gt;&amp;lt;yes&amp;gt;&lt;/STRONG&gt;: "))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 11:56:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9943616#M66370</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-12-16T11:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple visibility states to a group of items?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9948236#M66371</link>
      <description>&lt;P&gt;This may&amp;nbsp; be useful to you, the param is the name of the visibility state eg "Visibity1" it will the display in&amp;nbsp; a dcl all the options and you can pick which one. For multiple on can use Multi toggles instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(setq dynlst (LM:getdynpropallowedvalues  obj param))
(ah:butts but "v"  (append (list "Please choose") dynlst))&lt;/LI-CODE&gt;&lt;P&gt;This is displayed another dynamic block has 8 visibilty states the only issue is the name of the visibility parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot305.png" style="width: 177px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/857697i28191E4246548BC1/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot305.png" alt="screenshot305.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 05:58:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9948236#M66371</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2020-12-18T05:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple visibility states to a group of items?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9957005#M66372</link>
      <description>&lt;P&gt;I have not yet had time to dig deeply into all the responses yet, but thanks very much to all that contributed!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 21:29:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-multiple-visibility-states-to-a-group-of-items/m-p/9957005#M66372</guid>
      <dc:creator>matthew_neesley</dc:creator>
      <dc:date>2020-12-22T21:29:18Z</dc:date>
    </item>
  </channel>
</rss>

