Grabbing the 3dsmax viewport with python

posted in: Blog | 0

Not the best way, but I wasn’t able to get it running with the FPValue conversion, when I tried to use BitmapInfo.SetName(filename) it just crashed, so I’ll dig into that later on. An alternative would have also just copy pixel by pixel the bitmap returned by FPValue into a new bitmap… but that wouldn’t be that efficient.

Long story short, for now this works fine:

import MaxPlus

def grabviewporttofile(filename):
    command = MaxPlus.Core_EvalMAXScript('''grab = gw.GetViewportDIB()
    grab.filename = @"''' + filename + '''"
    save grab
    close grab''')
    return True

if __name__ == '__main__':
    grabviewporttofile(r'c:test.jpg')

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.