Remove iTriggers with iLogic

Remove iTriggers with iLogic

Anonymous
Not applicable
782 Views
4 Replies
Message 1 of 5

Remove iTriggers with iLogic

Anonymous
Not applicable

Hello, i have an iTrigger set up on my assembly template, however, i would like to create a code that would remove the trigger in some of my assemblies.  I cant delete the rules as they are external rules. I did found this code on the subject: 

 

SyntaxEditor Code Snippet

'capture current document
Dim oiLDoc As ThisApplication.ActiveDocument
'load up ilogic automation
Dim oiLogicAuto As Object = iLogicVb.Automation
'get container for all of the ilogic rules
Dim oRules As Object = oiLogicAuto.rules(oiLDoc)
'variable for the events rules
Dim oiLPropSet As PropertySet
'set up a counter
Dim iPropCount As Integer
'if there are no rules, then there is no need for event triggers'if there are no even rules, no need to go further'if not a part, I'm not interested
If oRules Is Nothing And oiLDoc.PropertySets.PropertySetExists("iLogicEventsRules") And oiLDoc.DocumentType = 12290 Then
'set our property set since we know it exists now
oiLPropSet = oiLDoc.PropertySets.Item("iLogicEventsRules")
'only iPart Members seem to be plagued with orphaned triggers'if there aren't any triggers, then we're done
If oiLDoc.ComponentDefinition.IsiPartMember And oiLPropSet.Count > 0 Then
'iterate through the triggers and delete each
For iPropCount = 1 To oiLPropSet.Count
oiLPropSet.Item(iPropCount).Delete
Next iPropCount
End If
End If

 

Which returns this error: Error on Line 2 : Type 'ThisApplication.ActiveDocument' is not defined.

and im not sure how to fix it. Anything would help! 

Thanks

0 Likes
783 Views
4 Replies
Replies (4)
Message 2 of 5

yvandelafontaine
Advocate
Advocate

Replace your line 2 with this:

 

oiLDoc = ThisApplication.ActiveDocument

It should work 😉

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks! I thought i had tried that already but i guess not. So that fixed my error, however it did not remove any triggers... has anyone else been able to make this work?

0 Likes
Message 4 of 5

yvandelafontaine
Advocate
Advocate

I dont have much time but... this rule seem to be made to remove trigger from ipart....

you might be better of with a parameter delete (iTrigger is a param after all)

this work for me, it delete the parameter in all parts of an assembly

 

Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document

For Each docFile In openDoc.AllReferencedDocuments

		If docFile.ComponentDefinition.IsiPartFactory Or docFile.ComponentDefinition.IsiPartMember Or docFile.ComponentDefinition.IsContentMember Then
			'Do Nothing
		Else
		
					Try
						
						Dim param As Parameter 
						param = docFile.ComponentDefinition.Parameters.Item("iTrigger0") 
						param.Delete

					Catch
'Do Nothing
End Try End If Next

 

If it work, accept as solution, and a Kudos would help me get to the next level to save the princess!

Message 5 of 5

Anonymous
Not applicable

Hello Yvan De Lafontaine, I just realized why this isn't working for me. I am talking about deleting an iTrigger, but what I am trying to do is actually remove an Event Trigger. I apologize for the mix up. The code i posted at the top was supposed to do this, however it doesn't.  Do you have any other thoughts?

0 Likes