Save a Snapshot (different way)

Next
 From:  scott (SSHWARTS)
7397.1 
I'd like to be able to save a snapshot of my work as a 3dm file. While incremental save is great, I want to continue to work on the file I started with and not the incremental file. So in this way I can just throw off a copy of the file before I do something "destructive" to my model that I might not be able to undo.

So I'd want to write a script without UI that does the following:

-Select All
-Export as 3dm file with the file name being base_filename+time (or instead of time could be an increment)

It should be a pretty easy script, I just can't find in other examples how to specify the params to export.

Can someone point me in the right direction?

Scott
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7397.2 In reply to 7397.1 
Hi Scott, try the following put into a shortcut key:

script: /* save snapsnot to .3dm file */ var name = moi.geometryDatabase.currentFileName; if ( !name ) { moi.ui.alert( 'filename not set' ); } else { name = name.substr(0,name.length-4); var date = new Date(); name += (date.getMonth()+1) + '_' + date.getDate() + '_' + date.getFullYear() + '_' + date.getTime() + '.3dm'; moi.geometryDatabase.selectAll(); moi.geometryDatabase.fileExport( name ); moi.geometryDatabase.deselectAll(); }


One thing to look out for is you can't have a colon : character in a filename so don't try to format the date like that in the filename, that won't work.

moi.geometryDatabase.fileExport() also takes a second optional paramter for options but it's for controlling meshing options for export to a mesh format, not anything for .3dm format export.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  scott (SSHWARTS)
7397.3 In reply to 7397.2 
Thanks Michael!
Should it start with:

moi.geometryDatabase.selectAll();

Scott
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7397.4 In reply to 7397.3 
Hi Scott,

> Thanks Michael!
> Should it start with:
>
> moi.geometryDatabase.selectAll();

You can put that at the start if you like - but the above script already does that just right before the call to moi.geometryDatabase.fileExport(), I've highlighted it here:

script: /* save snapsnot to .3dm file */ var name = moi.geometryDatabase.currentFileName; if ( !name ) { moi.ui.alert( 'filename not set' ); } else { name = name.substr(0,name.length-4); var date = new Date(); name += (date.getMonth()+1) + '_' + date.getDate() + '_' + date.getFullYear() + '_' + date.getTime() + '.3dm'; moi.geometryDatabase.selectAll(); moi.geometryDatabase.fileExport( name ); moi.geometryDatabase.deselectAll(); }

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  scott (SSHWARTS)
7397.5 In reply to 7397.4 
Oh! Didn't see it for some reason. Thanks this works great.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All