<?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 FolderBrowserDialog() not working with vb.net in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12169879#M20119</link>
    <description>&lt;P&gt;I get that this function is undefined, although it should enable me to pick the folder I need. Here's the code I'm using to do so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Function BrowseForFolder(prompt As String) As String&lt;BR /&gt;Using dialog As New FolderBrowserDialog()&lt;BR /&gt;dialog.Description = prompt&lt;BR /&gt;If dialog.ShowDialog() = DialogResult.OK Then&lt;BR /&gt;Return dialog.SelectedPath&lt;BR /&gt;End If&lt;BR /&gt;Return String.Empty&lt;BR /&gt;End Using&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I fix this?&lt;/P&gt;</description>
    <pubDate>Mon, 14 Aug 2023 14:53:21 GMT</pubDate>
    <dc:creator>mindaV3J2J</dc:creator>
    <dc:date>2023-08-14T14:53:21Z</dc:date>
    <item>
      <title>FolderBrowserDialog() not working with vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12169879#M20119</link>
      <description>&lt;P&gt;I get that this function is undefined, although it should enable me to pick the folder I need. Here's the code I'm using to do so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Function BrowseForFolder(prompt As String) As String&lt;BR /&gt;Using dialog As New FolderBrowserDialog()&lt;BR /&gt;dialog.Description = prompt&lt;BR /&gt;If dialog.ShowDialog() = DialogResult.OK Then&lt;BR /&gt;Return dialog.SelectedPath&lt;BR /&gt;End If&lt;BR /&gt;Return String.Empty&lt;BR /&gt;End Using&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I fix this?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 14:53:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12169879#M20119</guid>
      <dc:creator>mindaV3J2J</dc:creator>
      <dc:date>2023-08-14T14:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: FolderBrowserDialog() not working with vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170113#M20120</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13933266"&gt;@mindaV3J2J&lt;/a&gt;.&amp;nbsp; It may simply be due to the lack of an Imports statement in your rule's header for the System.Windows.Forms resource, because it may not recognize the object types.&amp;nbsp; This slightly edited version of your code works just fine for me in a regular iLogic rule without any Imports statements.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim sFolder As String = BrowseForFolder("Pick A Folder")
	MsgBox("sFolder = " &amp;amp; sFolder,,"")
End Sub

Private Function BrowseForFolder(prompt As String) As String
	Using dialog As New System.Windows.Forms.FolderBrowserDialog()
		dialog.Description = prompt
		If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
			Return dialog.SelectedPath
		End If
		Return String.Empty
	End Using
End Function&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 16:33:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170113#M20120</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-08-14T16:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: FolderBrowserDialog() not working with vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170471#M20121</link>
      <description>&lt;P&gt;that's not working for me unfortunately. Am I missing a reference maybe? I added the one that allowed me to use the inventor API, but no luck with this.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 19:46:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170471#M20121</guid>
      <dc:creator>mindaV3J2J</dc:creator>
      <dc:date>2023-08-14T19:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: FolderBrowserDialog() not working with vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170482#M20122</link>
      <description>&lt;P&gt;&lt;BR /&gt;Additionally, it cannot find the&amp;nbsp;&lt;SPAN&gt;System.Windows.Forms library. How can I get around this?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 19:50:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170482#M20122</guid>
      <dc:creator>mindaV3J2J</dc:creator>
      <dc:date>2023-08-14T19:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: FolderBrowserDialog() not working with vb.net</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170491#M20123</link>
      <description>&lt;P&gt;heres my code as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Imports System.IO&lt;BR /&gt;Imports System.Runtime.InteropServices&lt;BR /&gt;Imports System.Runtime.InteropServices.ComTypes&lt;BR /&gt;Imports System.Windows.Forms&lt;BR /&gt;Imports Inventor&lt;/P&gt;&lt;P&gt;Namespace d&lt;/P&gt;&lt;P&gt;Module Module1&lt;/P&gt;&lt;P&gt;Sub Main()&lt;BR /&gt;Dim invApp As Inventor.Application = GetInventorInstance()&lt;BR /&gt;If invApp Is Nothing Then&lt;BR /&gt;' MessageBox.Show("Autodesk Inventor is not running.")&lt;BR /&gt;Return&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Dim oDoc As Document = invApp.ActiveDocument&lt;BR /&gt;Dim folderPath As String = BrowseForFolder("Please select an input folder")&lt;BR /&gt;If String.IsNullOrEmpty(folderPath) Then&lt;BR /&gt;Return&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Dim oFSO As Object = CreateObject("Scripting.FileSystemObject")&lt;BR /&gt;Dim oFolder As Object = oFSO.GetFolder(folderPath)&lt;/P&gt;&lt;P&gt;Dim setFilePath As String = BrowseForFolder("Please select an output folder")&lt;BR /&gt;If String.IsNullOrEmpty(setFilePath) Then&lt;BR /&gt;Return&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;For Each oFile As Object In oFolder.Files&lt;BR /&gt;If LCase(oFSO.GetExtensionName(oFile.Name)) = "iam" Then&lt;BR /&gt;Dim sFilename As String = folderPath &amp;amp; "\" &amp;amp; oFile.Name&lt;BR /&gt;Dim oAsmDoc As AssemblyDocument = invApp.Documents.Open(sFilename, False)&lt;/P&gt;&lt;P&gt;' MessageBox.Show(oAsmDoc.FullFileName)&lt;/P&gt;&lt;P&gt;Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments&lt;BR /&gt;For Each oRefDoc As Document In oRefDocs&lt;BR /&gt;If oRefDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then&lt;BR /&gt;Dim oSheetMetDoc As PartDocument = invApp.Documents.Open(oRefDoc.FullFileName, True)&lt;BR /&gt;Dim oCompDef As SheetMetalComponentDefinition = oSheetMetDoc.ComponentDefinition&lt;BR /&gt;Dim oDef As FlatPattern = oCompDef.FlatPattern&lt;/P&gt;&lt;P&gt;If oDef Is Nothing Then GoTo NextOcc&lt;/P&gt;&lt;P&gt;Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2018" &amp;amp;&lt;BR /&gt;"&amp;amp;OuterProfileLayer=IV_INTERIOR_PROFILES" &amp;amp;&lt;BR /&gt;"&amp;amp;InvisibleLayers=IV_TANGENT;IV_ROLL_TANGENT"&lt;/P&gt;&lt;P&gt;Dim prevName As String = oSheetMetDoc.DisplayName&lt;BR /&gt;Dim arr() As String = prevName.Split("."c)&lt;BR /&gt;prevName = arr(0)&lt;/P&gt;&lt;P&gt;Dim sFname As String = setFilePath &amp;amp; "\" &amp;amp; prevName &amp;amp; ".dxf"&lt;/P&gt;&lt;P&gt;Dim oDataIO As DataIO = oCompDef.DataIO&lt;BR /&gt;oDataIO.WriteDataToFile(sOut, sFname)&lt;BR /&gt;oCompDef.FlatPattern.ExitEdit()&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;NextOcc:&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;If oDoc IsNot oAsmDoc Then&lt;BR /&gt;oAsmDoc.Close(True) ' True = skip save&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;' MessageBox.Show("Flat patterns exported to " &amp;amp; setFilePath)&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Private Function GetInventorInstance() As Inventor.Application&lt;BR /&gt;Try&lt;BR /&gt;Return DirectCast(Marshal.GetActiveObject("Inventor.Application"), Inventor.Application)&lt;BR /&gt;Catch ex As Exception&lt;BR /&gt;Return Nothing&lt;BR /&gt;End Try&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;Private Function BrowseForFolder(prompt As String) As String&lt;BR /&gt;Using dialog As New FolderBrowserDialog()&lt;BR /&gt;dialog.Description = prompt&lt;BR /&gt;If dialog.ShowDialog() = DialogResult.OK Then&lt;BR /&gt;Return dialog.SelectedPath&lt;BR /&gt;End If&lt;BR /&gt;Return String.Empty&lt;BR /&gt;End Using&lt;BR /&gt;End Function&lt;BR /&gt;End Module&lt;BR /&gt;End Namespace&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 19:54:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/folderbrowserdialog-not-working-with-vb-net/m-p/12170491#M20123</guid>
      <dc:creator>mindaV3J2J</dc:creator>
      <dc:date>2023-08-14T19:54:33Z</dc:date>
    </item>
  </channel>
</rss>

