<?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: from vba to vb.net in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/from-vba-to-vb-net/m-p/5895337#M59678</link>
    <description>&lt;P&gt;This Sub will be&amp;nbsp;quite simple to convert but there are a&amp;nbsp;few&amp;nbsp;things you'll need to fix&amp;nbsp;VB.NET program.&amp;nbsp;&amp;nbsp;The first step is to just copy and paste it into a VB.NET program.&amp;nbsp; You'll see a bunch of problems highlighted inside Visual Studio.&amp;nbsp; For example, the Set statement is not longer needed or even supported so you need to delete those.&amp;nbsp; (I think depending on the version of Visual Studio is might do this automatically.)&amp;nbsp; Where you declare variables that are an Inventor type you'll need to either full declare them or add a an Imports statement at the top of your program.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Dim wpls As WorkPlanes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;becomes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Dim wpls As Inventor.WorkPlanes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can add "Imports Inventor" at the very top of the code and then the original statement will still work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VB.NET also requires that enum values be fully qualified so&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; If invDoc.DocumentType = kPartDocumentObject Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;becomes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; If invDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Intellisense can help with these.&amp;nbsp; Just type in the equals again and it will display a list of valid enums and picking one will give you the fully qualified name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I said, a lot of the problems Visual Studio will point out to you and they're all easy to fix when you know what to do.&amp;nbsp; There are some other differences that are harder to find.&amp;nbsp; I presented a class at AU a few years ago about converting VBA programs to Add-Ins and discussed this a bit in there.&amp;nbsp; I've attached the paper I wrote for that class.&amp;nbsp; Hopefully it will&amp;nbsp;help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it's best to recognize up front, which it seems you already have, that VBA and VB.NET are different languages and it takes a little bit to get used to but once you do it's difficult to go back.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Nov 2015 22:29:48 GMT</pubDate>
    <dc:creator>ekinsb</dc:creator>
    <dc:date>2015-11-05T22:29:48Z</dc:date>
    <item>
      <title>from vba to vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/from-vba-to-vb-net/m-p/5894093#M59658</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;I've written this small function and I'd like to transpose it to vb.net.&lt;/P&gt;&lt;P&gt;'m planning to move all my functions to vb.net and want to use this one as a first howto.&lt;/P&gt;&lt;P&gt;A link to a howto would also be great! Where could I find some howto?&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub WP_Off()
'Visible Work Plan in parts OFF
    Dim invDoc As Document
    Set invDoc = ThisApplication.ActiveDocument
    
    If invDoc.DocumentType = kPartDocumentObject Then
 
        Dim pcd As PartComponentDefinition
        Set pcd = invDoc.ComponentDefinition
    
        Dim wpls As WorkPlanes
        Set wpls = pcd.WorkPlanes
        
        Dim owas As WorkAxes
        Set owas = pcd.WorkAxes
        
        Dim owpos As WorkPoints
        Set owpos = pcd.WorkPoints
        
        Dim owa As WorkAxis
        Dim owp As WorkPlane
        Dim owpo As WorkPoint
        
        For Each owp In wpls
            If owp.Visible = True Then
               owp.Visible = False
            End If
        Next
        For Each owa In owas
            If owa.Visible = True Then
               owa.Visible = False
            End If
        Next
        For Each owpo In owpos
            If owpo.Visible = True Then
               owpo.Visible = False
            End If
        Next
        
        
        Else: Exit Sub
    End If

End Sub&lt;/PRE&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>Thu, 05 Nov 2015 13:27:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/from-vba-to-vb-net/m-p/5894093#M59658</guid>
      <dc:creator>^_^clovis^_^</dc:creator>
      <dc:date>2015-11-05T13:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: from vba to vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/from-vba-to-vb-net/m-p/5895337#M59678</link>
      <description>&lt;P&gt;This Sub will be&amp;nbsp;quite simple to convert but there are a&amp;nbsp;few&amp;nbsp;things you'll need to fix&amp;nbsp;VB.NET program.&amp;nbsp;&amp;nbsp;The first step is to just copy and paste it into a VB.NET program.&amp;nbsp; You'll see a bunch of problems highlighted inside Visual Studio.&amp;nbsp; For example, the Set statement is not longer needed or even supported so you need to delete those.&amp;nbsp; (I think depending on the version of Visual Studio is might do this automatically.)&amp;nbsp; Where you declare variables that are an Inventor type you'll need to either full declare them or add a an Imports statement at the top of your program.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Dim wpls As WorkPlanes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;becomes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Dim wpls As Inventor.WorkPlanes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can add "Imports Inventor" at the very top of the code and then the original statement will still work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VB.NET also requires that enum values be fully qualified so&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; If invDoc.DocumentType = kPartDocumentObject Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;becomes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; If invDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Intellisense can help with these.&amp;nbsp; Just type in the equals again and it will display a list of valid enums and picking one will give you the fully qualified name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I said, a lot of the problems Visual Studio will point out to you and they're all easy to fix when you know what to do.&amp;nbsp; There are some other differences that are harder to find.&amp;nbsp; I presented a class at AU a few years ago about converting VBA programs to Add-Ins and discussed this a bit in there.&amp;nbsp; I've attached the paper I wrote for that class.&amp;nbsp; Hopefully it will&amp;nbsp;help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it's best to recognize up front, which it seems you already have, that VBA and VB.NET are different languages and it takes a little bit to get used to but once you do it's difficult to go back.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 22:29:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/from-vba-to-vb-net/m-p/5895337#M59678</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2015-11-05T22:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: from vba to vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/from-vba-to-vb-net/m-p/5895739#M59689</link>
      <description>&lt;P&gt;thanks a lot!!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 07:52:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/from-vba-to-vb-net/m-p/5895739#M59689</guid>
      <dc:creator>^_^clovis^_^</dc:creator>
      <dc:date>2015-11-06T07:52:35Z</dc:date>
    </item>
  </channel>
</rss>

