<?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: Speed problem with modifying properties of multiple dynamic blocks in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486918#M55231</link>
    <description>&lt;P&gt;hi. i dont use transaction out of a sub/function.&lt;/P&gt;&lt;P&gt;try to create the transaction in the sub. and use trans.commit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jun 2012 05:26:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-06-06T05:26:44Z</dc:date>
    <item>
      <title>Speed problem with modifying properties of multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486102#M55228</link>
      <description>&lt;P&gt;Would there be a faster way of doing the following?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a an event that updates dynamic properties of potentialy hundreds blocks. I'm a bit surprised at how slow it is considering that if I filter and change the colors of the same blocks it is instantaneous.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Sub ModifyViewDimensions(ByVal trans As Transaction)
        For Each ObjID In tmpIDCollection
           ProgressBar("Updating Views", tmpIDCollection.Count, False)
            Dim br As BlockReference = DirectCast(trans.GetObject(ObjID, OpenMode.ForWrite), BlockReference)
            Dim pc As DynamicBlockReferencePropertyCollection = br.DynamicBlockReferencePropertyCollection
            For i = 0 To pc.Count - 1
                Dim prop As DynamicBlockReferenceProperty = pc(i)
                If prop.PropertyName = "A" Then prop.Value = A
                If prop.PropertyName = "B" Then prop.Value = B
                If prop.PropertyName = "C" Then prop.Value = C
                If prop.PropertyName = "D" Then prop.Value = D
                If prop.PropertyName = "E" Then prop.Value = E_
            Next
            br.Dispose()
            pc.Dispose()
        Next
        ProgressBar("Updating Views", tmpIDCollection.Count, True)
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use a main transaction and pass that transaction through all my subroutines. There is something also after the procedure that also causes a long delay. I assume the drawing regen but there is no way to add a progress bar to that.&lt;/P&gt;&lt;P&gt;Performed on 60 blocks it takes 15 seconds to make the updates then there's a 20 second stall for the drawing to update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope someone can help.&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>Tue, 05 Jun 2012 18:11:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486102#M55228</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2012-06-05T18:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Speed problem with modifying properties of multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486526#M55229</link>
      <description>&lt;PRE&gt;Sub ModifyViewDimensions(ByRef trans As Transaction)
        Dim br As BlockReference 
        Dim pc As DynamicBlockReferencePropertyCollection 

        For Each ObjID In tmpIDCollection
           ProgressBar("Updating Views", tmpIDCollection.Count, False)
            br = DirectCast(trans.GetObject(ObjID, OpenMode.ForWrite), BlockReference)
            pc = br.DynamicBlockReferencePropertyCollection
            For i = 0 To pc.Count - 1
                Dim prop As DynamicBlockReferenceProperty = pc(i)
                If prop.PropertyName = "A" Then prop.Value = A
                If prop.PropertyName = "B" Then prop.Value = B
                If prop.PropertyName = "C" Then prop.Value = C
                If prop.PropertyName = "D" Then prop.Value = D
                If prop.PropertyName = "E" Then prop.Value = E_
            Next
        Next
        ProgressBar("Updating Views", tmpIDCollection.Count, True)
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;HI i am a noob with vb.net but if you :&lt;/P&gt;&lt;P&gt;-dispose br or dispose pc you have a bug i think you can't dipose a object not create directly with a new ..&lt;/P&gt;&lt;P&gt;-Byval trans is not good so try Byref&lt;/P&gt;&lt;P&gt;-déclare before your for each the type of var&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this and say if it is ok.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and : prop.Value = A&amp;nbsp;&amp;nbsp;&amp;nbsp; --&amp;gt; what mean A&amp;nbsp; ?&amp;nbsp;&amp;nbsp; is a var ?&amp;nbsp; integer ? etc..&lt;BR /&gt;and : tmpIDCollection is a global var ?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2012 21:27:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486526#M55229</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-06-05T21:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Speed problem with modifying properties of multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486842#M55230</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I get an unhandled exception “attempted to read or write protected memory” if I don’t dispose br &amp;amp; pc. It’s the reason I added them but I don’t understand this either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A and tmpIDCollection are global. Might not be the best practice thing to do but I there are a few commonly used variables I can’t be bothered passing all the time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’ve realised that the 20 second ?regen? problem doesn’t occur on the first instance of the event which is odd. Something is hurting it after the first one. I may need to shell the procedure down to try to isolate the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2012 03:10:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486842#M55230</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2012-06-06T03:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Speed problem with modifying properties of multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486918#M55231</link>
      <description>&lt;P&gt;hi. i dont use transaction out of a sub/function.&lt;/P&gt;&lt;P&gt;try to create the transaction in the sub. and use trans.commit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2012 05:26:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3486918#M55231</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-06-06T05:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Speed problem with modifying properties of multiple dynamic blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3487054#M55232</link>
      <description>&lt;P&gt;hi, substitute the 'for i&amp;nbsp;= 0 ...' loop by a 'for each' loop if&amp;nbsp;the order doesn't matter. this way you have the 'prop' declaration on the outset of the loop&amp;nbsp;and also add [some] flexibility within the loop. if the individual props are mutually exclusive, test adding&amp;nbsp;" : continue for" at the end of each line&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2012 08:57:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/speed-problem-with-modifying-properties-of-multiple-dynamic/m-p/3487054#M55232</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-06-06T08:57:33Z</dc:date>
    </item>
  </channel>
</rss>

