<?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: Exporting Inventor drawing to specified location in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12328257#M159419</link>
    <description>&lt;P&gt;No Worries, i appreciate the help. This works but i realized my intent was to select the folder and have the document save in that folder. And not create a folder with the Ilogic (Datestring). I will have to try and edit it to remove that and just save the document to the selected folder.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Oct 2023 19:32:29 GMT</pubDate>
    <dc:creator>brandon.lee97</dc:creator>
    <dc:date>2023-10-24T19:32:29Z</dc:date>
    <item>
      <title>Exporting Inventor drawing to specified location</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325156#M159369</link>
      <description>&lt;P&gt;I am trying to figure out if there is a way to export a pdf from a drawing to a selected location. (Have a prompt or window appear to allow you to select that location when you run the logic code).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found a ton of codes that send it to a specific location that if in the file path but nothing to a selected folder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 18:15:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325156#M159369</guid>
      <dc:creator>brandon.lee97</dc:creator>
      <dc:date>2023-10-23T18:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Inventor drawing to specified location</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325219#M159370</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5923092"&gt;@brandon.lee97&lt;/a&gt;.&amp;nbsp; Below is an example of a custom Function that you can include in your rule...after the Sub Main...your other code here...End Sub routine, then you can call this function to run from within your Sub Main area of code.&amp;nbsp; But this example also includes an example Sub Main routine, just to show you how to use it, and what it returns.&amp;nbsp; Most paths you get will not contain the final "\" character at the end, so keep that in mind when assembling a full file name using that returned path.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim sFolder As String = SelectFolder
	MsgBox(sFolder,,"iLogic")
End Sub

Function SelectFolder(Optional oPrompt As String = vbNullString) As String
	If oPrompt = "" Then oPrompt = "Select Folder"
	Dim oFDialog As New System.Windows.Forms.FolderBrowserDialog
	oFDialog.Description = oPrompt
	oFDialog.ShowNewFolderButton = True
	oFDialog.RootFolder = System.Environment.SpecialFolder.MyComputer
	Dim oResult As System.Windows.Forms.DialogResult = oFDialog.ShowDialog()
	If oResult = System.Windows.Forms.DialogResult.OK Then
		Return oFDialog.SelectedPath
	Else 'if dialog was canceled or something else
		Return vbNullString
	End If
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;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 18:38:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325219#M159370</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-10-23T18:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Inventor drawing to specified location</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325279#M159373</link>
      <description>&lt;P&gt;HI Wesley,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this, i am having a little trouble integrating this into the other code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also wondering if there is a way to have the pop up you had written start at a specific location.&lt;/P&gt;&lt;P&gt;For example, have it pop up already in&amp;nbsp;&lt;/P&gt;&lt;P&gt;G:\Dropbox\PROJECTS WIP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have written the code below that i have been using below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sub Main()
  Dim myDate As String = Now().ToString("yyyy-MM-dd HHmmss")
  myDate = myDate.Replace(":","")  ' &amp;amp; " - " &amp;amp; TypeString
 userChoice = InputRadioBox("Defined the scope", "This Document", "All Open Documents", True, Title := "Defined the scope")
 UserSelectedActionList = New String(){"DXF &amp;amp; PDF", "PDF Only", "DXF Only"}
  UserSelectedAction = InputListBox("What action must be performed with selected views?", _
          UserSelectedActionList, UserSelectedActionList(0), Title := "Action to Perform", ListName := "Options")
      Select UserSelectedAction
   Case "DXF &amp;amp; PDF": UserSelectedAction = 3
   Case "PDF Only": UserSelectedAction = 1
   Case "DXF Only":    UserSelectedAction = 2
   End Select
 If userChoice Then
   Call MakePDFFromDoc(ThisApplication.ActiveDocument, myDate, UserSelectedAction)
  Else
   For Each oDoc In ThisApplication.Documents
    If oDoc.DocumentType = kDrawingDocumentObject
     Try
      If Len(oDoc.File.FullFileName)&amp;gt;0 Then
       Call MakePDFFromDoc(oDoc, myDate, UserSelectedAction)
      End If
     Catch
     End Try
    End If
   Next
  End If
 End Sub
 Sub MakePDFFromDoc(ByRef oDocument As Document, DateString As String, UserSelectedAction As Integer)
 ' oPath = oDocument.Path
 ' oFileName = oDocument.FileName(False) 'without extension
  'oDocument = ThisApplication.ActiveDocument
  oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
  ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
  oContext = ThisApplication.TransientObjects.CreateTranslationContext
  oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
  oOptions = ThisApplication.TransientObjects.CreateNameValueMap
  oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
 oFullFileName = oDocument.File.FullFileName
  oPath = Left(oFullFileName, InStrRev(oFullFileName, "\")-1)
  oFileName = Right(oFullFileName, Len(oFullFileName)-InStrRev(oFullFileName, "\"))
  oFilePart = Left(oFileName, InStrRev(oFileName, ".")-1)
 'oRevNum = oDocument.iProperties.Value("Project", "Revision Number")
  'oDocument = ThisApplication.ActiveDocument
 ' If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
  oOptions.Value("All_Color_AS_Black") = 0
  oOptions.Value("Remove_Line_Weights") = 0
  oOptions.Value("Vector_Resolution") = 400
  oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
  'oOptions.Value("Custom_Begin_Sheet") = 2
  'oOptions.Value("Custom_End_Sheet") = 4
 ' End If
 'get PDF target folder path
  'oFolder = Left(oPath, InStrRev(oPath, "\")) &amp;amp; "PDF"
  oFolder = oPath &amp;amp; "\iLogic PDF's (" &amp;amp; DateString &amp;amp; ")"
 'Check for the PDF folder and create it if it does not exist
  If Not System.IO.Directory.Exists(oFolder) Then
   System.IO.Directory.CreateDirectory(oFolder)
  End If
 'Set the PDF target file name
  oDataMedium.FileName = oFolder &amp;amp; "\" &amp;amp; oFilePart &amp;amp; ".pdf"
 'Publish document
  If (UserSelectedAction = 1) Or (UserSelectedAction = 3) Then
   oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)'For PDF's
  End If
  If (UserSelectedAction = 2) Or (UserSelectedAction = 3) Then
   oDocument.SaveAs(oFolder &amp;amp; "\" &amp;amp; oFilePart &amp;amp; ".dxf", True) 'For DXF's
  End If
  'oDocument.SaveAs(oFolder &amp;amp; "\" &amp;amp; ThisDoc.ChangeExtension(".dxf"), True) 'For DXF's
  '------end of iLogic-------
 End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 19:07:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325279#M159373</guid>
      <dc:creator>brandon.lee97</dc:creator>
      <dc:date>2023-10-23T19:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Inventor drawing to specified location</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325936#M159382</link>
      <description>&lt;P&gt;Looking at documentation for &lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.folderbrowserdialog?view=windowsdesktop-7.0" target="_blank" rel="noopener"&gt;FolderBrowserDialog&lt;/A&gt; you can set the property RootFolder or SelectedPath prior to ShowDialog() to limit and affect what the dialog will allow you to choose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd recommend adding the SelectFolder function to your script, and modify the function signature for MakePDFFromDoc so you can pass a path or filename into it.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 01:10:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12325936#M159382</guid>
      <dc:creator>j-robertson</dc:creator>
      <dc:date>2023-10-24T01:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Inventor drawing to specified location</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12328191#M159418</link>
      <description>&lt;P&gt;Sorry for the delay, but I have a lot going on today at work.&amp;nbsp; In the following example, I basically just added the SelectFolder Function as an additional routine, similar to the previous example, but that function is now being called to run from within your existing MakePDFFromDoc Sub routine.&amp;nbsp; I usually pass the full file name of the file that I want to export to the routine that will be doing the exporting, making it more robust for use in multiple scenarios.&amp;nbsp; You are currently passing just the 'DateString' to your custom routine, but you could have transferred most, if not all of the code for assembling the full file name of the PDF from that custom routine, into your 'Main' routine, then just pass the full file name of the PDF to that custom routine.&amp;nbsp; You could also call the SelectFolder routine to run from the 'Main' routine somewhere before you call your other routine to run, then pass the folder / path data to that routine.&amp;nbsp; Since I am not sure what all your design intent is for this, I am not sure if you want to manually select a folder using the SelectFolder routine, then still add the "\iLogic PDF's ( DateString )" text after that point, or if you want to handle that part while you have the dialog open, then skip that step in the code.&amp;nbsp; If doing it all in the dialog, you should no longer need to check if the directory exists.&lt;/P&gt;
&lt;P&gt;I did customize the SelectFolder routine a bit more for you, to make it easier to specify a starting folder.&amp;nbsp; When setting the RootFolder, you limit how far up you can browse within the dialog, so I left that line of code out in this version.&amp;nbsp; Instead I added an extra optional input variable (sStartFrom) to the routine, allowing you an easier way to specify that starting path.&amp;nbsp; Then within the routine, it uses that to set the SelectedPath property, which will cause that path expanded and selected when the dialog opens.&amp;nbsp; If a simple folder browser is too basic, and you want to step it up a notch, we could instead use an Inventor.&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-FileDialog" target="_blank" rel="noopener"&gt;FileDialog&lt;/A&gt;, then set its settings similarly, then use its &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=FileDialog_ShowSave" target="_blank" rel="noopener"&gt;ShowSave&lt;/A&gt;&amp;nbsp;method, which will show the same dialog you see when using SaveAs.&amp;nbsp; But it will not actually save the file, just return the final full path and file name that you specify to the code that called it to run.&amp;nbsp; Then you can use that later in the code.&amp;nbsp; That online help page contains a &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=FileDialog_Sample" target="_blank" rel="noopener"&gt;link to a VBA (not iLogic) sample&lt;/A&gt; that uses one.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main()
	Dim myDate As String = Now().ToString("yyyy-MM-dd HHmmss")
	myDate = myDate.Replace(":","")  ' &amp;amp; " - " &amp;amp; TypeString
	userChoice = InputRadioBox("Defined the scope", "This Document", "All Open Documents", True, Title := "Defined the scope")
	UserSelectedActionList = New String(){"DXF &amp;amp; PDF", "PDF Only", "DXF Only"}
	UserSelectedAction = InputListBox("What action must be performed with selected views?", _
	UserSelectedActionList, UserSelectedActionList(0), Title := "Action to Perform", ListName := "Options")
	Select UserSelectedAction
		Case "DXF &amp;amp; PDF" : UserSelectedAction = 3
		Case "PDF Only" : UserSelectedAction = 1
		Case "DXF Only" : UserSelectedAction = 2
	End Select
	If userChoice Then
		MakePDFFromDoc(ThisApplication.ActiveDocument, myDate, UserSelectedAction)
	Else
	Dim oDocs As Documents = ThisApplication.Documents
	For Each oDoc As Document In oDocs
		If oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject
			Try
				If Len(oDoc.File.FullFileName) &amp;gt; 0 Then
					MakePDFFromDoc(oDoc, myDate, UserSelectedAction)
				End If
			Catch
			End Try
		End If
	Next
	End If
End Sub

Sub MakePDFFromDoc(ByRef oDocument As Document, DateString As String, UserSelectedAction As Integer)
	Dim oPDFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById _
	("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
	Dim oTO As TransientObjects = ThisApplication.TransientObjects
	Dim oContext As TranslationContext = oTO.CreateTranslationContext
	oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
	Dim oOptions As NameValueMap = oTO.CreateNameValueMap
	Dim oDataMedium As DataMedium = oTO.CreateDataMedium
	'&amp;lt;&amp;lt;&amp;lt; calling the other custom Function to run in next line &amp;gt;&amp;gt;&amp;gt;
	Dim oPath As String = SelectFolder("Select Folder", "G:\Dropbox\PROJECTS WIP")
	'checking to make sure it returned something, if not, exit this routine
	If String.IsNullOrEmpty(oPath) Then Return 'if no path was returned, exit routine
	Dim oFilePart As String = System.IO.Path.GetFileNameWithoutExtension(oDocument.FullFileName)
	'Dim oRevNum As String = oDocument.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value
	'get PDF target folder path
	Dim oFolder As String = oPath &amp;amp; "\iLogic PDF's (" &amp;amp; DateString &amp;amp; ")"
	'Check for the PDF folder and create it if it does not exist
	If Not System.IO.Directory.Exists(oFolder) Then
		System.IO.Directory.CreateDirectory(oFolder)
	End If
	'Set the PDF target file name
	oDataMedium.FileName = oFolder &amp;amp; "\" &amp;amp; oFilePart &amp;amp; ".pdf"
	If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
		oOptions.Value("All_Color_AS_Black") = 0
		oOptions.Value("Remove_Line_Weights") = 0
		oOptions.Value("Vector_Resolution") = 400
		oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
		'oOptions.Value("Custom_Begin_Sheet") = 2
		'oOptions.Value("Custom_End_Sheet") = 4
		
		'Publish document
		If (UserSelectedAction = 1) Or (UserSelectedAction = 3) Then
			oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)'For PDF's
		End If
		If (UserSelectedAction = 2) Or (UserSelectedAction = 3) Then
			oDocument.SaveAs(oFolder &amp;amp; "\" &amp;amp; oFilePart &amp;amp; ".dxf", True) 'For DXF's
		End If
	End If
End Sub

Function SelectFolder(Optional sPrompt As String = vbNullString, Optional sStartFrom As String = vbNullString) As String
	If String.IsNullOrEmpty(oPrompt) Then sPrompt = "Select Folder"
	If String.IsNullOrEmpty(sStartFrom) Then sStartFrom = "C:\"
	Dim oFDialog As New System.Windows.Forms.FolderBrowserDialog
	oFDialog.Description = sPrompt
	oFDialog.ShowNewFolderButton = True
	oFDialog.SelectedPath = sStartFrom
	Dim oResult As System.Windows.Forms.DialogResult = oFDialog.ShowDialog()
	If oResult = System.Windows.Forms.DialogResult.OK Then
		Return oFDialog.SelectedPath
	Else 'if dialog was canceled or something else
		Return vbNullString
	End If
End Function&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 19:07:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12328191#M159418</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-10-24T19:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Inventor drawing to specified location</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12328257#M159419</link>
      <description>&lt;P&gt;No Worries, i appreciate the help. This works but i realized my intent was to select the folder and have the document save in that folder. And not create a folder with the Ilogic (Datestring). I will have to try and edit it to remove that and just save the document to the selected folder.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 19:32:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exporting-inventor-drawing-to-specified-location/m-p/12328257#M159419</guid>
      <dc:creator>brandon.lee97</dc:creator>
      <dc:date>2023-10-24T19:32:29Z</dc:date>
    </item>
  </channel>
</rss>

