Event when Assembly/Drawing is completely opened

Event when Assembly/Drawing is completely opened

ge.ki
Explorer Explorer
1,702 Views
9 Replies
Message 1 of 10

Event when Assembly/Drawing is completely opened

ge.ki
Explorer
Explorer

Hello,

 

Is there any event triggered, as soon as all files of an assembly (or drawing) are loaded?

Inside the OpenDocument event, I watched an assembly with subassemblies opening with MsgBox(FullFileName). The top-level file name is at least the one showing up at first (in kBefore), but after that, I don't see when it's finished.

I've tried serval workarounds without success Smiley Sad

 

If there's nothing I guess I have to catch the assembly name in the beginning, search for all dependencies and then wait until all of them went through the opening process. But this sounds kind of cumbersome to me.

I hope there's is another way...

 

Thank you!

0 Likes
Accepted solutions (1)
1,703 Views
9 Replies
Replies (9)
Message 2 of 10

bradeneuropeArthur
Mentor
Mentor

Hi,

 

I use "Inventor.ready = true" frequently

 

Regards,

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 !


 


EESignature

0 Likes
Message 3 of 10

ge.ki
Explorer
Explorer

Hi and thanks for your answer!

I've just tried it but it fires too often.

Here's where I've used it:

Private Sub m_ApplicationEvents_OnOpenDocument(ByVal DocumentObject As Inventor._Document, ByVal FullFileName As String, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_ApplicationEvents.OnOpenDocument

  If BeforeOrAfter = EventTimingEnum.kAfter Then
    'Some other code 
    If g_inventorApplication.ready = True Then
      MsgBox("ready")
    End If
End If End Sub

And the OnReady event is triggered only once after Inventor is initialized (as described in the API help), not after opening a file.

 

Do I miss something here?

 

0 Likes
Message 4 of 10

wangdu
Collaborator
Collaborator

Hi,

 

I have also notice the same thing.

I am currently storing the context.Item["TopLevelfilename"] passed in the kBefore event and then in the kAfter event comparing the stored value against the "fulldocumentname" parameter (which is cumbersome as you have mentioned) that seems to do the trick. 

Wangdu

 

coolOrange

www.coolOrange.com

0 Likes
Message 5 of 10

bradeneuropeArthur
Mentor
Mentor

Hi,

I am far from my desk but you could try this:

You could try to check the event per "DocumentObject" type.

just do it for one type either:

  • DocumentObject. type = ...Assembly
  • DocumentObject. type = ...Part
  • DocumentObject. type = ...Drawing

Regards,

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 !


 


EESignature

0 Likes
Message 6 of 10

YuhanZhang
Autodesk
Autodesk

From your description seems the top assembly only fires the OnOpenDocument once(kBefore) and ignores the kAfter. Does this happen to all the assemblies there or only happen to specific assemblies? Can you try below EventWatcher.exe tool if you installed the DeveloperTools.msi to double check:

 

C:\Users\Public\Documents\Autodesk\Inventor 2019\SDK\DeveloperTools\Tools\EventWatcher\bin\Release\EventWatcher.exe 

 

1. Start Inventor.

2. Run the EventWatcher.exe.

3. Check the ApplicationEvents.OnOpenDocument event.

4.Open your assembly.

5. In the output panel, copy the results in a text editor and search if the OnOpenDocument fires for kBefore and kAfter for the assembly.

 

Please let me what you see with the tool.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 7 of 10

wangdu
Collaborator
Collaborator

Hi,

 

The event is fired in both kBefore and kAfter for the topassembly. That's not the issue for me at least. The issue is that the context.Item["TopLevelFilename"] in the kAfter event is different from the kBefore event. The value of the context.Item["TopLevelFilename"] in the case of kAfter event is always same as fullDocumentName parameter.  The value for TopLevelFilename should not get changed in the kAfter event since there is only one Top assembly or part or drawing.

 

Wangdu

 

coolOrange

www.coolOrange.com

0 Likes
Message 8 of 10

YuhanZhang
Autodesk
Autodesk
Accepted solution

This should be as designed if you read the details of the description for the Context argument:

Output NameValueMap object that can be used to determine the context of why the event fired. Additional information is provided through this argument to help in understanding the context of how the document is being opened. Name = "TopLevelFilename", Value = The full filename of the top-level file that was opened that's causing this file to be opened. For example, if an assembly is opened and a document referenced by that assembly is opened as a result, the TopLevelFilename will be the full filename of the assembly. This value can be the same as the FullDocumentName argument which indicates this document was opened by itself.

So you can handle this in your code. Hope this clears.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 9 of 10

wangdu
Collaborator
Collaborator

Hi,

 

Thank you for your reply.

 

It is exactly what I understood that the document if opened by itself has the TopLevelFilename has the samesvalue as the FullDocumentName. And the issue is it is always same no matter whether the document is opened by itself or by a top level assembly or drawing.

Regards,

Wangdu

0 Likes
Message 10 of 10

ge.ki
Explorer
Explorer

Thanks for clarifying! Sounds like the solution.

I'll have to try that first, but unfortunately project priorities changed so I won't have time for that soon.

0 Likes