<?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 Re: Set Value in Dynamic Block in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7451988#M113472</link>
    <description>&lt;P&gt;Try&amp;nbsp;with vla-object instead of ename&lt;/P&gt;
&lt;PRE&gt;(setq blk (car (entsel)))&lt;BR /&gt;(LM:setdynpropvalue ((vlax-ename-&amp;gt;vla-object blk) "Visibility1" "1 inch WC")&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 Oct 2017 16:48:40 GMT</pubDate>
    <dc:creator>Ranjit_Singh</dc:creator>
    <dc:date>2017-10-11T16:48:40Z</dc:date>
    <item>
      <title>Set Value in Dynamic Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7451943#M113471</link>
      <description>&lt;P&gt;(USING AUTOCAD ELECTRICAL 2017)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using Lee Mac's LISP function to change the value of the dynamic block. I can't seem to get this working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil

(defun LM:setdynpropvalue ( blk prp val )
    (setq prp (strcase prp))
    (vl-some
       '(lambda ( x )
            (if (= prp (strcase (vla-get-propertyname x)))
                (progn
                    (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                    (cond (val) (t))
                )
            )
        )
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;** I would love to be able to get the block by entity name (IE: do not have the user select it - the entity is already known) **&lt;/P&gt;&lt;P&gt;IS THIS POSSIBLE???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But just to see if I can get this working, I went ahead and used entsel to have the user select the block (ideally, I won't want the user to select anything)&lt;/P&gt;&lt;P&gt;I've tried to run this by using the following commands:&lt;/P&gt;&lt;PRE&gt;(setq blk (car (entsel)))
(LM:setdynpropvalue (blk "Visibility1" "1 inch WC")&lt;/PRE&gt;&lt;P&gt;But I get the error:&lt;/P&gt;&lt;PRE&gt;bad argument type: VLA-OBJECT &amp;lt;Entity name: 4868b70&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What do I need to enter to get this function working?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lisp_error.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/411746iD38E9E7D0E889762/image-size/large?v=v2&amp;amp;px=999" role="button" title="lisp_error.jpg" alt="lisp_error.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 16:33:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7451943#M113471</guid>
      <dc:creator>david.faunce</dc:creator>
      <dc:date>2017-10-11T16:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Set Value in Dynamic Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7451988#M113472</link>
      <description>&lt;P&gt;Try&amp;nbsp;with vla-object instead of ename&lt;/P&gt;
&lt;PRE&gt;(setq blk (car (entsel)))&lt;BR /&gt;(LM:setdynpropvalue ((vlax-ename-&amp;gt;vla-object blk) "Visibility1" "1 inch WC")&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Oct 2017 16:48:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7451988#M113472</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2017-10-11T16:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Set Value in Dynamic Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7452513#M113473</link>
      <description>&lt;P&gt;Thanks again Ranjit!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know how I can set the blk variable if I already know the handle entity?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie:&amp;nbsp; &amp;nbsp;(setq&amp;nbsp; blk&amp;nbsp; &amp;nbsp;** handle entity = "1C43" **)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;??&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 19:30:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7452513#M113473</guid>
      <dc:creator>david.faunce</dc:creator>
      <dc:date>2017-10-11T19:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Set Value in Dynamic Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7452545#M113474</link>
      <description>&lt;P&gt;Nevermind. I got it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(setq blk (vlax-ename-&amp;gt;vla-object (handent "1C43")))
(LM:setdynpropvalue blk "Visibility1" "1 inch WC")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 19:42:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-value-in-dynamic-block/m-p/7452545#M113474</guid>
      <dc:creator>david.faunce</dc:creator>
      <dc:date>2017-10-11T19:42:37Z</dc:date>
    </item>
  </channel>
</rss>

