[Plugin] Save Copy As Previous Version

[Plugin] Save Copy As Previous Version

Postby Jim » Thu Dec 16, 2010 1:41 pm

Update 2014-05-18 - Version 2.0

Saves a copy of a model at the selected SketchUp version (3 thru latest.) Also has basic template with date, time, model name, and version macros.

This version is compatible with SketchUp 2014 or later, Windows or Mac (untested on Mac.)

Plugin adds "[jf] Save Copy As ..." item to the File menu.


Formats

You can set a default format for the saved filename:

2014-05_36.png


Format codes include (case sensitive):

Code: Select all
Date:
  %Y - Year
  %m - Month
  %d - Day

Time:
  %H - Hour
  %M - Minute
  %S - Second

SketchUp:
  %model - current model name
  %version - Selected version to save as


Example Format:
A format of:
%model_v%version_%Y-%m-%d
Might yield a filename of:
MyHouse_v8_2014-05-18.skp

2014-05_37.png


Download version 2.0

save-copy-as-2.0-jf.rb





original post below


This is a Windows-only plugin.

What: Save the model as the previous version.

How: Uses a VBScript to automate the process of selecting the File/Save As menu, and select the option to save the model using the previous version. The plugin writes a small script to the Windows TEMP folder, then executes it using UI.openURL().

The final confirmation dialog is left for the user to handle.

Where: Download and place the file in your Plugins folder.

Download jf_save_as_prev_version.rb
4
Hi

Jim 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Pixero » Thu Dec 16, 2010 3:17 pm

Thanks!
0
User avatar
Pixero 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby putnik » Wed Feb 09, 2011 8:32 am

Thanks Jim, this should be very useful, except:
1. I Save As.. -> choose Sketchup 7
2. modify file
3. File -> Save Previous
4. Try to close, SketchUp asks me if I want to save before closing. (clearly not saving with Save Previous)

What am I doing wrong?
0

putnik 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby bharvey » Tue Nov 08, 2011 4:55 pm

Jim,
First off, thanks for the plugin!!
Is there a way to remove the "final confirmation dialogue"?
Dialogue Capture.JPG
0

bharvey 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Jim » Wed Nov 09, 2011 10:01 am

Hi Brandon,

Yes, just add a 'y' to the end of the string, like this:

"%fa%ts{Enter}y"

(The string represents the keys that are pressed.)
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Lily Rose » Thu Dec 29, 2011 7:00 pm

Great stuff! Thank you so much for the plugin!
0

Lily Rose 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Arc » Fri Aug 30, 2013 2:30 am

in sketchup 2013, this plugin always save as same file - s.skp, why?
0
User avatar
Arc 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby TIG » Fri Aug 30, 2013 11:16 am

Arc wrote:in sketchup 2013, this plugin always save as same file - s.skp, why?
It uses WshShell to mimic keypresses.
The version currently available from the link has this line
script += %[WshShell.SendKeys "%fa%ts{Enter}"]
Which will do that - the 's' is its name !

BUT these lines can replace that line and it then works, keeping the name unchanged !

script += "WshShell.SendKeys(\"+(^s)\")\n"
script += "WScript.Sleep(500)\n"
script += "WshShell.SendKeys(\"{TAB}{DOWN}{DOWN}{ENTER}{ENTER}y\")"

[NOTE: you will need to have Ctrl+Shift+S set as your shortcut to 'Save_As']

So you need to compare the 'down' key presses needed to save as the desired 'earlier version' - this goes one step back - so v2013 becomes v8 - adjust the key codes as desired ...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Ken » Sat Aug 31, 2013 5:35 pm

TIG wrote:
Arc wrote:in sketchup 2013, this plugin always save as same file - s.skp, why?
It uses WshShell to mimic keypresses.
The version currently available from the link has this line
script += %[WshShell.SendKeys "%fa%ts{Enter}"]
Which will do that - the 's' is its name !

BUT these lines can replace that line and it then works, keeping the name unchanged !

script += "WshShell.SendKeys(\"+(^s)\")\n"
script += "WScript.Sleep(500)\n"
script += "WshShell.SendKeys(\"{TAB}{DOWN}{DOWN}{ENTER}{ENTER}y\")"

[NOTE: you will need to have Ctrl+Shift+S set as your shortcut to 'Save_As']

So you need to compare the 'down' key presses needed to save as the desired 'earlier version' - this goes one step back - so v2013 becomes v8 - adjust the key codes as desired ...


TIG

This works great for my boss as he still has V8. However, I was wondering if there is a way to add some text following the original file name, i.e. "orig_file_name+my_boss_name + V8". This way I can save as and would have a file named as "Habitat Jack V8.skp", and I could send this file to him and still have the original V13 file "Habitat.skp" for me to work on.

Thanks in advance.

Ken
0
Fight like your the third monkey on Noah's Ark gangway.
User avatar
Ken 
Premium Member
Premium Member
 

Re: [Plugin] Save As Previous Version (Windows)

Postby TIG » Sun Sep 01, 2013 12:25 pm

Remove the whole block of code starting from [and up to and including the 'end']
unless File.exists?(script_file)
....
end

Add in these lines instead
script = "Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n"
script += "WshShell.SendKeys(\"+(%s)\")\n"
script += "WScript.Sleep(500)\n"
script += "WshShell.SendKeys(\"{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}_v8{TAB}{DOWN}{DOWN}{ENTER}{ENTER}y\")\n"
script += "WScript.Sleep(1000)\n"
script += "WshShell.SendKeys(\" \")\n"
script += "Set WshShell = Nothing\n"


To match the new key-strokes you must add a new shortcut key-combo Shift+Alt+S to activate the File menu's 'Save A Copy As' - so then it then saves a v8 COPY but leaves the original v2018 SKP still open. You can mess around with that combo in the second line, + = Shift, % = Alt and ^ = Ctrl, and 's' = S key, note how the second modifier key must to be with the 'letter' key inside the () e.g. +(%s) ...

Now the v2013 'Habitat.skp' gets saved as 'Habitat_v8.skp' ...
Change '_v8' to 'JACK_V8' or whatever you like...
The BACKSPACE keystroke is there to remove the auto-added '1' on the end of the SKP name when SketchUp makes a Copy name.

The ' ' space is to invoke the Select tool after the Copy is made, because the 'y' needed to overwrite an existing Copy [if any] could otherwise invoke whatever tool you have set to shortcut Y ?
The final 'Nothing' part is to ensure that the process stops.
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Ken » Sun Sep 01, 2013 8:52 pm

TIG

Thanks you for your help. I can't seem to get it to work. Here is what I copied into the plugin, with one line above and one line below what I copied into the file. Also changed short cut key to shift + alt + S. The save a copy file menu does show up.

"jf_save_as_prev_version.vbs") # this line above
script = "Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n"
script += "WshShell.SendKeys(\"+(%s)\")\n"
script += "WScript.Sleep(500)\n"
script += "WshShell.SendKeys(\"{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}Jack_v8{TAB}{DOWN}{DOWN}{ENTER}{ENTER}y\")\n"
script += "WScript.Sleep(1000)\n"
script += "WshShell.SendKeys(\" \")\n"
script += "Set WshShell = Nothing\n"
UI.openURL("file:///"+script_file)
end # this line below.

I added "Jack_v8". Right now it saves a copy, one number above the last copy, but does not add the "Jack_v8" or change the version #.

Again thank you for your help. I know you are busy. So I will just plug along.

Ken
0
Fight like your the third monkey on Noah's Ark gangway.
User avatar
Ken 
Premium Member
Premium Member
 

Re: [Plugin] Save As Previous Version (Windows)

Postby TIG » Mon Sep 02, 2013 9:39 am

Here's the FULL code - replaces everything below the top # lines
Code: Select all
module JF
  def self.save_as_previous_version()
    title = Sketchup.active_model.title
    if title == ""
      UI.messagebox("Model must be saved before it can be saved as the previous version.", MB_OK, 1)
      return
    end
    Dir.chdir(File.dirname(Sketchup.active_model.path))
    script_file = File.join(ENV["TEMP"], "jf_save_as_prev_version.vbs")
    script  = "Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n"
    script += "WshShell.SendKeys(\"+(%s)\")\n"
    script += "WScript.Sleep(500)\n"
    script += "WshShell.SendKeys(\"{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}_v8{TAB}{DOWN}{DOWN}{ENTER}{ENTER}y\")\n"
    script += "WScript.Sleep(1000)\n"
    script += "WshShell.SendKeys(\" \")\n"
    script += "Set WshShell = Nothing\n"
    begin;File.delete(script_file);rescue;end
    File.open(script_file, "w"){|f| f.puts(script) }
    UI.openURL("file:///"+script_file)
  end
end
UI.menu("File").add_item("Save_As Previous Version") { JF.save_as_previous_version() }
PC only, and change '_v8' to '_Jack_v8' as desired...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Ken » Mon Sep 02, 2013 2:06 pm

TIG

Works great. This plugin will save my boss from the "white screen of death" he gets when I send the models forgetting to save in V8.

Thank you for your time and knowledge.

Ken
0
Fight like your the third monkey on Noah's Ark gangway.
User avatar
Ken 
Premium Member
Premium Member
 

Re: [Plugin] Save As Previous Version (Windows)

Postby mirale999 » Sun Jan 19, 2014 9:38 am

Fantastic plugin! Since I begin using the 2013 version, I,m always annoyed with this same thing.
But I find that if I have mcafee in my system, the .vbs in the TEMP folder will be blocked, is there a safe folder can be used for the vbs, such as the sketchup folder? That will be better~
0
paranoia is a higher form of awareness...

mirale999 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby TIG » Sun Jan 19, 2014 2:38 pm

You'll have limited permissions to any folders within the Programs Files tree too !
So Macafee blocking is likely there too...
[ You should have reset the SketchUp Plugins folder to have FULL read/write, BUT even then Macafee might block ! ]
The user's TEMP folder should have FULL permissions by default.
If Macafee blocks it, then isn't it easier to teach it to allow it !
There are several tools doing things like this [like the SketchUcation Archive Installer for ZIP files or when using custom-plugins folders to AutoINstall...] so you'll have continuing problems unless you put your foot down.
Don't let your virus-app dictate to you - show it who's boss... ;)
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby sstuchfield » Wed Apr 09, 2014 11:01 am

Hi Jim,

I can't seem to find a download link to this plugin anywhere... Is it still available?

Sandy
0

sstuchfield 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby unclex » Fri Apr 11, 2014 4:14 am

could it always save as one version, such as 13 or 8 @2014?
like a switch, could be fixed
0

unclex 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Jim » Fri Apr 11, 2014 8:04 am

sstuchfield wrote:Hi Jim,

I can't seem to find a download link to this plugin anywhere... Is it still available?

Sandy


I took it down to work on it, but looks like I never got it re-posted.

unclex wrote:could it always save as one version, such as 13 or 8 @2014?
like a switch, could be fixed


My current version uses a sub-menu to list all available back versions - so you could set a shortcut key to your preferred version. I may also add an option to set the default version.

I will update in the next few days.
4
Hi

Jim 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby JQL » Fri Apr 11, 2014 9:44 am

Really useful!
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Jim » Sat Apr 19, 2014 1:12 pm

I think the name "Save As Previous" does not accurately convey my original purpose of this plugin. Rather than "Save", I think "Export As Version" would be more accurate. Exporting implies the desire to keep the original file unchanged while creating a new file at the selected SU version. Perhaps the new file would have a version hint in in the file name.

So the workflow is:

1. Editing a model named "Jones_Residence" in the most recent version of SketchUp.
2. Ready to send changes to person or application that can only use SU version 8 files.
3. Activate shortcut to "Export model as Version 8."
4. A new model is exported as "Jones_Residence_su8" in the same folder as original. Original model is unmodified both in SketchUp and on disc.
5. Send v8 file.
6. Repeat.

Sound about right?
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Ken » Sat Apr 19, 2014 5:11 pm

Jim

Is there anyway to add the date, or a version #, such as, ??????_SU8_03_12_14 or ??????SU8_V_01?

That would prevent writing over the file.

Ken
0
Fight like your the third monkey on Noah's Ark gangway.
User avatar
Ken 
Premium Member
Premium Member
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Jim » Sun Apr 20, 2014 12:42 pm

Ken wrote:s there anyway to add the date, or a version #,


Yes, I will make the format customizable.
1
Hi

Jim 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby sstuchfield » Mon May 12, 2014 4:47 pm

Hi Jim,

Do you have an estimate of when you will be able to repost it?

Cheers,
Sandy
0

sstuchfield 
 

Re: [Plugin] Save As Previous Version (Windows)

Postby Jim » Wed May 14, 2014 12:50 am

Thanks for the reminder. With SU being a hobby for me and not something i do for a living, I tend to spend time on things that interest me at the moment. I will get this plugin updated this weekend.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Save As Previous Version (Windows)

Postby sstuchfield » Thu May 15, 2014 5:21 pm

Awesome, Thanks
0

sstuchfield 
 

Re: [Plugin] Save As Previous Version

Postby Jim » Sun May 18, 2014 2:46 pm

Updated, see first post.
1
Hi

Jim 
Global Moderator
 

Re: [Plugin] Save As Previous Version

Postby stagelight » Mon Jun 09, 2014 12:09 am

Great plugin !! Thank you.
0

stagelight 
 

Re: [Plugin] Save Copy As Previous Version

Postby dirtypr » Thu Dec 04, 2014 2:37 pm

This is wonderful!! thanks!
0

dirtypr 
 

Re: [Plugin] Save Copy As Previous Version

Postby rv1974 » Mon Dec 15, 2014 10:09 am

Would it be possible to make the 'silent' version of this script:
1. no confirmation windows
2. no additions to the file name
3. background autosave as prev. version
?
This script would help to solve the problem of crashing windows explorer (v.2015) and open skp files in other applications (Xnview renders skp thumbnails (up to v.2013) and 3ds Max\Lumion open only older skp versions).

Thanks.
0

rv1974 
 

Re: [Plugin] Save Copy As Previous Version

Postby stagelight » Fri Jan 02, 2015 2:10 am

Maybe this is new for 2015? But this code, will save as version 7, no confirmation needed. Just run in the ruby console...
model = Sketchup.active_model
status = model.save("", Sketchup::Model::VERSION_7)
1

stagelight 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: No registered users and 19 guests

Visit our sponsors: