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

How to compare two document internal name without open

AttilaFarkas
Advocate

How to compare two document internal name without open

AttilaFarkas
Advocate
Advocate

Hi Guys,

 

I would like to check two files via API and currently I use the internalname property for this but I have to open the document first.

If I want to process lot of files particularly big files then the process is too slow because of the open command.

One of the two comparable internal name comes from a file referece using the "FileDescription.ReferencedFileInternalName" only the second one should be read from file. 

Is there a way to get the internal name of the documents directly from the files without open them?

 

Thanks in advance.

 

Regards,

 

Attila Farkas

0 Likes
Reply
Accepted solutions (2)
4,135 Views
18 Replies
Replies (18)

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @AttilaFarkas,

 

Yes, it is possible through Apprentice server. For more details about Apprentice, refer the following link.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-F2A12822-98DE-4638-B1C7-6BEEF821D50A

 

Sample application using VB.net is attached with this post. It works for Inventor 2018. In source code, name and path of file need to update.

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

AttilaFarkas
Advocate
Advocate

Hi Chandra,

 

Thanks for the fast answer. As I know apprentice is not mentioned for Add-Ins and I need this function in my Add-In.

There is no way in standard API?

 

Regards,

 

Attila

0 Likes

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Two drawing; Part; assembly file or what?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

AttilaFarkas
Advocate
Advocate

Hi,

 

It doesn't matter the type of the document.

If I want to check that the two file is the same or not (for example you copy or rename it) then I need to compare the internal name of the documets.

The internal name is really important to resolve missing references! If the two internal name differs then Inventor doesn't replace the reference.

 

Regards,

 

Attila

0 Likes

bradeneuropeArthur
Mentor
Mentor

Hi,

 

This is how you can do that.

Public Sub prop()
Dim oinvapp As Inventor.Application
Set oinvapp = ThisApplication
Dim odoc As Document
Set odoc = oinvapp.ActiveDocument
Dim oInvRefDoc As Inventor.Document

        Dim oDocumentDescriptor As Inventor.DocumentDescriptor
        Set oDocumentDescriptor = odoc.ReferencedDocumentDescriptors.Item(1)

        Set oInvRefDoc = oinvapp.Documents.ItemByName(oDocumentDescriptor.FullDocumentName)
        MsgBox oInvRefDoc.InternalName
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

CattabianiI
Collaborator
Collaborator

Did you try opening the document as not visible?

 

SyntaxEditor Code Snippet

Dim doc As Document = ThisApplication.Documents.Open(FullFileName, False)
Dim internalName As String = doc.InternalName

 

0 Likes

AttilaFarkas
Advocate
Advocate

Hi,

 

I know how can I get the internal name of the referenced file, the problem is that how can I find the missing file in a folder.

How I do it know:

 

1. For example I open a drawing.

2. Search for the references.

3. If a reference missing then I get the internal name of the missing document

4. Iterate through all files in the project folder, open them check the internal name is the same or not like the missing reference and if it is than I change the reference.

 

This is time-consuming process and it should be faster if I can read the internal name directly from the file.

For example if I want to check that a DWG file is Inventor or AutoCAD DWG then I don't need to open it I can check it directly in the file with this function:

FileManager.IsInventorDWG(FullFileName as string) as boolean.

I looking for a command something like this.

 

Regards,

 

Attila

 

0 Likes

AttilaFarkas
Advocate
Advocate

Yes I always open the files in silent mode but it also slow if I want to manage thousands of files especially if there are large assemblies also.

0 Likes

AttilaFarkas
Advocate
Advocate

FileManager object has a function GetIdentifierFromFileName(FullFileName as string, byref Identifier() as byte, [AbsolutePath] as string) but I don't understand how it works, especially this "Identifier() as byte". I tried to use it but I've got an errormessage. Maybe I did something wrong. Currently I'am not sure that this is the right command. I didn't find any sample about this.

0 Likes

CattabianiI
Collaborator
Collaborator

Instancing your byte array like this should work:

SyntaxEditor Code Snippet

Dim identifier As Byte() = New Byte() {}

 But I don't know how that method works either.

0 Likes

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

Hi Attila,

 

1) Are you just trying to make sure that you can use the ReplaceReference on the given file or trying to find out if the files are exactly the same?

Here is an overview on these things: 
http://adndevblog.typepad.com/manufacturing/2015/12/differentiate-inventor-documents.html

 

2) You can use Apprentice from an add-in, just not directly - i.e. you could create an app based on Apprentice (e.g. called GetInternalName.exe) that you could call from your add-in to find out the internal name of a given file 

 

3) Inventor files are using Structured Storage - some info on that here:
http://adndevblog.typepad.com/manufacturing/2013/03/save-extra-data-in-inventor-file-3.html

So you could also just use that API which is fully independent of Inventor. When looking into a part file it looks like you'll find the internal name here:
InternalName.png

 

4) FileManager.GetIdentifierFromFileName

I never used this function, but the word "Creates" in the Online Help seems to suggest that it's not the InternalName, since that does not need to be created - it's always there. I'll ask my colleagues to comment on that. 
I also tested this function in VBA and it seems to work fine, but the result does not seem to resemble the InternalName.

 

I hope this helps.

 

Cheers,



Adam Nagy
Autodesk Platform Services

CattabianiI
Collaborator
Collaborator
Accepted solution

I found out how to get the InternalName from the GetIdentifierFromFileName identifier byte array.

It seems the internalName is stored starting from the fitfth byte to last in little endianness mode per guid group

 

Try this method I tested in iLogic:

 

SyntaxEditor Code Snippet

Public Function FullFileNameToGUID(ffn As String) As String

	Dim Identifier As Byte() = New Byte() {}
	ThisApplication.FileManager.GetIdentifierFromFileName(ffn, Identifier)

	Dim guidOffset As Integer = 4
	
	Dim guidAsByteList As New List(Of Byte) 
        
' group 1: 4 bytes For i As Integer = Identifier.Length - 1 - guidOffset To Identifier.Length - 4 - guidOffset Step -1 guidAsByteList.Insert(0, Identifier(i)) Next
' group 2: 2 bytes For i As Integer = Identifier.Length - 4 - 1 - guidOffset To Identifier.Length - 4 - 2 - guidOffset Step -1 guidAsByteList.Insert(0, Identifier(i)) Next
' group 3: 2 bytes For i As Integer = Identifier.Length - 6 - 1 - guidOffset To Identifier.Length - 6 - 2 - guidOffset Step -1 guidAsByteList.Insert(0, Identifier(i)) Next
' group 4: 2 bytes For i As Integer = Identifier.Length - 8 - 1 - guidOffset To Identifier.Length - 8 - 2 - guidOffset Step -1 guidAsByteList.Insert(0, Identifier(i)) Next
' group 5: 6 bytes For i As Integer = Identifier.Length - 10 - 1 - guidOffset To Identifier.Length - 10 - 6 - guidOffset Step -1 guidAsByteList.Insert(0, Identifier(i)) Next Dim guid As New Guid(guidAsByteList.ToArray) Return guid.ToString.ToUpper End Function

 

AttilaFarkas
Advocate
Advocate

Hi Cattabianil,

 

Thank you for your idea, I will try it soon.

 

Regards,

 

Attila

0 Likes

AttilaFarkas
Advocate
Advocate

Hi Guys,

 

Thank you very much for the lot of useful information. As I see the optimal solution is depends on the situation:

 

1. If I work with an Add-In and I just want to check the internal name of a file (for example compare two files) then the best way is the FileManager.GetIdentifierFromFilename. Cattabianil its amazing that you can figured it how it works. Which planet did you come from? 🙂 I've tested it and its exactly the same then the Document.InternalName.

 

2. If I just want to work with iproperties of files then the Apprentice is the best tool.

 

3. If I have to use Add-In and I have to work with iproperties also then the combination of Add-In and Apprentice should be the rigth way like Adam mentioned.

 

Adam also thank you for the detailed informations about the possibilities!

 

How can I accept two solutions? 🙂

 

I hope this topic will be useful for everybody!

 

Best regards,

 

Attila Farkas

Anonymous
Not applicable

i jast finished create a tools with c# to read iproperties  without open file, if you need that i can send you source

tall me if you need that

0 Likes

j.haggenjos
Advocate
Advocate

Hi @Anonymous, 

 

I am interested. It would really help me for my project if you could post your code here.

0 Likes

CattabianiI
Collaborator
Collaborator

Hi @j.haggenjos,
if you're looking for how to read and write iProperties outside Inventor you can just google Inventor Apprentice, this mod the machine blog entry is a good article to start with.  

If @Anonymous can read iProperties without apprentice and opening file (via StructuredStorage?) I'm interested too, even if it could be a "DO NOT TRY THIS AT HOME!"

0 Likes

j.haggenjos
Advocate
Advocate

Thanks @CattabianiI, I'm interested in the "do not try this at home" option as well. I did some research on Apprentice, I'll probably use it for other things, but for my use case I think accessing the StructuredStorage would be the best option.

I tried following this guide with no luck. After some trial and error, I reached the limit of my knowledge and it did not work. I moved on as it is "nice to have" but not mandatory for my project.

If @Anonymous can provide us with a working sample I'll be giving this a last try.

0 Likes