You can do it like this:
Sub Main()
Dim oRepresentationEvents As Inventor.RepresentationEvents
oRepresentationEvents = ThisApplication.RepresentationEvents
AddHandler oRepresentationEvents.OnActivatePositionalRepresentation, AddressOf oRepresentationEvents_OnActivatePositionalRepresentation
End Sub
Sub oRepresentationEvents_OnActivatePositionalRepresentation(ByVal DocumentObject As Inventor._AssemblyDocument, ByVal Representation As Inventor.PositionalRepresentation, _
ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum)
If DocumentObject Is ThisDoc.Document
If BeforeOrAfter = kAfter Then
'iLogicVb.RunRule("Name of rule")
MsgBox(Representation.Name)
End If
End If
End Sub
I wrote the code now to only execute if the positionrep is changed in the document the iLogic rule is in.
As it is now it only gives back the name of the positionrep when it's changed. If you uncomment the iLogicVB.RunRule and pass the name of the rule you want to run as an argument it will run that rule on positionrep change.
However, the only way to remove this Handler is to restart inventor I think. Haven't found any other way to access and remove it.
Also, if you run this rule multiple times it'll add as many handlers. meaning the rule you want to run when positionrep is changed will run as many times.
Maybe trigger this rule once the document is opened and also trigger another rule that suppress the rule
iLogicVB.Automation.GetRule("Rule Name").IsActive = False
I think this is the only way to do it by iLogic.