Skip to content

Commit

Permalink
Change to "versionless"
Browse files Browse the repository at this point in the history
From SU 2021, SketchUp uses the same file format version across application versions. This program should now be able to open and convert files made in all new SU versions (until the format changes again).
  • Loading branch information
Eneroth3 committed Aug 4, 2022
1 parent 8eb3d68 commit 52a2d9d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
9 changes: 7 additions & 2 deletions cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ int main(int argc, char* argv[]) {
const char* target = argv[2];
int version_name = std::stoi(argv[3]);

// With version 2021 SketchUp changed to a "versionless" file format, meaning later application versions uses the same file version.
if (version_name > 21)
version_name = 21;

// REVIEW: Must be a way to simply append number to "SUModelVersion_SU" string
// and get enum from its string name.
const std::unordered_map<int, SUModelVersion> versions = {
Expand All @@ -32,14 +36,15 @@ int main(int argc, char* argv[]) {
{19,SUModelVersion_SU2019},
{20,SUModelVersion_SU2020},
{21,SUModelVersion_SU2021}
// When adding new version here, also update HIGHEST_SUPPORTED_SU_VERSION in open_newer.rb.
// 2021 is the first "versionless" file version, also used by later SU versions.
};
enum SUModelVersion version = versions.at(version_name);

SUInitialize();

SUModelRef model = SU_INVALID;
SUResult res = SUModelCreateFromFile(&model, source);
SUModelLoadStatus status;
SUResult res = SUModelCreateFromFileWithStatus(&model, source, &status);
if (res != SU_ERROR_NONE) return 1;
SUModelSaveToFileWithVersion(model, target, version);

Expand Down
Binary file modified src/ene_open_newer_version/bin/ConvertVersion.exe
Binary file not shown.
11 changes: 0 additions & 11 deletions src/ene_open_newer_version/open_newer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ module OpenNewer
# Major version of the running SketchUp.
SU_VERSION = Sketchup.version.to_i

# Newest major SketchUp version file format currently supported.
# Update this along with recompiling binary with the new SDK.
HIGHEST_SUPPORTED_SU_VERSION = 21

# Get SketchUp version string of a saved file.
#
# @param path [String]
Expand Down Expand Up @@ -120,13 +116,6 @@ def self.open_newer_version
Sketchup.open_file(source)
return
end
if version > HIGHEST_SUPPORTED_SU_VERSION
msg =
"This version of #{EXTENSION.name} does not support "\
"SketchUp 20#{version} files."
UI.messagebox(msg)
return
end
target = prompt_target_path(source) || return
convert_and_open(source, target)

Expand Down

1 comment on commit 52a2d9d

@eusoubrasileiro
Copy link

@eusoubrasileiro eusoubrasileiro commented on 52a2d9d Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's awesome! Just wanted to thank you somewhere. I am using this now 2023 October on my old pc version. Thank you so much!!!

Please sign in to comment.