Python Errors in 3dsmaxbatch only

Python Errors in 3dsmaxbatch only

hannesdelbeke
Enthusiast Enthusiast
5,192 Views
13 Replies
Message 1 of 14

Python Errors in 3dsmaxbatch only

hannesdelbeke
Enthusiast
Enthusiast

short version:

 

pymxs throws exceptions in 3dsmaxbatch but not in normal 3ds max mode


long version:

I need some help with a max issue
My script runs fine in both 3ds max, and 3dsmaxbatch.exe
but in the batch version it is a lot slower.
after running it in debug mode "-v 5 "

i noticed it prints a LOT of error messages, resulting in the script running a lot slower
this happens when doing normal stuff such as trying to access a material
 

import pymxs

rt = pymxs.runtime

for i in range(100):

    standClass = rt.StandardMaterial


or 

node = rt.getnodebyname("Box001")

for i in range(100):

    nodeMat = node.material

 

doing this gives me the following error in maxbatch
but no errors at all in normal max

MAXScript Evaluate MXSWrapperBase Exception: -- Unknown property: "_referencedObject"

is there a away to disable these errors being send? they originate from pymxs so i assume its a autodesk bug

0 Likes
5,193 Views
13 Replies
Replies (13)
Message 2 of 14

hannesdelbeke
Enthusiast
Enthusiast

i hacked around it by using the legacy batch
running normal 3dsmax.exe with the -batch parameter

it starts slower and i need to handle the close down myself but at least it only takes 1 min instead of 10 to run my script

 

if anyone knows how to get 3dsmaxbatch.exe working let me know
but i probably have to wait untill autodesk fixes it

0 Likes
Message 3 of 14

eric.brosseau
Autodesk
Autodesk

We are currently reviewing your question @hannesdelbeke.

 

We have done some fixes to lower the number of occurrence for those exceptions to be thrown in 3ds Max 2019. Can you confirm under which version of the software (and applied updates) you are experiencing this issue? It would help us pin-point the issue.

 

Also, the exceptions are thrown in both 3ds Max and 3ds Max Batch. You are not seeing the exception when running 3ds Max but they are log in the standard 3ds Max log file.

 

Eric Brosseau
Senior Software Developer, 3ds Max, Autodesk
Message 4 of 14

hannesdelbeke
Enthusiast
Enthusiast
I'll have a look on Monday when I'm in work.
Think i'm on 2018.4, we aren't using 2019

I tried "hiding" the exceptions by changing the verbosity level
and I managed to get maxbatch to not print it, but it still was slow
If you say these exceptions also happen in normal 3ds max, then they aren't
the reason of the slow down. So what difference is there between max and
batchmax that could cause this?

The script runs fine and only slows down the moment those errors start
appearing, so that's why I thought they were the cause.

0 Likes
Message 5 of 14

hannesdelbeke
Enthusiast
Enthusiast

The version I'm using 2018.4 Update 20.0-20.4.0.4254

0 Likes
Message 6 of 14

Anonymous
Not applicable

Same here.
The code still seems to be working mostly properly and the exceptions seem rather harmless but apparently performance takes a hit and at least on one occasion the very same pipeline, which ran just fine in normal mode, failed to run properly when simply switched to 3dsmaxbatch, which was totally unexpected and required two days to fix.
Also, the exceptions clutter the log and you get "Task Completed with Error(s)" at the end which is disconcerting.

In my case, it appears using pymxs.runtime.Name()
A simple operation such as
pymxs.runtime.move (pymxs.runtime.selection, pymxs.runtime.Point3 (1, 0, 0))
also causes the exception.

Tested in 20.4.0.4254
Does appear to work correctly in 21.0.0.845

Message 7 of 14

hannesdelbeke
Enthusiast
Enthusiast

I ran the same script trough 3dsmaxbatch.exe and 3dsmax.exe with the -batch tag
it worked successfully in both, but in 3dsmaxbatch took 207 sec, and in 3dsmax only 38 sec (this includes time to launch 3ds max)

 

the commands


"C:\Program Files\Autodesk\3ds Max 2018\3dsmax.exe" -batch -U PythonHost "C:\Projects\VuTools\site-packages\vutools\batcher\batch_fixExportScene.py" -q -mi "C:\Users\Hannes\Desktop\TQ3299\TQ2973.max" -listenerLog "C:/Users/Hannes/Documents/test.log"

"C:\Program Files\Autodesk\3ds Max 2018\3dsmaxbatch.exe" -sceneFile "C:\Users\Hannes\Desktop\TQ3299\TQ2973.max" "C:\Projects\VuTools\site-packages\vutools\batcher\batch_fixExportScene.py" -listenerLog "C:/Users/Hannes/Documents/test.log" -v 0

 

Errors


I monitored where it was slow and it turned out to be in the scale and uv checks
when it is in the scale and uv check it also happens to throwing loads of errors
whereas all the other processes do not throw any errors and therefor are near instant.


I also noticed that if i run this in normal max, it runs fast and does not throw a visible error, but it fails in a try/except loop. likely because of the hidden error in the background, that is being logged to the default max log

1342 times
MAXScript Evaluate MXSWrapperBase Exception: -- No "">"" function for [1,1,1]

 

2969 times

MAXScript Evaluate MXSWrapperBase Exception: -- Unknown property: "_referencedObject" in Uvwmap:UVW Map
MAXScript Evaluate MXSWrapperBase Exception: -- Unknown property: "_referencedObject" in Edit_Poly:Edit Poly
MAXScript Evaluate MXSWrapperBase Exception: -- No "">"" function for Edit_Poly

 

other

 

I disabled writing to the log, by going to preferences/files and unticking Errors, Warningsm Info, Debug

I confirmed the log does not update anymore, but 3dsmaxbatch is still slow

 

Our company is on a monthly license subscription, so if required I might be able to update to 2019.
But this would likely be a slow process since we need everyone on the same version in the studio.

 

currently installing the 2019 trail to test it on there

0 Likes
Message 8 of 14

Anonymous
Not applicable

I used to use 3dsmax.exe/-batch but for various reasons, I find 3dsmaxbatch.exe to be a better alternative and that's why I want this to work.
Also, I implement any data-intense processing via plugins so I don't get all that many exceptions.
Still, this thing continues to be a problem and it would be nice to see it fixed.

0 Likes
Message 9 of 14

VUCITY
Explorer
Explorer

-ignore this post-
posted from wrong account, cant seem to delete this

0 Likes
Message 10 of 14

hannesdelbeke
Enthusiast
Enthusiast

tested 2019

I tried the latest version of max 21.3.0.3250
it has improved but still slow

3dsmax 2018.4: 45 sec 
3dsmaxbatch 2018.4 150 sec 
3dsmax 2019.3: 37.5 sec 
3dsmaxbatch 2019.3 78 sec

max 2019 has less errors in the log, all material, and UV errors are gone

the Point3 scale, and edit poly error are still there.

873 times
MAXScript Evaluate MXSWrapperBase Exception: -- No "">"" function for [1,1,1]

1694 times
MAXScript Evaluate MXSWrapperBase Exception: -- No "">"" function for Edit_Poly

 

this is caused by the following code:

when it tries to check the class of the "Edit Poly" modifier
it does not trigger on the UVW modifier

for modifier in node.modifiers:
    if rt.classof(modifier) == rt.Uvwmap:
        pass



i also have the odd

MAXScript MacroScript Error Exception: -- Unknown property: "AutoDisplaySelectedLightEnabled" in undefined
MAXScript MacroScript Error Exception: -- Unknown property: "VisualStyleMode" in undefined

0 Likes
Message 11 of 14

hannesdelbeke
Enthusiast
Enthusiast

i have 873 meshes in the test scene
873 errors: No "">"" function for [1,1,1]

 

this error is caused by

if node.scale == rt.Point3(0.01,0.01,0.01):


most nodes are edit poly meshes with a "UVW Map" modifier and "editpoly" modifier
so the editpoly error triggers both on the edit poly basemesh and the edit poly modifer
873 *2 = 1746 which is near 1694 (can be explained by some meshes being a EditMesh instead of EditPoly)

the material and UV errors I had in 2018  follow the same pattern
I got them when i did 

rt.classof(modifier) == rt.Uvwmap:
if rt.classof(mat) != rt.Standardmaterial:
if rt.classof(node.material) != rt.Standardmaterial:
nodeClass = rt.classof(node)  

 

the errors are caused by pymxs classes not being compatible with compare functions
(even though it works it throws an error)

I then continued and tested if the errors slow it down. and they do!
Created a test script that just closes. Takes 20 sec to run in 3dsmaxbatch

rt.quitMAX(quiet=True)

If the messages do not slow it down, the following script should run just as fast in 3dsmaxbatch

But this script takes 47 sec to run in 3dsmaxbatch

for i in range(1000):
rt.logsystem.logEntry("test", broadcast=True)
rt.quitMAX(quiet=True, exitCode=e.exitCodes.fail_Vutools)


47-20= 27
so it takes 27 seconds to run the for loop

if i run the same script in 3dsmax it only takes 3 seconds
a slight slow down but nothing compared to 3dsmaxbatch

This proves the slow down is caused by the errors 


0 Likes
Message 12 of 14

hannesdelbeke
Enthusiast
Enthusiast

update:
2020 has fixed some of these bugs but not all of them
still getting errors in maxbatch


when doing
try:
  material.materialList
except:
  pass

expected behaviour, we use the material list if material is of type multimaterial, we get an exception if it is of type standard material. and this is handled by the try loop

what happens:
an error is written to the log in batchmode
code continues to run fine, but when running maxquit with exitcode 0, exitcode -130 is returned

error in the log:
07/11/2019 14:27:33; MAXScript Evaluate MXSWrapperBase Exception: -- Unknown property: "materialList" in Buildings:Standard

0 Likes
Message 13 of 14

hannesdelbeke
Enthusiast
Enthusiast

comparing material classes gives an error in the log
we cant compare classes, so we first need to convert to string, and then compare the string

def is_standard_material(mat):
# 3dsmaxbatcher throws exception when comparing material classes, this is a workaround
matClass = rt.classof(mat)
return str(matClass) == str(rt.Standardmaterial)

def is_multi_material(mat):
# 3dsmaxbatcher throws exception when comparing material classes, this is a workaround
matClass = rt.classof(mat)
return str(matClass) == str(rt.multimaterial)

similar issues for classes of edit poly modifier 

   # todo this slows down 3dsmaxbatch . when it compares a edit poly modifier
if rt.classof(modifier) == rt.Uvwmap:


any of these errors
only happen in batchmode
result in code still running, so no exception raised!
but error written to log, slows down processing a lot!
when we run  rt.quitMAX (quiet=True, exitCode=0), the exitcode is -130 instead

if code is in a try loop the try loop will fail, but when not in try loop, code doesnt throw exception (except in log)


there is also
MAXScript Evaluate MXSWrapperBase Exception: -- Unknown property: "__class__" in <MixinInterface:LayerProperties>"
not investigated yet which code line triggers this but this happens in the same way. only in maxbatch

0 Likes
Message 14 of 14

petrCDS7Y
Contributor
Contributor

This code takes FOREVER in 3dsmaxbatch.exe

with pymxs.animate(True):
        for point in trajectory_3dsmax:
            rt.sliderTime = point.frame_number

            pos_controller.value = point.position
            rot_controller.x_rotation = point.rotation.x
            rot_controller.y_rotation = point.rotation.y
            rot_controller.z_rotation = point.rotation.z

            camera.focal_length_mm = point.intrinsic.focal_length_mm
            camera.film_width_mm = point.intrinsic.film_width_mm
0 Likes