Save as with screen shot

 From:  Michael Gibson
6249.2 In reply to 6249.1 
Hi Shayne, so if I understand right what's happening is you're saving to an "external" (meaning other than 3DM) file type during the Save As.

The issue with that, is that when you save to a non-3DM file format, the current file name does not get changed. That's because many things that MoI has in it like background images, etc... are only saved when it's going into a 3DM file, so only 3DM files set the current file name which is then used later on when you do a plain "Save" (instead of "Save As").

So what you'll want to do is not read the file name by doing this: var filename = moi.geometryDatabase.currentFileName;

Instead you'll want your script to pop up the file dialog box itself so that it can get the filename being saved to and work with it directly rather than trying to retrieve it from .currentFileName

Something like this (note this isn't tested, let me know if it does not work):

code:
    // config: norepeat

    var filename = moi.geometryDatabase.getSaveFileName();

    if ( filename != '' )
    {
        moi.geometryDatabase.saveAs( filename );

        var img = moi.view.screenshot( 'viewpanel', false );
        img.save( filename.substring(0,filename.length-3) + 'jpg' );
     }



Anyway the main thing there is that it gets the filename by calling moi.geometryDatabase.getSaveFileName(); - that will pop up the file save dialog and return back the filename that was picked, you can then pass that on to saveAs and also use it for the image save as well.

- Michael