HI yvandelafontaine,
The one way I can think of, to achieve this, is by using the RepresentationEvents.OnActivateDesignView Event.
Below is a sample piece of code that may help you get started.
Copy the below code into a code module.
Dim oRepCls As cRepEvents ' Create a new cRepEvents object
Sub StartEvents()
Set oRepCls = New cRepEvents
End Sub
Sub StopEvents()
Set oRepCls = Nothing
End Sub
Create a new class module called cRepEvents and copy below code into it, since VB only supports events within a class module
Private WithEvents RepEvents As RepresentationEvents
Private Ilogicaddin As Object
Private Sub Class_Initialize()
Set RepEvents = ThisApplication.RepresentationEvents
Set Ilogicaddin = ThisApplication.ApplicationAddIns.ItemById("{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}").Automation ' Get ilogic addin to run the rule
End Sub
Private Sub Class_Terminate()
Set RepEvents = Nothing
End Sub
Private Sub RepEvents_OnActivateDesignView(ByVal DocumentObject As Document, ByVal Representation As DesignViewRepresentation, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
Ilogicaddin.RunRule DocumentObject, "Rule0" ' The rule name that needs to be executed
End Sub
Let me know if this helps.
Regards,
Sajith
Sajith Subramanian
Autodesk Developer Network