Search and Replace Rule Text from Other Rule

Anonymous

Search and Replace Rule Text from Other Rule

Anonymous
Not applicable

Dear all,

 

Is there a rule to change text in other rule?

 

Example:

If Parameter ("ANG_LEFT") > 89 And Parameter ("ANG_LEFT") < 91 Then
Feature.IsActive("HOLE_ONE")= True
Feature.IsActive("HOLE_TWO")= False
End If

 

Nothing wrong so far. But this rule is in 100 parts. And 91 has to be 92.

Now i want use "Code Injector" to place the "search and replace rule". But I don't know how to change text from other rule.

Reply
Accepted solutions (1)
827 Views
5 Replies
Replies (5)

b_sharanraj
Advocate
Advocate

In code Injector we have two options to do this,

 

Option 1

If the Rule Name is same in all the 100 Parts, then use "Overwrite Duplicate Rules" from Advanced Options

 

Option 2

If the Rule Name are not same in all the 100 Parts, then use "Delete all Rules" and add New Rule using "Keep Rule after Run" from Advanced Options.

Regards

B.Sharan Raj

0 Likes

Anonymous
Not applicable

Dear B. Sharan Raj,

 

This could be a solution. Because the Rule Name (and the "If Parameter..." Also) is always the same but the feature names differ almost every time.

 

That's why, I think, I have to address the specific Numbers. 

0 Likes

Anonymous
Not applicable

I have a rule to get the text of a Rule (But it will search Random, not on given name in Rulelist)

 

SyntaxEditor Code Snippet

Dim oList As Collection = New Collection

oattributes = ThisDoc.Document.attributesets.item("iLogicRule_Name6")
For Each oattribute In oattributes

oList.Add(oattribute.Value.tostring())

Next

If oList.Count = 0 Then
MessageBox.Show("Empty", "ParameterList")
Return

Else

For Each st In oList

sTotal = sTotal + st & vbNewLine

Next

End If

MessageBox.Show(sTotal,"AttributeList")

 

And I have a Rule to Search and replace Parameters

 

SyntaxEditor Code Snippet

'Name of Rule: Search_and_Replace_Parameter

oSearch = InputBox("Search", "Search_and_Replace", "Find what")
oReplace = InputBox("Replace", "Search_and_Replace", "Replace with")

For Each oParameter In ThisApplication.ActiveDocument.ComponentDefinition.Parameters

'Returns index where found, or -1 if not found
If oParameter.Name.IndexOf(oSearch) > -1 Then

oParameter.Name = oParameter.Name.Replace(oSearch, oReplace)

End If

Next

 

So I need to combine these two and a need a way that it searches for a specific name 

0 Likes

Anonymous
Not applicable

I'm almost there, this works in single part:

 

SyntaxEditor Code Snippet

'Name of Rule: Search_and_Replace_iLogic

oSearch = InputBox("Search", "Search_and_Replace", "Find what")
oReplace = InputBox("Replace", "Search_and_Replace", "Replace with")

'Returns index where found, or -1 if not found
If iLogicVb.Automation.GetRule(ThisDoc.Document, "Different Angle").text.IndexOf(oSearch) > -1 Then

iLogicVb.Automation.GetRule(ThisDoc.Document, "Different Angle").text = iLogicVb.Automation.GetRule(ThisDoc.Document, "Different Angle").text.Replace(oSearch, oReplace)

End If

 

Now I only have to make it usable for Code Injector 

0 Likes

Anonymous
Not applicable
Accepted solution

FOUND IT!

 

SyntaxEditor Code Snippet

'Name of Rule: Search_and_Replace_iLogic

'To Change
oRule = "Different Angle"
oSearch = "83.5"
oReplace = "83"

'Returns index where found, or -1 if not found
If iLogicVb.Automation.GetRule(ThisDoc.Document, oRule).text.IndexOf(oSearch) > -1 Then

iLogicVb.Automation.GetRule(ThisDoc.Document, oRule).text = iLogicVb.Automation.GetRule(ThisDoc.Document, oRule).text.Replace(oSearch, oReplace)

End If