<?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: iLogic to set initial filename on first save in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9469278#M108644</link>
    <description>&lt;P&gt;I actually did exactly the same as the last response, however, if you're loading an excel file it will just take a while to process the information.&lt;BR /&gt;&lt;BR /&gt;Now, I did this to create a file naming application that reads the excel file containing the naming characteristics. Then every time I open a new inventor file, it grabs the number from excel, populates this name into the browser node and then when i click save, it just takes the browser name and appears as the name file. (Cool it really, works) now i have a naming application for every file, assembly, parts, sheet metal, drawings (for drawings uses a different number)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it's absolutely slow, especially with content centre files or frame generated parts, or well i have good computer so it doesn't bother me, but I really would like to find a different file instead of an excel file to process this.&amp;nbsp; Can anyone give me a recommendation for this? How could i speed up this opening and reading the excel file every time i create a new file.&lt;BR /&gt;&lt;BR /&gt;Cheers.&lt;/P&gt;</description>
    <pubDate>Sat, 25 Apr 2020 02:42:54 GMT</pubDate>
    <dc:creator>antoniobaron</dc:creator>
    <dc:date>2020-04-25T02:42:54Z</dc:date>
    <item>
      <title>iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/5751456#M108641</link>
      <description>&lt;P&gt;I'd like to create an iLogic code to do two things:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. On the first save of a part, check if the Description is filled out, and give me the option to fill it out if I want&lt;/P&gt;&lt;P&gt;2. After that, allow the Save As dialog to come up, with the Filename populated with the current Description if it exists&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code that I have right now, a lot of which I got from the forums:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;If ThisDoc.Path="" Then
    'If document has not been saved before...
    
    If iProperties.Value("Project", "Description")="" Then
        'If the Description is empty...
        GiveDescription=MessageBox.Show("You have not given this part a Description (Component name). Would you like to do so now?", "Missing Description",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)
        If GiveDescription=DialogResult.Yes Then
            'If the user wants to provide a Description...
            iProperties.Value("Project", "Description") = InputBox("Component Name:", "Part Description", "")
        End If
    End If
    
    'SAVE AS DIALOG BOX
    'define the active document
    oDoc = ThisDoc.Document
    'create a file dialog box
    Dim oFileDlg As inventor.FileDialog = Nothing
    InventorVb.Application.CreateFileDialog(oFileDlg)
    
    'Set dialog filter
    'oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"
    
    'set the directory to open the dialog at
    'oFileDlg.InitialDirectory = ThisDoc.WorkspacePath()
    'set the file name string to use in the input box as the value entered in Excel Spreadsheet
    oFileDlg.FileName = iProperties.Value("Project", "Description")
    
    'work with an error created by the user backing out of the save
    oFileDlg.CancelError = True
    On Error Resume Next
    'specify the file dialog as a save dialog (rather than a open dialog)
    oFileDlg.ShowSave()
    
    'catch an empty string in the imput
    If Err.Number &amp;lt;&amp;gt; 0 Then
    MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
    ElseIf oFileDlg.FileName &amp;lt;&amp;gt; "" Then
    'save the file
    oDoc.SaveAs(iProperties.Value("Project", "Description"), False) 'True = Save As Copy &amp;amp; False = Save As
    End If
Else
    'If document has been saved before...
    Return
End If&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the two main issues with it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. If I put it under the "Before Save Document" trigger, Inventor runs it AFTER displaying the Save As dialog box, so that makes it useless.&lt;/P&gt;&lt;P&gt;2. If I just run the rule manually before ever saving the document, it appears that everything works as intended, but after hitting "Save", nothing happens. The part isn't actually saved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, does anyone know how I can get my code to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Intercept the Save As dialog and run BEFORE it comes up&lt;/P&gt;&lt;P&gt;2. Actually save the file once it's done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2015 12:30:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/5751456#M108641</guid>
      <dc:creator>DRoam</dc:creator>
      <dc:date>2015-07-31T12:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/5751529#M108642</link>
      <description>Guessing you will have to look into events manager, and actually just intercept the save action itself by looking for the button press or something similiar....</description>
      <pubDate>Fri, 31 Jul 2015 13:21:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/5751529#M108642</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2015-07-31T13:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/7097302#M108643</link>
      <description>&lt;P&gt;I realize this is an old post, but maybe this will help someone. I am doing something similar. I want the users to name a new file according to properties which should be in the file. Instead of watching for the save event, I just added the external rule to the template and trigger it on a new document event. It fires a form to fill out the properties, and then populates the save dialog with the constructed name. It works great for my purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for posting the code, it saved me some time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Sat, 20 May 2017 14:52:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/7097302#M108643</guid>
      <dc:creator>tmuel</dc:creator>
      <dc:date>2017-05-20T14:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9469278#M108644</link>
      <description>&lt;P&gt;I actually did exactly the same as the last response, however, if you're loading an excel file it will just take a while to process the information.&lt;BR /&gt;&lt;BR /&gt;Now, I did this to create a file naming application that reads the excel file containing the naming characteristics. Then every time I open a new inventor file, it grabs the number from excel, populates this name into the browser node and then when i click save, it just takes the browser name and appears as the name file. (Cool it really, works) now i have a naming application for every file, assembly, parts, sheet metal, drawings (for drawings uses a different number)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it's absolutely slow, especially with content centre files or frame generated parts, or well i have good computer so it doesn't bother me, but I really would like to find a different file instead of an excel file to process this.&amp;nbsp; Can anyone give me a recommendation for this? How could i speed up this opening and reading the excel file every time i create a new file.&lt;BR /&gt;&lt;BR /&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 02:42:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9469278#M108644</guid>
      <dc:creator>antoniobaron</dc:creator>
      <dc:date>2020-04-25T02:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9474731#M108645</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2364203"&gt;@antoniobaron&lt;/a&gt;&amp;nbsp;That sounds simple enough, but how do you change the browser node?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 21:30:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9474731#M108645</guid>
      <dc:creator>Eide.N</dc:creator>
      <dc:date>2020-04-27T21:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9474892#M108646</link>
      <description>&lt;P&gt;Im not a programmer but Thanks to COVID-19 I have plenty of time to experiment, hope this works for you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub Main()&lt;BR /&gt;' Define a variable that will set the type of document&lt;/P&gt;&lt;P&gt;Dim oComp1occ As Document = ThisDoc.Document&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Define the iproperty value that you want in your browser node&lt;/P&gt;&lt;P&gt;Dim strText As String = iProperties.Value("Custom", "DocumentID")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Looks for the type of document and replaces the node value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If oComp1occ.DocumentType = kAssemblyDocumentObject Then&lt;BR /&gt;Dim oPart As AssemblyDocument = ThisDoc.Document&lt;BR /&gt;oPart.DisplayName = strText&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ElseIf oComp1occ.DocumentType = kPartDocumentObject Then&lt;BR /&gt;Dim oPart As PartDocument = ThisDoc.Document&lt;BR /&gt;oPart.DisplayName = strText&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Elseif oComp1occ.DocumentType = kDrawingDocumentObject Then&lt;BR /&gt;Dim oPart As DrawingDocument = ThisDoc.Document&lt;BR /&gt;oPart.DisplayName = strText&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end Sub&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:27:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9474892#M108646</guid>
      <dc:creator>antoniobaron</dc:creator>
      <dc:date>2020-04-27T23:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9477136#M108647</link>
      <description>&lt;P&gt;Nice!&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to work without checking the file type.&amp;nbsp;I then combined that with some excel tomfoolery - just put the starting PN in cell A2 in your excel file... (This script only runs if the file hasn't been saved before. )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'If not saved
If ThisDoc.Path = "" Then

	'look at the excel file, update PN and save
	GoExcel.Open("C:\Work\Local\SequentialPN.xlsx", "Sheet1")
		PreviousNumber = GoExcel.CellValue("A2")
		NewNumber = (PreviousNumber + 1)
		'MessageBox.Show(PreviousNumber &amp;amp; vbLf &amp;amp; NewNumber)
		GoExcel.CellValue("A2") = NewNumber
		iProperties.Value("Project", "Part Number") = NewNumber
	GoExcel.Save()

	'Set Browser Node Name - When part is saved, saves as this name
	ThisDoc.Document.DisplayName = NewNumber
End If&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 16:26:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9477136#M108647</guid>
      <dc:creator>Eide.N</dc:creator>
      <dc:date>2020-04-28T16:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9477540#M108670</link>
      <description>&lt;P&gt;Don't for get this handy little tool:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oDoc As Document = ThisApplication.ActiveDocument
'If oDoc.FileSaveCounter &amp;gt; 0 Then
If oDoc.FileSaveCounter = 0 Then
	'Your code here
Else
	'Your other code here
End If&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Apr 2020 18:24:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9477540#M108670</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-04-28T18:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9478269#M109393</link>
      <description>&lt;P&gt;Fantastic that little piece of code is all i needed to solve all the problems.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 22:36:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/9478269#M109393</guid>
      <dc:creator>antoniobaron</dc:creator>
      <dc:date>2020-04-28T22:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to set initial filename on first save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/10738490#M130977</link>
      <description>&lt;P&gt;For the ones who came here looking for that handy little tool in Inventor 2022 (and followings), check this post:&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/how-to-check-if-a-file-has-been-saved-in-inventor-2022/td-p/10738478" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/how-to-check-if-a-file-has-been-saved-in-inventor-2022/td-p/10738478&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 16:44:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-set-initial-filename-on-first-save/m-p/10738490#M130977</guid>
      <dc:creator>CattabianiI</dc:creator>
      <dc:date>2021-11-05T16:44:46Z</dc:date>
    </item>
  </channel>
</rss>

