Getting filename and modelname in vs project

Getting filename and modelname in vs project

mechielvanvalen
Enthusiast Enthusiast
746 Views
3 Replies
Message 1 of 4

Getting filename and modelname in vs project

mechielvanvalen
Enthusiast
Enthusiast

Hi,

 

I'm trying to get the file -path and -name from my active model in my Visual studio project, but i cant find it...

 

Normal iLogic is: "oPath = thisDoc.Path" But it doesnt work in Visual Studio

 

Someone tips?

0 Likes
Accepted solutions (2)
747 Views
3 Replies
Replies (3)
Message 2 of 4

J-Camper
Advisor
Advisor
Accepted solution

Can you use System calls in Visual Studio?  I strictly work in iLogic right now, but I use System.IO.Path methods for File/Path info because it is quick and easy.

 

Here is a sample written in iLogic:

Dim oDoc As Document = ThisApplication.ActiveDocument 'for testing

'However you get your document Object.  Do these lines work in Visual Studio?
Dim oDirectory As String = System.IO.Path.GetDirectoryName(oDoc.FullDocumentName)
Dim oFileName As String = System.IO.Path.GetFileName(oDoc.FullDocumentName)

Logger.Trace(oDirectory)
Logger.Trace(oFileName)

 

Let me know if you have any questions, or if System calls don't work in Visual Studio.

Message 3 of 4

nmunro
Collaborator
Collaborator

The Document object in Inventor has FullFileName and FullDocumentName properties. The FullFileName property returns the full path to the file location, the FullDocumentName appends information on which LOD or Model State is active. Since part and assembly document types derive from Document, they also have these properties. The Document.Name property returns the name of the file without the path. These are all documented in the Inventor API help.

        


https://c3mcad.com

0 Likes
Message 4 of 4

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

 

Good morning, I'm a little "rusty", but I think maybe this can help you

 

Dim oDoc As Document = ThisApplication.ActiveDocument

Dim oPath as string = oDoc.fullfilename
Dim oDocName as string = oDoc.Displayname

Msgbox(oPath)
Msgbox(oDocName)

 Greetings!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn