Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Modeling Events OnParameterChange

1 REPLY 1
SOLVED
Reply
Message 1 of 2
gert-leonvanlier
534 Views, 1 Reply

iLogic Modeling Events OnParameterChange

gert-leonvanlier
Collaborator
Collaborator

I am looking to create a trigger in my iLogic to code for when parameters are changed, so that based on the parameter changed specific code/subs are run. I found this topic and tried it in my code, but I get the following errors:

  • 'AddHandler' is not declared. It may be inaccessible due to its protection level.
  • Method argements must be enclosed in parentheses.

What am I doing wrong here? Is it possible to have a trigger event in an iLogic rule?

 

 

Sub Main()
Dim invApp As Inventor.Application
Dim modelingEvents As modelingEvents

invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") 
modelingEvents = invApp.ModelingEvents
	
AddHander modelingEvents.OnParameterChange, AddressOf modelingEvents_ParameterChange
End Sub

Sub modelingEvents_ParameterChange(documentObject As _Document, parameter As Parameter, beforeOrAfter As EventTimingEnum, context As NameValueMap, ByRef handlingCode As HandlingCodeEnum)
	If beforeOrAfter = kBefore Then
		'actions to do before the parameter changes (so with the 'old' value)
		MessageBox.Show("kBefore trigger.")
	ElseIf beforeOrAfter = kAfter Then
		'actions to do after the parameter changes (so with the 'new' value)
		MessageBox.Show("kAfter trigger.")
	End If
End Sub

 

 

 

0 Likes

iLogic Modeling Events OnParameterChange

I am looking to create a trigger in my iLogic to code for when parameters are changed, so that based on the parameter changed specific code/subs are run. I found this topic and tried it in my code, but I get the following errors:

  • 'AddHandler' is not declared. It may be inaccessible due to its protection level.
  • Method argements must be enclosed in parentheses.

What am I doing wrong here? Is it possible to have a trigger event in an iLogic rule?

 

 

Sub Main()
Dim invApp As Inventor.Application
Dim modelingEvents As modelingEvents

invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") 
modelingEvents = invApp.ModelingEvents
	
AddHander modelingEvents.OnParameterChange, AddressOf modelingEvents_ParameterChange
End Sub

Sub modelingEvents_ParameterChange(documentObject As _Document, parameter As Parameter, beforeOrAfter As EventTimingEnum, context As NameValueMap, ByRef handlingCode As HandlingCodeEnum)
	If beforeOrAfter = kBefore Then
		'actions to do before the parameter changes (so with the 'old' value)
		MessageBox.Show("kBefore trigger.")
	ElseIf beforeOrAfter = kAfter Then
		'actions to do after the parameter changes (so with the 'new' value)
		MessageBox.Show("kAfter trigger.")
	End If
End Sub

 

 

 

Labels (4)
1 REPLY 1
Message 2 of 2

gert-leonvanlier
Collaborator
Collaborator
Accepted solution

Ok, very stupid of me, I made a typo 😶. Now AddHandler is working and so are the triggers.

0 Likes

Ok, very stupid of me, I made a typo 😶. Now AddHandler is working and so are the triggers.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report