For the record, I am more artist than I am technical so I am still learning and open minded to my code. But basically I have a situation that I have been trying to solve for weeks.... and I am stumped like no other.
This script works in Max 2019 but does not work in Max 2020... I don't have the slightest clue, could someone help guide me?
#
#import modules
#
import MaxPlus as max
import pymxs
import os
#
#define a master folder and suffix name
#
folder = r"C:\Users\me\Desktop\test2"
convertedEndingName = "_BUILD"
# Find any .max files in the folder specified, if max exist, open, export # entire scene to fbx.
for root, dirs, files in os.walk(folder):
for item in files:
if item.endswith((".max", ".MAX")):
filePath = os.path.join(root, item)
filePath = filePath.replace('\\', '\\\\')
filePath1 = r'"' + filePath + '"'
print(filePath1)
filePathExported = filePath.replace('.max', '').replace('.MAX', '')
sm = r'loadMaxFile ' + filePath1 + ' quiet:true prompt:false useFileUnits:false'
max.Core.EvalMAXScript(sm)
filePathExported = r'"' + filePathExported + '_MAX' + convertedEndingName +'.fbx"'
print(filePathExported)
efbx = r'exportFile ' + filePathExported + '#noPrompt ' + ' selectedOnly:false'
max.Core.EvalMAXScript(efbx)
Solved! Go to Solution.
Solved by eric.brosseau. Go to Solution.
What is the error you are encountering?
Whoops, I am sorry, I got my versions mixed up, It works in Max 2020 but not 2021.
The error I am getting looks like this:
Sounds like you may have introduced an inconsistency in the white space that you use for code indentation.
Turn on "show whitespace" in your editor (in 3ds Max's editor, it's Ctrl+Shift+8, or View menu > Whitespace) and look for the problem.
Thanks! That helped me get to the real problem....
If there is no MaxPlus Module... then how do I rewrite the two functions that use MaxPlus on line
The lines I am referring to are
sm = r'loadMaxFile ' + filePath1 + ' quiet:true prompt:false useFileUnits:false'
and
efbx = r'exportFile ' + filePathExported + '#noPrompt ' + ' selectedOnly:false'
@Anonymous ,
The script already uses a MAXScript way of loading and exporting a file. You simply need to use the 'pymxs' module to achieve the same. The module is a Python wrapper over MAXScript. Your script would now read like this:
#
#import modules
#
from pymxs import runtime as mxs
import os
#
#define a master folder and suffix name
#
folder = r"C:\Users\me\Desktop\test2"
convertedEndingName = "_BUILD"
# Find any .max files in the folder specified, if max exist, open, export # entire scene to fbx.
for root, dirs, files in os.walk(folder):
for item in files:
if item.endswith((".max", ".MAX")):
filePath = os.path.join(root, item)
filePath = filePath.replace('\\', '\\\\')
print(filePath)
filePathExported = filePath.replace('.max', '').replace('.MAX', '')
mxs.loadMaxFile(filePath, quiet=True, prompt=False, useFileUnits=False)
filePathExported = filePathExported + '_MAX' + convertedEndingName + '.fbx'
print(filePathExported)
mxs.exportFile(filePathExported, mxs.Name('noPrompt'), selectedOnly=False)
You can read more on translating MAXScript to Python on this help page.
THANK YOU SO MUCH! IT WORKS!
The resources you linked are really helpful, especially seeing it used in example.. You rock for correcting this for me. Thanks again.
Can't find what you're looking for? Ask the community or share your knowledge.