Loading Files with same in Inventor session

Loading Files with same in Inventor session

Anonymous
Not applicable
409 Views
3 Replies
Message 1 of 4

Loading Files with same in Inventor session

Anonymous
Not applicable

Hello,

 

Is there a way in Inventor which restricts the user from loading a file having same name.

 

Scenario:

 

I have one file in a location D:\Autodesk\Location1\Part1.ipt and second file in D:\Autodesk\Location2\Part1.ipt. (The Geometry and properties might be same or might not be same).

I open the first file Part1 from D:\Autodesk\Location1\Part1.ipt. Now this first file is loaded in Inventor session.

Now if i try to open second file Part1 from D:\Autodesk\Location2\Part1.ipt inventor should not allow me to open. (By Default Inventor allows, as the Location is different)

 

This is the case i want Inventor to handle...

 

How can i acheive this.?

0 Likes
410 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Can anybody Help me out...?
0 Likes
Message 3 of 4

matt_jlt
Collaborator
Collaborator

You will need to have an addin running that monitors the application events.

 

 

Brian Ekins post on his blog have a great example on how to use events

http://modthemachine.typepad.com/my_weblog/2013/07/add-in-with-event-example-to-replace-auto-run-mac...

 

Below is a rough example of what you need to do (please note I just threw this together and could have problems, it's just a guide)

 

Private Sub m_ApplicationEvents_OnOpenDocument( DocumentObject As Document, FullDocumentName As String, BeforeOrAfter As EventTimingEnum, Context As NameValueMap, HandlingCode As HandlingCodeEnum )

If BeforeOrAfter = EventTimingEnum.kBefore Then
        Try
            Dim strNewDoc As String = System.IO.Path.GetFileNameWithoutExtension(FullDocumentName)
            Dim oDoc As Document
            For Each oDoc In ThisApplication.Documents
                 If System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) = strNewDoc Then
                       ' Close the document
                       DocumentObject.Close ' Havn't checked if .close is the correct call
                       Exit Sub
                 End If
            Next
         Catch Ex As Exception
            messagebox.show(ex.message)
         End Try
End If

 

 

0 Likes
Message 4 of 4

Anonymous
Not applicable
This is what i am currently doing.i.e., Monitoring with an addin.
Now we cannot use adding to monitor. Thats why we want to change.

I have been listening to ApplicationEvents.OneOpenDocument and AssemblyEvents.NewOccurrence. But we cannot veto the operattion.
As per API documentation HandlingCode will be ignored for these events.
0 Likes