Ilogic Trigger - New Document

Ilogic Trigger - New Document

jparks_79
Collaborator Collaborator
615 Views
13 Replies
Message 1 of 14

Ilogic Trigger - New Document

jparks_79
Collaborator
Collaborator

Hello,

 

 

I have created a simple external rule to set the active Material library to a custom library of my company. This rule runs great from the iLogic browser. But when I set it to run as an event trigger for "New Document", the library wont change on the 1st New document event per inventor session. Every subsequent "New document" event, the rule runs. I'm at a loss. Here is the code block:

Sub Main()
	' This section sets the active material library to custom library
        Dim oHMaterialLibrary As AssetLibrary
        
        oHMaterialLibrary = ThisApplication.AssetLibraries.Item("Autodesk Material Library")
                     
        ThisApplication.ActiveMaterialLibrary() = oHMaterialLibrary
			
End Sub

After debugging with a message box, I noticed the material updates on the first documents. So maybe there is an issue with timing? Does anyone have a tip?

 

 

running Inventor 2020.2

0 Likes
616 Views
13 Replies
Replies (13)
Message 2 of 14

BrandonBG
Collaborator
Collaborator

I'm not sure how you have your trigger set up, but this is what works for me.

 

Edit the template file for your assembly or part. On the Manage tab, click on Event Triggers.

 

On the This Document tab, add the external rule to New Document.

 

Brandon

 

trigger.JPG

0 Likes
Message 3 of 14

bradeneuropeArthur
Mentor
Mentor

Hi,

 

You can't change this (Library switch) with a document opened.

This will not work with ilogic this way.

 

Tip:

 

Start programming your own (Custom) add-ins.

This will solve these kind of problems.

 

This issue is easy to solve with an add-in written with ie Vb.net

 

If you need any help with Add-ins please let me know.

 

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 4 of 14

BrandonBG
Collaborator
Collaborator
Dim sAppearanceLibrary As String
sAppearanceLibrary = "The Name"

ThisApplication.ActiveAppearanceLibrary() = ThisApplication.AssetLibraries.Item(sAppearanceLibrary)

I'm able to manipulate the active appearance library with iLogic. Does the material library work differently?

 

Brandon

0 Likes
Message 5 of 14

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Hmmmm!!

 

I need to take a closer look at this.

Seems weird, since this can only be done in the project file when no files are opened.

 

Give me some time...

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 14

jparks_79
Collaborator
Collaborator

Thanks for the advise. Changing of the Current Material library is possible at any point while a document is opened from standard inventor behavior. You can try it. Inventor comes by default with 2...Inventor Material Library and Autodesk Material Library. In the project, you can define the available material libraries, as well as an "Active" or "Default". But you can change the active library from the UI.

 

Sorry, I am trying to attach a screenshot from the triggers dialog, but It wont persist. I essentially have the same setting, only it is in the "Part" tab. I do not want to attach any logic to the template file.

 
 

The logic works fine while running from the iLogic browser, it also works fine on any new document after the 1st in the inventor session. I just cant figure out what is happening on the first new document which is preventing the update.

 

Addins are much more powerful and flexible, I am aware. But I just needed something quick that I could deploy to several machines at once. And an add-in just seemed a little overkill.

0 Likes
Message 7 of 14

bradeneuropeArthur
Mentor
Mentor

What version of inventor are you using?

I cannot with 2018

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 8 of 14

jparks_79
Collaborator
Collaborator

Inventor 2020

0 Likes
Message 9 of 14

bradeneuropeArthur
Mentor
Mentor

It seems that the API allows you to change it...

 

 

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 10 of 14

bradeneuropeArthur
Mentor
Mentor

Hi,

 

For me it works too in inventor 2020.

 

this code I use in  VBA:

Sub Main()
    ' This section sets the active material library to custom library
        Dim oHMaterialLibrary As AssetLibrary
        
        Set oHMaterialLibrary = ThisApplication.AssetLibraries.Item("Autodesk Material Library")
                     
        ThisApplication.ActiveMaterialLibrary() = oHMaterialLibrary
        
        MsgBox ThisApplication.ActiveMaterialLibrary.DisplayName
            
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 !


 


EESignature

0 Likes
Message 11 of 14

bradeneuropeArthur
Mentor
Mentor

And the following too:

 

Public Sub main2()
Dim sAppearanceLibrary As String
sAppearanceLibrary = "Autodesk Material Library"

ThisApplication.ActiveAppearanceLibrary() = ThisApplication.AssetLibraries.Item(sAppearanceLibrary)
MsgBox ThisApplication.ActiveAppearanceLibrary.DisplayName

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 !


 


EESignature

0 Likes
Message 12 of 14

bradeneuropeArthur
Mentor
Mentor

for I-logic:

 

These changes the active libaries in the application.

These can be change since they are actually filters within the application.

But you cannot change the active library in the project.

I misunderstood your question, because you didn't mention the filter in the application.

But this must work of course...

Sub Main()
    ' This section sets the active material library to custom library
        Dim oHMaterialLibrary As AssetLibrary
        
        oHMaterialLibrary = ThisApplication.AssetLibraries.Item("Autodesk Material Library")
                     
        ThisApplication.ActiveMaterialLibrary() = oHMaterialLibrary
        
        MsgBox (ThisApplication.ActiveMaterialLibrary.DisplayName)
            
End Sub

Public Sub main2()
Dim sAppearanceLibrary As String
sAppearanceLibrary = "Autodesk Material Library"

ThisApplication.ActiveAppearanceLibrary() = ThisApplication.AssetLibraries.Item(sAppearanceLibrary)
MsgBox (ThisApplication.ActiveAppearanceLibrary.DisplayName)

End Sub

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 13 of 14

jparks_79
Collaborator
Collaborator

@bradeneuropeArthur 

 

Thanks for your help. Sorry for the confusion

 

As for your samples, I am not sure If I mentioned in my original post, but this whole behavior is unusual. If you "Show" the message box indicating the new active library, everything works. Which looks like what you did.

 

Try commenting out your message box command.

attach the rule to "New document" trigger, for "Parts"

Close inventor

Open inventor

Create a new ipt

 

When I make those changes, the rule doesn't run the first time. Does your library change to the specified library?

 

I see you are working on the appearance library, which Is not what I am trying to set. I don't know if the behavior is any different.

0 Likes
Message 14 of 14

bradeneuropeArthur
Mentor
Mentor

I tested both Appearance and Material.

 

But not for the new document

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