Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

3dsmaxbatch.exe Outputing text to console from python script

3dsmaxbatch.exe Outputing text to console from python script

8m0005
Explorer Explorer
786 Views
8 Replies
Message 1 of 9

3dsmaxbatch.exe Outputing text to console from python script

8m0005
Explorer
Explorer

I'm using 3dsmaxbatch.exe to run a python script:

3dsmaxbatch.exe script.py -mxsString string1:"InputPath" -mxsString string2:"OutputPath" -listenerlog Logfile.log

 

I see that 3dsmaxbatch.exe outputs some progress to the console window, and similar gets logged into the Logfile.log

Logfile.log also gets all the Print statements from the python script. 

 

Is it possible to output these print statements to the console window also, not just the log file?

 

 

0 Likes
787 Views
8 Replies
Replies (8)
Message 2 of 9

klvnk
Collaborator
Collaborator

have you tried sys.stderr in your print ? I've no idea if it works just a thought.

 

print("Hello World", file=sys.stderr)
0 Likes
Message 3 of 9

8m0005
Explorer
Explorer

That actually worked....in a way. Good beginning... 

print("Hello World", file=sys.stderr)

prints to the output, but because it is stderr, when the task is done it also tells me that it finished with errors

2/16/2023 15:55:07 PM;  Initializing Python version: 3.9.7
2/16/2023 15:55:26 PM;    ****************TEST***************
2/16/2023 15:55:26 PM;
2/16/2023 15:55:27 PM;  Task Completed with Error(s) - see above

It would be nice if it didnt give me the "Errors present" message unless there are actual errors. 

 

If I use sys.stdout I still don't see anything....

 

 

0 Likes
Message 4 of 9

klvnk
Collaborator
Collaborator

have a look at logging perhaps ?

import logging 

logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')
0 Likes
Message 5 of 9

8m0005
Explorer
Explorer

I've tried using logging, and that does output the log message to the console, but it also prepends the log level name and root to the line:

logging.info('This is an info message')

INFO:root:This is an info message

 

and you still get the error message: 

Task Completed with Error(s) - see above
0 Likes
Message 6 of 9

klvnk
Collaborator
Collaborator

could try....

 

logging.basicConfig(format='%(message)s', level=logging.INFO)

 

0 Likes
Message 7 of 9

8m0005
Explorer
Explorer
I actually fixed the INFO:root: output with logging.basicConfig(format='%(message)s')

But I still get the error message.... and it seems that the logging does not respect the '\n' character. It might be using stderr in the background.
0 Likes
Message 8 of 9

klvnk
Collaborator
Collaborator

another way maybe to use win32gui and write your text directly to the window ?

 

0 Likes
Message 9 of 9

8m0005
Explorer
Explorer
Hm....That might conflict with whatever 3DS is doing to stdout. I believe it is somehow redirecting it.
0 Likes