Active document path location vb.net

Active document path location vb.net

Anonymous
Not applicable
1,747 Views
3 Replies
Message 1 of 4

Active document path location vb.net

Anonymous
Not applicable

Hi, 

 

I need to get the active file location, but I can only retrive a files entire location and name with the following code...

 

 

Dim inventorApp As Inventor.Application
inventorApp = GetObject(, "Inventor.Application")
MsgBox(inventorApp.ActiveDocument.FullFileName)

 

 

How can I do this, also is it possible to check if that document has been saved first?

0 Likes
1,748 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor
SO use string concatenation to make it how you want it.

Google "Msdn + vb.net + string operations" and look around at InStr and InStrRev and Right And Left and Mid.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 4

MechMachineMan
Advisor
Advisor
Also, search File.Exists operations through the same website.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 4 of 4

ekinsb
Alumni
Alumni

The FullFileName property will return an empty string if the file hasn't been saved yet.  There are also some great functions in the System.IO.Path library provided by .Net.  The following code demonstrates both of these ideas.

 

If doc.FullFileName = "" Then
    MsgBox("The file has not been saved.")
Else
    Dim path As String = System.IO.Path.GetDirectoryName(doc.FullFileName)
    MsgBox "The folder of the active document is: " & path
End If

 

 

In the example above if doc.FullFileName is "C:\Users\Brian\Files\Part1.ipt", the variable path will be "C:\Users\Brian\Files".


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog