<?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: stretch multiple dynamic blocks in AutoCAD Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/8889817#M134866</link>
    <description>&lt;P&gt;Probably not with built-in functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But with LISP could be that done quite easily.&lt;/P&gt;
&lt;P&gt;I case you're not familiar with LISP yet read&amp;nbsp;&lt;A href="http://www.lee-mac.com/runlisp.html" target="_blank" rel="noopener"&gt;HERE&lt;/A&gt;&amp;nbsp;a short tutorial on how to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:DBlocksLengthen (/ sel prp opr dst idx obj old)

  (if (and (setq sel (ssget "_:L" '((0 . "INSERT"))))
           (princ (strcat "\nProperties: " (vl-string-right-trim " -" (apply 'strcat (mapcar '(lambda (x) (strcat x " - ")) (mapcar 'car (LM:getdynprops (vlax-ename-&amp;gt;vla-object (ssname sel 0)))))))))
           (setq prp (getstring "\nProperty name (numerical): "))
           (not (initget "/ * - +"))
           (setq opr (read (cond ((getkword "\nOperation (+ - * /) &amp;lt;+&amp;gt;: "))
                                ("+"))))
           (setq dst (getdist "\nValue: "))
           )
    (repeat (setq idx (sslength sel))
      (and (setq obj (vlax-ename-&amp;gt;vla-object (ssname sel (setq idx (1- idx)))))
           (setq old (LM:getdynpropvalue obj prp))
           (numberp old)
           (LM:setdynpropvalue obj prp ((eval opr) old dst))
           )))
  (princ)
  )
   

;; 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 ((&amp;lt;prop&amp;gt; . &amp;lt;value&amp;gt;) ... )

(defun LM:getdynprops ( blk )
    (mapcar '(lambda ( x ) (cons (vla-get-propertyname x) (vlax-get x 'value)))
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)

;; 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)
    )
)

;; 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;</description>
    <pubDate>Thu, 04 Jul 2019 07:21:13 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2019-07-04T07:21:13Z</dc:date>
    <item>
      <title>stretch multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/8889590#M134865</link>
      <description>&lt;P&gt;greetings&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need stretching several dynamic blocks (with stretch parameters) at the same time; but here is the problem... the stretch parameters should has different values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example... I got a dynamic block with a simple stretch paramert (a pipe with a variable length)... I put multiple pipes to the same level but each length is different among them and I need to add 20 cm more to each one (at the same time).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is this possible do this with dynamic blocks that contains stretch parameter????&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks a lot&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2019 05:05:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/8889590#M134865</guid>
      <dc:creator>arq.jolmor</dc:creator>
      <dc:date>2019-07-04T05:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: stretch multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/8889817#M134866</link>
      <description>&lt;P&gt;Probably not with built-in functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But with LISP could be that done quite easily.&lt;/P&gt;
&lt;P&gt;I case you're not familiar with LISP yet read&amp;nbsp;&lt;A href="http://www.lee-mac.com/runlisp.html" target="_blank" rel="noopener"&gt;HERE&lt;/A&gt;&amp;nbsp;a short tutorial on how to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:DBlocksLengthen (/ sel prp opr dst idx obj old)

  (if (and (setq sel (ssget "_:L" '((0 . "INSERT"))))
           (princ (strcat "\nProperties: " (vl-string-right-trim " -" (apply 'strcat (mapcar '(lambda (x) (strcat x " - ")) (mapcar 'car (LM:getdynprops (vlax-ename-&amp;gt;vla-object (ssname sel 0)))))))))
           (setq prp (getstring "\nProperty name (numerical): "))
           (not (initget "/ * - +"))
           (setq opr (read (cond ((getkword "\nOperation (+ - * /) &amp;lt;+&amp;gt;: "))
                                ("+"))))
           (setq dst (getdist "\nValue: "))
           )
    (repeat (setq idx (sslength sel))
      (and (setq obj (vlax-ename-&amp;gt;vla-object (ssname sel (setq idx (1- idx)))))
           (setq old (LM:getdynpropvalue obj prp))
           (numberp old)
           (LM:setdynpropvalue obj prp ((eval opr) old dst))
           )))
  (princ)
  )
   

;; 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 ((&amp;lt;prop&amp;gt; . &amp;lt;value&amp;gt;) ... )

(defun LM:getdynprops ( blk )
    (mapcar '(lambda ( x ) (cons (vla-get-propertyname x) (vlax-get x 'value)))
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)

;; 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)
    )
)

;; 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;</description>
      <pubDate>Thu, 04 Jul 2019 07:21:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/8889817#M134866</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2019-07-04T07:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: stretch multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/8890743#M134867</link>
      <description>&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;the routine works great&lt;/P&gt;&lt;P&gt;ty, ty, ty, ty&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2019 15:21:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/8890743#M134867</guid>
      <dc:creator>arq.jolmor</dc:creator>
      <dc:date>2019-07-04T15:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: stretch multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/11857316#M134868</link>
      <description>&lt;P&gt;Hi BeeKeeCZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this topic is old, so I apologize if I should just start a new one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm trying to use your code here to edit the properties of a dynamic block. It seems to work until it gets to the&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;(LM:setdynpropvalue obj prp ((&lt;/SPAN&gt;&lt;SPAN&gt;eval&lt;/SPAN&gt;&lt;SPAN&gt; opr) old dst)) line. Here is where it gives me an&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;; error: too few arguments&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;error. The dynamic property is a Stretch action on a Linear parameter named BayLength, whose "Dist increment" equals 48 "Dist minimum" equals 48, and "Dist maximum" equals 144.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Command: DBLOCKSLENGTHEN&lt;BR /&gt;Select objects: 1 found&lt;BR /&gt;Select objects:&lt;BR /&gt;Properties: FrameDepth - Origin - BayLength - Origin&lt;BR /&gt;Property name (numerical): BayLength&lt;BR /&gt;Operation (+ - * /) &amp;lt;+&amp;gt;: +&lt;BR /&gt;Value: 48&lt;BR /&gt;48.0&lt;BR /&gt;BayLength&lt;BR /&gt;; error: too few arguments&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I know the Operation line isn't really applicable but I made sure that my input there equaled a parameter value that matches the "Dist increment".&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;Do you have any ideas? Is there something I'm doing wrong with&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;LM:setdynpropvalue? I've attached a dwg with my block in it.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks again and I apologize if this should be a new thread or something.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 Mar 2023 20:14:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/11857316#M134868</guid>
      <dc:creator>jbohP9BSS</dc:creator>
      <dc:date>2023-03-29T20:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: stretch multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/11858484#M134869</link>
      <description>&lt;P&gt;Don't really know. I could not replicate the issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this routine without Lees subs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:DBlocksLengthen (/ sel prp opr dst idx obj old new)

  (if (and (setq sel (ssget "_:L" '((0 . "INSERT"))))
           (princ (strcat "\nProperties: "
			  (vl-string-right-trim " -" (apply 'strcat (mapcar '(lambda (x) (strcat x " - ")) (mapcar 'vla-get-propertyname (vlax-invoke (vlax-ename-&amp;gt;vla-object (ssname sel 0)) 'getdynamicblockproperties)))))))
           (setq prp (strcat "AcDbDynBlockProperty" (getstring "\nProperty name (numerical): ")))
           (not (initget "/ * - +"))
           (setq opr (read (cond ((getkword "\nOperation (+ - * /) &amp;lt;+&amp;gt;: ")) ("+"))))
           (setq dst (getdist "\nValue: "))
           )
    (repeat (setq idx (sslength sel))
      (and (setq ent (ssname sel (setq idx (1- idx))))
	   (or (not (setq err (vl-catch-all-error-p (setq old (vl-catch-all-apply 'getpropertyvalue (list ent prp))))))
	       (prompt (strcat "\nError: " err)))
           (or (numberp old)
	       (prompt "\nError: Numberp prove failed."))
	   (setq new ((eval opr) old dst))
	   (setpropertyvalue ent prp new))))
  (princ)
  )
 &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 08:27:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/11858484#M134869</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2023-03-30T08:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: stretch multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/11859193#M134870</link>
      <description>&lt;P&gt;Hi BeeKeeCZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked!!! Thank you so much for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 12:43:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/stretch-multiple-dynamic-blocks/m-p/11859193#M134870</guid>
      <dc:creator>jbohP9BSS</dc:creator>
      <dc:date>2023-03-30T12:43:48Z</dc:date>
    </item>
  </channel>
</rss>

