03-12-2021
07:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-12-2021
07:37 AM
This code counts non-empty lines of code in all iLogic rules of the active document (ignoring comments, line continuations, etc):
Dim doc As Document = ThisDoc.Document Dim iLogic As ApplicationAddIn = ThisApplication.ApplicationAddIns.ItemById("{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}") Dim iLogicAuto As IiLogicAutomation = iLogic.Automation Dim separators As Char() = System.Environment.NewLine.ToCharArray() Dim sb As Text.StringBuilder = New Text.StringBuilder() For Each rule As iLogicRule In iLogicAuto.Rules(doc) Dim text As String = rule.Text Dim splits As String() = text.Split(separators, StringSplitOptions.RemoveEmptyEntries) sb.Append(rule.Name).Append(" : ").Append(splits.Count).AppendLine() Next MsgBox( sb.ToString(), vbOKOnly, "Lines in " + doc.DisplayName)
Thank you,

Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.