Save Component Definitions in an older SU version

components
saveas

#1

I want to save Components (with the save_as method) in the same way you can do it for Sketchup models with a second parameter for the Version.
Has anybody an idea how to do this?


#2

Save the current SKP.
Do the defn.save_as(path)
It’s a current version SKP.
Then open the new file [path] and use the save command and change its version there.


Then you need to tidy up.
Remove the backup SKB / ~.SKP [MAC].
Close the changed SKP.
Reopen the original SKP.


#3

Thanks TIG for your answer. It is a solution in some situations.
But in this case i am creating the components from a large model, and sometimes 50 or more in row.
I am wondering why Sketchup::ComponentDefinition.save_as() has no parameter for Version…?!
Based on your answer i will make a specific script that converts all the stored components at the end of de creating process, So then there is no need to reopen the original large SKP model every time.
Thanks a lot!


#4

Yes, it’ll be easier to save all the model’s definitions out individually into a subfolder, as the current version, then batch process the subfolder’s SKPs into another earlier version…
https://sketchucation.com/pluginstore?pln=TIG_save_all_components
I already been involved in something to do this.
There’s probably something there to help you…
http://sketchucation.com/forums/viewtopic.php?p=619136#p619136
http://sketchucation.com/forums/download/file.php?id=147153


#5

Are you targeting a specific older version of SketchUp?

If so, then you could save the entire model as a previous version, then load that file using the older version of SketchUp, and finally have a simple script to save out all the Components to disk.


#6

Hi Jim, i needed a solution to a older version i dont use.
With the directions of TIG i find a fine solution.

This way:

# Method: convert_component_definitions()
def self.convert_component_definitions(folder, new_version=false)
  new_version = new_version || Sketchup::Model::VERSION_2016
  # Store active model
  active_file = Sketchup.active_model.path
  # Loop trough all the files in folder and convert the .skp files
  Dir.foreach(folder) {|file|
    next if [".", ".."].include?(file) 
    next if !file.downcase.index(".skp")
    Sketchup.open_file(file)
    Sketchup.active_model.save(file, new_version)
    file_backup = file[0, file.size-4]+".skb"
    # Delete created backup file
    if File.exist?(file_backup)
      File.delete(file_backup)
    end
  }
  # Re-open Original model or New one
  if !active_file.empty?
    Sketchup.open_file(active_file)
  else
    Sketchup.file_new()
  end
end

#7

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.