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