Run a rule when I change positional view rep

Run a rule when I change positional view rep

Anonymous
Not applicable
401 Views
2 Replies
Message 1 of 3

Run a rule when I change positional view rep

Anonymous
Not applicable

Is there a way to run a rule when I change a positional view rep?

Thanks,

Sandy

0 Likes
402 Views
2 Replies
Replies (2)
Message 2 of 3

Darkforce_the_ilogic_guy
Advisor
Advisor

I do not think you can do it ... if with view rep  mean posion under view rep... but if you use an ilogic role/form Rule to change position ... then you can simple make an ilogic rule that first change the position and next run the rule you want 

0 Likes
Message 3 of 3

JhoelForshav
Mentor
Mentor

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.