Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
LSKELLY
603 Views, 4 Replies

How to get last SaveAs path in iLogic?

When you "SaveAs" a new document in Inventor it defaults to the last saved path.

 

How do I get this path as a string value in iLogic?

 

I expect it should look something like this:

 

MessageBox.Show(ThisApplication.LastSaveAsPath(), "Last SaveAs Path")

 

LSKELLY
in reply to: LSKELLY

I got a workaround to my problem by using ThisApplication.CommandManager..ControlDefinitions.Item("AppFileSaveAsCmd") to run the "SaveAs" command instead of ThisDoc.Document.SaveAs()

 

The idea was to make a "Smart SaveAs" rule in a drawing document which would auto-populate the saveas dialog with PartNumber - RefModelFilename.idw to save time when saving a lot of drawings.

 

As a workaround, my code uses the clipboard instead:

 

Dim openDoc As Document
openDoc = ThisDoc.Document

'Look at the model file referenced in the open document
Dim docFile As Document
If ThisDoc.ModelDocument IsNot Nothing Then
docFile = ThisDoc.ModelDocument
Else
MessageBox.Show("This drawing has no model reference", "iLogic")
Return
End If
    
'format model file name                   
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)                        
Dim docFName As String 
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 
'remove Extension
Dim docFNameSimple As String 
docFNameSimple = Left(docFName, Len(docFName) - 4) 

ModelPartNumber = iProperties.Value(docFName, "Project", "Part Number")
'ModelDescription = StrConv(iProperties.Value(docFName, "Project", "Description"), VbStrConv.ProperCase)'ModelTitle = StrConv(iProperties.Value(docFName, "Summary", "Title"), VbStrConv.ProperCase)'ModelSubject = StrConv(iProperties.Value(docFName, "Summary", "Subject"), VbStrConv.ProperCase)

AutoFilename = ModelPartNumber & " - " & docFNameSimple
Clipboard.SetText(AutoFilename)

ThisApplication.UserInterfaceManager.UserInteractionDisabled = False

Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager

Dim oDef As ControlDefinition
oDef = oCommandMgr.ControlDefinitions.Item("AppFileSaveAsCmd")

oDef.Execute2(False)

 

Still it would be nice to know if there is a way to get the last saved file location in iLogic.

442780782
in reply to: LSKELLY

hello!
Is the above code only suitable for the engineering drawing environment
WCrihfield
in reply to: 442780782

Hi @442780782.  That overall code example above does not really appear to be document type specific.  But the task it is doing could be done in a simpler way, using much less code.  What are you currently trying to do?

If the title of this topic is what caught your attention, then you may like the following vb.net code property:

Microsoft.VisualBasic.FileIO.FileSystem.CurrentDirectory 

It is a Read/Write property with a String type value representing a system-wide environment variable.

Also, in the Inventor API, we have this method that we can use for 'posting' things like file names, Strings, Booleans, and such to accompany command execution calls.

CommandManager.PostPrivateEvent (ThisApplication.CommandManager.PostPrivateEvent)

It will post (or send) some data up into Inventor's session memory, similar to the clipboard method being used in the example above, but scoped to Inventor's internal clipboard, instead of the whole operating system's clipboard.  It has a companion method also, for clearing such data, when needed.

CommandManager.ClearPrivateEvents 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

442780782
in reply to: WCrihfield

Thank you for your helpThanks helps