Viz Artist : Script to generate Logs

Published 2 months ago, has comments


Dim filename As String = Scene.Name
Dim path As String = "C:\\LogPATH1\\"
Dim path2 As String = "D:\\LogPATH2\\"
DIM dt AS DateTime
Dim filepath As String
Dim newLineData As String
Dim fileData As String
Dim myDirector As Director
Dim isLogged As Boolean = false
Dim dtString As String


Sub LogIt(path As String)
    filepath = path & filename & "_" &  GetCurrentTime().Month & "." & GetCurrentTime().Year & ".csv"

    fileData = ""
	System.LoadTextFile(filepath, fileData)
	
	if fileData == "" then
		System.SaveTextFile(filepath, "timestamp,name" )
		System.LoadTextFile(filepath, fileData)
	end if
	
	dt = GetCurrentTime() 	
	dtString = dt.DayOfMonth & "/" & dt.Month & "/" & dt.Year & " " & dt.Hour & ":" & dt.Minute & ":" & dt.Second 
	newLineData = dtString & "," & filename
	
	System.SaveTextFile(filepath, fileData & newLineData )
End Sub


sub OnExecPerField()
	myDirector = Stage.FindDirector("Default")

	if myDirector.time > 0 and myDirector.time < 1 then
		
		if isLogged == false then
			LogIt(path)
			LogIt(path2)
		end if
				
		isLogged = true
	end if
	
	if myDirector.time == 0 or myDirector.time > 1 then
		isLogged = false
	end if
	
end sub

Note: create path folders manually

Update/ Change
"C:\\LogPATH1\\" and "D:\\LogPATH2\\"
to your desired Directory Like
"C:\\Logs\\"

You have to have a Director in Stage named 'Default' and its animation must be > 1 second

Create a Container and Drop 'Script' Plugin in it, Edit the 'Script' Copy/Paste this code in it press 'Compile & Run' Save Scene. That's it.