Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show only
|
Search instead for
Did you mean:
This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.Translate
here is a sample rule that copies internal rules from one file to another
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
'create list
Dim oList As New ArrayList
' Define the iLogic addin
Dim iLogicAddIn As ApplicationAddIn = _
ThisApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
' Get the iLogic automation object
Dim iLogic As Object = iLogicAddIn.Automation
'get collection of rules
Dim ruleName As String
Dim rules As Object
rules = iLogicVb.Automation.Rules(oDoc)
'make sure there are rules in the file
'and then add them to the list
If Not (rules Is Nothing) Then
For Each rule In rules
ruleName = rule.Name
oList.Add(ruleName)
Next
Else
'no rules found
Return 'exit rule
End If
'get user input
sRuleName = InputListBox("Select a Rule to copy", _
oList, oList(0), "iLogic", "List")
If sRuleName = "" Then
Return
End If
'get rule text
For Each iRule As iLogicRule In rules
If iRule.Name = sRuleName
oRuleText = iRule.Text
End If
Next
'get list of open documents
oList.Clear
For Each oDoc In ThisApplication.Documents.VisibleDocuments
oList.Add(oDoc.DisplayName)
Next
'get user input
oDocName = InputListBox("Select an destination file", _
oList, oList(0), "iLogic", "List")
If oDocName = "" Then
Return
End If
'get the rules in the destination doc
For Each oDoc In ThisApplication.Documents.VisibleDocuments
If oDocName = oDoc.DisplayName Then
rules = iLogicVb.Automation.Rules(oDoc)
Exit For
End If
Next
'make sure there are rules in the file
'and make sure a rule of the same name is not present
If Not (rules Is Nothing) Then
For Each rule In rules
If sRuleName = rule.Name Then
MsgBox("A rule named " & sRuleName & _
" already exists in " & oDoc.DisplayName, , "ilogic")
Return 'exit rule
End If
Next
End If
'copy the rule to the document
Try
iLogic.AddRule(oDoc, sRuleName, oRuleText)
Catch
MsgBox("something went wrong", , "iLogic")
End Try
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oList As New ArrayList
' iLogic automation object
Dim iLogicAddIn As ApplicationAddIn = ThisApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
Dim iLogic As Object = iLogicAddIn.Automation
' Ophalen van regels
Dim allRules As Object = iLogic.Rules(oDoc)
If allRules Is Nothing Then
MsgBox("Geen regels gevonden.", , "iLogic")
Return
End If
Dim selectedRules As New List(Of String)
Do
oList.Clear()
For Each rule In allRules
If Not selectedRules.Contains(rule.Name) Then
oList.Add(rule.Name)
End If
Next
oList.Add("Klaar") ' Voeg "Klaar" toe als stopoptie
Dim pick As String = InputListBox("Selecteer een regel (of 'Klaar')", oList, oList(0), "iLogic", "Regel Selectie")
If pick = "Klaar" Or pick = "" Then Exit Do
If Not selectedRules.Contains(pick) Then selectedRules.Add(pick)
Loop
If selectedRules.Count = 0 Then
MsgBox("Geen regels geselecteerd.", , "iLogic")
Return
End If
' Selecteer bestemmingsbestand
oList.Clear()
For Each oDoc In ThisApplication.Documents.VisibleDocuments
oList.Add(oDoc.DisplayName)
Next
Dim oDocName As String = InputListBox("Selecteer doelbestand", oList, oList(0), "iLogic", "Bestand")
If oDocName = "" Then Return
' Zoek doelbestand
Dim targetDoc As Document = Nothing
For Each doc In ThisApplication.Documents.VisibleDocuments
If doc.DisplayName = oDocName Then
targetDoc = doc
Exit For
End If
Next
If targetDoc Is Nothing Then
MsgBox("Doelbestand niet gevonden.", , "iLogic")
Return
End If
' Haal regels van doelbestand op
Dim targetRules As Object = iLogic.Rules(targetDoc)
' Voeg regels toe
Dim conflictRules As New List(Of String)
For Each ruleName In selectedRules
' Zoek de tekst van de regel
Dim ruleText As String = ""
For Each rule In allRules
If rule.Name = ruleName Then
ruleText = rule.Text
Exit For
End If
Next
' Controleer of regel al bestaat
Dim exists As Boolean = False
For Each tr In targetRules
If tr.Name = ruleName Then
conflictRules.Add(ruleName)
exists = True
Exit For
End If
Next
If Not exists Then
Try
iLogic.AddRule(targetDoc, ruleName, ruleText)
Catch ex As Exception
MsgBox("Fout bij kopiëren van regel '" & ruleName & "'", , "iLogic")
End Try
End If
Next
' Toon eventueel conflicten
If conflictRules.Count > 0 Then
MsgBox("De volgende regels zijn niet gekopieerd omdat ze al bestaan:" & vbCrLf & String.Join(vbCrLf, conflictRules), , "iLogic")
Else
MsgBox("Regels succesvol gekopieerd!", , "iLogic")
End If
Thanks a lot for the code and inspiration! Based on it, I created a rule for copying/deleting selected or all rules and forms, but with a slightly faster selection from a single list...
Many thanks!
I don't even want to comment on the fact that this isn't standard 😕