- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
(Inventor 2021.2)
I have been referring to this post: Solved: Ilogic to add ilogic to event triggers - Autodesk Community - Inventor which @Sergio.D.Suárez solved in 2019. I have created a part file from which I will run a rule that will:
- Select a solid body
- Open a new part
- derive the solid body into it
- create some parameters
- write an (internal) ilogic rule in the part to refer the parameters back to the derive 'master'
- create an event trigger to run the rule when any part model geometry changes (based on master changes)/before save.
This has been surprisingly successful given my modest ilogic abilities. The only thing not working correctly is the last step. The event trigger is created and applied in the new part, no errors are produced - it just doesn't seem to function properly! Interestingly the before save trigger does work as expected, just not the model geometry change.
I'm having difficulty finding any info on this in the API help... I have re-created the problem with two sample parts below. Running the event trigger rule in DerivePartA.ipt will create the trigger in the box but it doesn't work when geometry is changed in DeriveBaseA.ipt. Delete this and manually add the trigger and it works!
Any thoughts?
'This sub creates an event trigger to make sure the transfer is always updated
Sub Events
On Error Resume Next
Dim EventPropSet As Inventor.PropertySet
EventPropSet = GetiLogicEventPropSet(ThisApplication.ActiveDocument)
EventPropSet.Add("Iproperties (Automatic)", "PartBodyChanged", 1200)
EventPropSet.Add("Iproperties (Automatic)", "BeforeDocSave", 700)
'After Open Document : AfterDocOpen : 400
'Close(Document) : DocClose : 500
'Before Save Document : BeforeDocSave : 700
'After Save Document : AfterDocSave : 800
'Any Model Parameter Change : AfterAnyParamChange : 1000
'Part Geometry Change** : PartBodyChanged : 1200
'Material Change** : AfterMaterialChange : 1400
'Drawing View Change*** : AfterDrawingViewsUpdate : 1500
'iProperty(Change) : AfterAnyiPropertyChange : 1600
'Feature Suppression Change** : AfterFeatureSuppressionChange : 2000
'Component Suppression Change* : AfterComponentSuppressionChange : 2200
'iPart / iAssembly Change Component* : AfterComponentReplace : 2400
'New Document : AfterDocNew : 2600
InventorVb.DocumentUpdate()
End Sub
'***************************************************************************************************************************
'part of the event trigger
Function GetiLogicEventPropSet(cDocument As Document) As Inventor.PropertySet
On Error Resume Next
iLogicEventPropSet = cDocument.PropertySets.Item("iLogicEventsRules")
If iLogicEventPropSet Is Nothing Then
iLogicEventPropSet = cDocument.PropertySets.Item("_iLogicEventsRules")
End If
If iLogicEventPropSet.InternalName <> "{2C540830-0723-455E-A8E2-891722EB4C3E}" Then
Call iLogicEventPropSet.Delete
iLogicEventPropSet = cDocument.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If iLogicEventPropSet Is Nothing Then
iLogicEventPropSet = cDocument.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If iLogicEventPropSet Is Nothing Then
MsgBox ("Unable to create the Event Triggers property for this file!", , "Event Triggers Not Set")
Err.Raise(1)
Exit Function
End If
On Error GoTo 0
Return iLogicEventPropSet
End Function
Thanks,
Glenn
Solved! Go to Solution.