OnFileResolution not called when part file not relative to assembly file

OnFileResolution not called when part file not relative to assembly file

Anonymous
Not applicable
1,113 Views
8 Replies
Message 1 of 9

OnFileResolution not called when part file not relative to assembly file

Anonymous
Not applicable

FileAccessEvents.OnFileResolution not called when part not relative to assembly,

is there something i am doing wrong?

 

Reason i need this is that we are opening file from another system and then downloading the files into a cache folder based on part resolution.

 

 

Situation 1, works as expected:

 

step 1. i create assembly file: C:\Users\<USER>\Desktop\inventor\Assembly1.iam

step 2. i create a part file: C:\Users\<USER>\Desktop\inventor\parts\Part1.ipt

step 3. i add part to assembly

step 4. i close all files and inventor

step 5. i delete part

step 6. i open inventor and load assembly.

step 7. FileAccessEvents.OnFileResolution called as expected.

 

Situation 2, does NOT work as expected:

 

step 1. i create assembly file: C:\Users\<user<\Desktop\inventor\Assembly1.iam

step 2. i create a part file: C:\parts\Part1.ipt

step 3. i add part to assembly

step 4. i close all files and inventor

step 5. i delete part

step 6. i open inventor and load assembly.

step 7. FileAccessEvents.OnFileResolution is not called. Nothing is called. Just the dialog is shown.

 

 

 

 

Also at first I couldnt get FileAccessEvents to fire at all? are FileAccessEvents somehow related to ActiveDocument? And is there a documentation on this somewhere?

0 Likes
Accepted solutions (2)
1,114 Views
8 Replies
Replies (8)
Message 2 of 9

Owner2229
Advisor
Advisor

Hi, in Inventor you can see question mark in top right, so click it, then click "Help" and then the second line "Programming: Help for API".

On the left go to Registry tab and paste this "FileAccessEvents Object" in the search field. In the tree double click "OnFileResolution Event". And here you go, here is your documentation.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 9

Anonymous
Not applicable

Thank you for the api reference.

 

But looking at it did not solve my problem, infact I am more sure it should work as I expect it to.

 


 

This event allows you to override Inventors standard file resolution and perform the resolution yourself. The OnFileResolution event notification is sent at the time Inventor recognizes that a file needs to be resolved but before it begins the resolution process. Through the arguments of this event, Inventor provides you all of the information it has about this reference. You can use this information to perform your own file resolution using whatever logic you choose and then supply Inventor with the full filename to use.


 

 

 

 

 

0 Likes
Message 4 of 9

Owner2229
Advisor
Advisor
Accepted solution

"For example, if there is an assembly Top.iam that contains Part.ipt, when Top.iam is opened Inventor needs to find Part.ipt on the disk in order to open it too. It does this using a combination of information stored in Top.iam and the paths defined by the active project."

 

So the issue might be that the file is outside of the project folder. Can you try to set up new/current project on path that is highter then both assembly and part folder? As you're ussing these two folders below, you can try to set it to C:\

 

C:\Users\<user<\Desktop\inventor\Assembly1.iam

C:\parts\Part1.ipt

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 9

Anonymous
Not applicable

Ah i see, it is the project path that defines what is at all resolvable, so I cannot just perform whatever logic i choose 🙂

 


 

You can use this information to perform your own file resolution using whatever logic you choose.

 


 

 

Adding the paths I need to project libraries made the event fire. Thank you for pointing out the way.

0 Likes
Message 6 of 9

Owner2229
Advisor
Advisor

You're welcomed. I'm glad i could help.

They should be careful when using "whatever you want". 😄

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 7 of 9

Anonymous
Not applicable

Actually I still think it works wrong and I cant resolve it in a correct way, just in a poor hack way.

 

 

According to steps 1. and 7. of the Inventor help, "Resolution of file search document",  I should be given a chance to resolve it in the FileAccessEvents.OnResolveFile. Nowhere it is said that if it the file is not previously saved in a library location, the event will not fire at all.

 

http://help.autodesk.com/view/INVNTOR/2016/ENU/?guid=GUID-CD73F9CD-F485-4CAE-AA64-0E80BA15CCA3

 

 

 

All in all, i think this is a bug or bad behaviour and the event should fire no matter what. I wish i knew how to make a bug report.

 

 

 

0 Likes
Message 8 of 9

Anonymous
Not applicable
Actually it works as expected with ApprenticeServerComponent but not with Inventor Addin
0 Likes
Message 9 of 9

Anonymous
Not applicable
Accepted solution
Forgot to document it here but what worked for me was to change property embed interop types to false for Autodesk.Inventor.Interop reference.

http://modthemachine.typepad.com/my_weblog/2012/07/set-embed-interop-types-to-false-to-avoid-problem...
0 Likes