ilogic Log , get code Line?

ilogic Log , get code Line?

Curtis_Waguespack
Consultant Consultant
1,595 Views
8 Replies
Message 1 of 9

ilogic Log , get code Line?

Curtis_Waguespack
Consultant
Consultant

 

@MjDeck 

 

Is there some way to have the code line of a rule show up in the iLogic Log ? (without having to add it manually)

 

Something like this where "Current.Line" would just return the line the Debug line is on?

 

The goal here would be to see the last line number before an error occurred... something like this:

 

111.JPG

 

 

222.JPG

 

 

Even better would be to be able to see the line of code that creates the error in the error message, something like this:

 

555.JPG

 

Thanks!

EESignature

Accepted solutions (1)
1,596 Views
8 Replies
Replies (8)
Message 2 of 9

MjDeck
Autodesk
Autodesk

Hi Curtis,

 It might be possible to show the line number with the error message in a future version.

 There is an alternative that works now: you can debug errors in Visual Studio. That will bring you right to the line in a slightly modified version of the rule.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 9

Curtis_Waguespack
Consultant
Consultant

@MjDeck wrote:

... in a future version.

 


ok, well when I was looking at the iLogic Log tools, and it seemed so obvious to me that grabbing the code line would provide some extremely helpful ability, that I thought maybe I was just missing something...

 

but yes if we could get the line of code that causes an error in the error message, it would be helpful too.

 

thanks for the reply!

EESignature

Message 4 of 9

floccipier
Advocate
Advocate
HI MjDeck,
Do we have update on this?
Thank you.
0 Likes
Message 5 of 9

floccipier
Advocate
Advocate
Thanks for this tip.
0 Likes
Message 6 of 9

JelteDeJong
Mentor
Mentor

if you want to write the line number to the logger. you can create a function that will give you the line number. You would get something like this:

Sub Main()
    ' your rule code here 
    Logger.Info(LineNumber() & ": Foo")
    ' and more rule code here
End Sub

Private Shared Function LineNumber(<Runtime.CompilerServices.CallerLineNumber> ByVal Optional lineNumberCaller As Integer = 0) As String
        ' the number 2 here is the difference between the line number 
	' in your rule and the code that is actual run. You might need
	' to tweak this number in your inventor version
	Return lineNumberCaller - 2
End Function

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 9

MjDeck
Autodesk
Autodesk

Thanks @JelteDeJong , that is useful.

 

@floccipier , there is no progress yet on the ability to show the line number in the error message. This is internal issue number INVGEN-53774.

If you have Visual Studio, you can debug iLogic rules


Mike Deck
Software Developer
Autodesk, Inc.

Message 8 of 9

floccipier
Advocate
Advocate

@MjDeck 

 

I am using VS to debug the code and I must say it is impressive.

0 Likes
Message 9 of 9

MjDeck
Autodesk
Autodesk
Accepted solution

@Curtis_Waguespack , @floccipier , and @JelteDeJong : Inventor 2022.2 will show the line number in error messages.


Mike Deck
Software Developer
Autodesk, Inc.