Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Loading Files with same in Inventor session

3 REPLIES 3
Reply
Message 1 of 4
santoshr0114
259 Views, 3 Replies

Loading Files with same in Inventor session

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.?

Regards
Santosh
3 REPLIES 3
Message 2 of 4
santoshr0114
in reply to: santoshr0114

Can anybody Help me out...?
Regards
Santosh
Message 3 of 4
matt_jlt
in reply to: santoshr0114

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

 

 

Message 4 of 4
santoshr0114
in reply to: matt_jlt

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.
Regards
Santosh

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report