<?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: Performance VBA vs .NET in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509525#M110689</link>
    <description>&lt;P&gt;One thing that significantly impacts performance is if your program is running inside Inventor or not. When your program is running within Inventor’s process it’s referred to as in-process. When your program is running in another process it referred to as out-of-process. Add-ins and VBA macros, run in-process. Exe’s and programs that run from within other products all run in a process outside of Inventor.&lt;/P&gt;&lt;P&gt;i expect that your .net code is run out of process. If so try to make a addin and retry it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://modthemachine.typepad.com/my_weblog/2015/09/improving-your-programs-performance.html" target="_blank" rel="noopener"&gt;this page&lt;/A&gt; is a great refrence for performance. (especialy have a look at the chapter Running In-Process vs. Out-of-Process)&lt;/P&gt;</description>
    <pubDate>Tue, 12 May 2020 11:19:51 GMT</pubDate>
    <dc:creator>JelteDeJong</dc:creator>
    <dc:date>2020-05-12T11:19:51Z</dc:date>
    <item>
      <title>Performance VBA vs .NET</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509437#M110684</link>
      <description>&lt;P&gt;I am seeing a huge difference in the performance between VBA and .NET.&lt;/P&gt;&lt;P&gt;A code that executes in under a second in VBA takes more than 65 seconds in .NET&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@3E5F6F5F61A59A319E954F4832B72305/emoticons/1f914.png" alt=":thinking_face:" title=":thinking_face:" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VBA: (&amp;lt;0.5 sec)&lt;/P&gt;&lt;LI-CODE lang="general"&gt; Sub testperformance()
    Dim ElapsedTime As Long:   ElapsedTime = Timer
    Dim oPartDoc As PartDocument: Set oPartDoc = ThisApplication.ActiveDocument
    Dim oPartDef As PartComponentDefinition: Set oPartDef = oPartDoc.ComponentDefinition
    Dim nCylinders As Integer
    
    Dim oSurfBody As SurfaceBody
    Dim oFace As Face

    For Each oSurfBody In oPartDef.SurfaceBodies
        For Each oFace In oSurfBody.faces
            If oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then
                nCylinders = nCylinders + 1
            End If
        Next
    Next
    MsgBox Timer - ElapsedTime
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.NET: (&amp;gt; 65 sec)&lt;/P&gt;&lt;LI-CODE lang="general"&gt; Sub testperformance()
        Dim ThisApplication As Application = GetObject(, "Inventor.application")

        Dim start_time As DateTime = Now
        Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
        Dim oPartDef As PartComponentDefinition = oPartDoc.ComponentDefinition
        Dim nCylinders As Int16 = 0

        For Each oSurfBody As SurfaceBody In oPartDef.SurfaceBodies
            For Each oFace As Face In oSurfBody.Faces
                If oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then
                    nCylinders += 1
                End If
            Next
        Next

        Dim elapsed_time As TimeSpan = Now.Subtract(start_time)
        MsgBox(elapsed_time.TotalSeconds)
    End Sub
End Class&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code is run on a complex part file with approx 10.000 faces.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 10:37:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509437#M110684</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-12T10:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Performance VBA vs .NET</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509525#M110689</link>
      <description>&lt;P&gt;One thing that significantly impacts performance is if your program is running inside Inventor or not. When your program is running within Inventor’s process it’s referred to as in-process. When your program is running in another process it referred to as out-of-process. Add-ins and VBA macros, run in-process. Exe’s and programs that run from within other products all run in a process outside of Inventor.&lt;/P&gt;&lt;P&gt;i expect that your .net code is run out of process. If so try to make a addin and retry it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://modthemachine.typepad.com/my_weblog/2015/09/improving-your-programs-performance.html" target="_blank" rel="noopener"&gt;this page&lt;/A&gt; is a great refrence for performance. (especialy have a look at the chapter Running In-Process vs. Out-of-Process)&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 11:19:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509525#M110689</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2020-05-12T11:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Performance VBA vs .NET</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509568#M110690</link>
      <description>&lt;P&gt;Yes, I realize that's the issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It just easier to debug, but I will move it to an addin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 11:36:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509568#M110690</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-12T11:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Performance VBA vs .NET</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509695#M110693</link>
      <description>&lt;P&gt;I often use a UnitTest to start and debug addin functions out of process. that makes debugging almost as easy as a standalone application (but it's slow) but for the end users there is the speed of an addin.&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 12:18:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/performance-vba-vs-net/m-p/9509695#M110693</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2020-05-12T12:18:12Z</dc:date>
    </item>
  </channel>
</rss>

