Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Lines of code

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
angermaier
397 Views, 2 Replies

iLogic Lines of code

angermaier
Enthusiast
Enthusiast

Hi everyone!

We want to understand, how many lines of code are in use in the documents in our file-store.

We have different rules in all kinds of documents.

 

Does anybody have any idea or an approach, how to find out?

 

Best regards,

Tobias

0 Likes

iLogic Lines of code

Hi everyone!

We want to understand, how many lines of code are in use in the documents in our file-store.

We have different rules in all kinds of documents.

 

Does anybody have any idea or an approach, how to find out?

 

Best regards,

Tobias

2 REPLIES 2
Message 2 of 3
AlexKorzun
in reply to: angermaier

AlexKorzun
Autodesk
Autodesk
Accepted solution

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)

AlexKorzun_0-1615562387348.png

 

 

Thank you,




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

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)

AlexKorzun_0-1615562387348.png

 

 

Thank you,




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

Message 3 of 3
angermaier
in reply to: AlexKorzun

angermaier
Enthusiast
Enthusiast
Accepted solution

Hi @AlexKorzun,

thank you very much for the quick answer. Think, this will already help to get started.

Have a nice weekend!

Tobias

0 Likes

Hi @AlexKorzun,

thank you very much for the quick answer. Think, this will already help to get started.

Have a nice weekend!

Tobias

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report