How can get version of layout's file?

I can not find the function that gets the version of the layout file.

I’m afraid there is none. There isn’t even such function for SKP files.

There is for a model object, but the whole file must be loaded:

The following feature request is still open to read the version from the SKP file header for both the Ruby and C APIs:

Read SketchUp version of external file · Issue #346 · SketchUp/api-issue-tracker · GitHub

The following issues discuss how to do it with the Ruby API:

SketchUp crashes when attempting to load component made in newer version · Issue #30 · SketchUp/api-issue-tracker · GitHub

Reading GUID of external file · Issue #225 · SketchUp/api-issue-tracker · GitHub

Please open a new issue in the tracker for getting version of an external .layout file.

NOTE: I just opened an issue for reading the version from an internal LO document.

1 Like

SKP file can directly read the specified byte position to get the version. I think it’s faster

Since .layout files are zip archives. Your app (or extension) can open the archive then extract the "documentProperties.xml" file and read the "version" attribute for the <dp:generator> element.

1 Like

Thank you.

verstr = nil do |zip_file|
  zip_file.each do |entry|
    zip_file_name ='utf-8')
    next unless zip_file_name == 'documentProperties.xml'
    entry.get_input_stream.readlines.each { |line|
      verstr = line[/(\d*\.){2}\d*/] if line.strip['<ldp:version']
    } if entry.file?