Clear iLogic log window at start of rule?

Clear iLogic log window at start of rule?

Rory_M
Advocate Advocate
3,371 Views
11 Replies
Message 1 of 12

Clear iLogic log window at start of rule?

Rory_M
Advocate
Advocate

Is there an iLogic command to clear the log window?

 

I have a rule that checks all the parts in an assembly and copies their drawings (if they exist) into a specific folder. All I need is a simple text list of which of the parts had a drawing and which didn't.

 

I can write to a text file or spreadsheet but in this instance I don't need to keep a proper log, a transient list will do.

 

All I want to do is clear the existing log window at the start of the rule and then write the list to it.

 

I know you can RMB on the log to clear the log, any ideas if this can be done via code?

0 Likes
3,372 Views
11 Replies
Replies (11)
Message 2 of 12

Michael.Navara
Advisor
Advisor

I don't know this can be done via code. But for simple text output you can use some "local log". For example you can use a StringBuilder object

 

Dim log As New System.Text.StringBuilder
log.AppendLine("Log start")

For i = 1 To 10
	log.AppendFormat("Line: {0}{1}", i, vbCrLf)
Next

log.AppendLine("Log end")
MsgBox(log.ToString())

 

 

0 Likes
Message 3 of 12

TechInventor20
Advocate
Advocate
0 Likes
Message 4 of 12

Rory_M
Advocate
Advocate

Thanks for the responses.

It looks like clearing the log can't be done so I'll go for one of the alternative methods instead.

 

 

0 Likes
Message 5 of 12

WCrihfield
Mentor
Mentor

I believe it can be done.  It's not as straight forward as it maybe should be, but here's something I think you could use.

Try this:

Dim oLogFile As String = iLogicVb.Automation.LogControl.FullFileName
System.IO.File.WriteAllText(oLogFile,"")

It gets the full path and file name with extension, of the current iLogic log file (usually in a temp folder), then simply overwrites any data that is currently in it with an empty string.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 12

Rory_M
Advocate
Advocate

Thanks for the code, I've tried it and it fails. The error is:

 

Could not find a part of the path 'C:\Users\rory m\AppData\Local\Temp\iLogic\Log_ec021af6-9920-4078-99cb-176fb233e169.txt'

 

The log file and folder listed don't exist. The folder isn't hidden, it's not there.

 

 

 

0 Likes
Message 7 of 12

WCrihfield
Mentor
Mentor

This is odd behavior.  It seems that the 'active' log file only exists in session memory.  The file isn't actually written to the hard drive, even though it has a file system address, and file name.  You can save a copy of the file off, and that will exist on the hard drive, but will still not be the 'active' log file going forward, so it still can't be opened visibly or edited normally.

I still have hope though.  There is likely still a way to navigate to that 'iLogicLog' browser pane, and simulate the right-click option to clear the log.  I'll have to do a little more testing.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 12

JoãoASilva
Advocate
Advocate

@WCrihfield  Have you found anything regarding this?

I'm looking into it right now as well...

João Silva

Mechanical Engineer

 

0 Likes
Message 9 of 12

WCrihfield
Mentor
Mentor

No.  I dabbled with clearing the DockableWindow that the logger resides within, but that removes the reference to the logger control within the DockableWindow (doesn't destroy it), instead of just clearing its contents.  You then have to restart Inventor, which will automatically re-associate the logger control to its DockableWindow, to get its usual functionality back.  (The tab remains, but the control is lost, temporarily.)   I haven't found the 'correct' way to clear the iLogic Log using an iLogic rule.  They simply don't have that Method exposed within the API yet.  Here is the link to the 2021 online help page for the IRuleLogger Interface.  It only has Methods exposed for writing to the log, but nothing for clearing it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 10 of 12

JoãoASilva
Advocate
Advocate

This logger feature is around since 2018-2019, right?

Hopefully it won't follow the Inventor revision cloud idea and will be added a way to clear the logger.

 

It just seems like such a easy thing to do, and yet none come to fruition...

João Silva

Mechanical Engineer

 

0 Likes
Message 11 of 12

Michele_DeLucaSW7PJ
Contributor
Contributor

up

0 Likes
Message 12 of 12

WCrihfield
Mentor
Mentor

Hi @Michele_DeLucaSW7PJ.  No progress here, as far as I can recall.  The first code example I showed above, where it attempts to get the text file, then write an empty String over its current contents ,still fails with the same type of error, and likely for the same reasons.  Below is another code example, just for reference, where I 'blink' the DockableWindow that the iLogic Log resides in, but that just turns its visibility on/off, and the logger contents remain afterwards, so this does not work either.

Dim iLogicLogDWindow As Inventor.DockableWindow = ThisApplication.UserInterfaceManager.DockableWindows.Item("ilogic.logwindow")
iLogicLogDWindow.Visible = False
iLogicLogDWindow.Visible = True

Doing that does not require restarting Inventor, but doing DockableWindow.Clear, which I mentioned in an earlier reply, will require you to restart Inventor, and may still not clear the contents of the logger window.  However, there is a setting iLogicVb.Automation.LogControl.AutoDelete that, when set to True (its default value), it will clear the iLogic Log when you quit Inventor.  But I know no one hear wants to have to restart Inventor to clear this log.  The lack of a way to clear this log by iLogic rule code may be 'by design' though.

 

Below is a link to an 'Idea' topic within the Inventor Ideas forum, where a simple command for clearing this log is being asked for.  You can vote for it to make it more popular, to let Autodesk know that we want this ability in newer versions of Inventor / iLogic.

https://forums.autodesk.com/t5/inventor-ideas/create-a-simple-command-for-clearing-the-ilogic-log/id... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes