Files from 2020 appear radically different in 2023

I am opening some old files from 2020. They open, but objects have moved around and have lost their scale. Can anybody help?

Now using Pro Version 23.0.396 on a Mac M1. Ventura 13.3.1(a)

Should look like this:

Now looks like this in 2023:

There was a scale issue fixed in 2023, where components that had a strange scaling issue would look very strange. The fix for that seems to have shown up cases where a component had the scaling issue already, but it wasn’t noticeable in 2022.

Try right-click on one of the components and choose to reset the scale. See how big or small it gets.

Thanks, but I tried that. All the objects are already reset to their original scale. I guess the problem is that 2023 is not reading the scaling I did to the pieces in 2020.

Also, please note that the position has changed, too, not just the scale.

Can I take a look at the model?

Hexagons.skp (3.4 MB)

It isn’t like other problems I’ve seen. I created a bug report so that a developer will look into the problem.

Exploding and regrouping each group (in an older version of Sketchup) will fix the transformation matrices so that they work correctly in 2023. I’ll see if I can conjure up a Ruby program to automate this repair for you.

Hexagon redux.skp (3.6 MB)

2 Likes

That is so nice of you! A script would be super helpful because there are so many groups.

Before investing the time, let’s ask @colin if this problem is likely to be resolved in an upcoming update.

The problem itself seems to stem from the fact that the 16th element of the transformation matrix does not have a value of 1.0. Which, normally, shouldn’t be an issue but for some reason in this instance we are getting really strange results.

Do you happen to remember if this file was imported from some other software or was this totally created with Sketchup?

Not imported, It was totally made in SU. Lots of imported graphics used as textures, though.

Here’s the scoop.

In older versions of Sketchup the location of the origin of a group was calculated from the values in the transformation as:

x = m12 / m15
y = m13 / m15
z = m14 / m15
(m15 being the value at the lower right; ~1.15 )

For example here is a group located at [10, 10, 10] and its associated transformation matrix.

Now in the 2023 version of Sketchup the value of m15 is ignored which places the group at [11.49, 11.49, 11.49]

And the model used for this exposé.

Hexagons element 15 error.skp (3.2 MB)

Ignoring the ‘scaling value’ in m15 also causes the size of the entities in the group to be in error.

2 Likes

Some Ruby code for you!!!

Open a faulty model
Open the Ruby Console
Copy the following code
Paste the code into the Ruby console and press enter
Save the model with a new filename

***Note: I tested this code in the older version of Sketchup not in the 2023 version

module SW
  module M15fix
    def self.rescale(obj)
      obj.make_unique if obj.is_a? Sketchup::Group
      p obj
      m = obj.transformation.to_a
      x = m[12] / m[15]
      y = m[13] / m[15]
      z = m[14] / m[15]
      m15 = m[15]
      scale = 1.0 / m15
      if m15 != 1.0
        # reset m15 to 1.0
        tr = Geom::Transformation.scaling( [x, y, z], m15 )
        obj.transform!(tr)
        
        # rescale entities
        ents = entities(obj)
        tr = Geom::Transformation.scaling( ORIGIN, scale )
        ents.transform_entities(tr, ents.to_a)
      end
    end

    def self.entities(obj)
      obj.is_a?( Sketchup::Group ) ? obj.entities : obj.definition.entities
    end
    
    def self.recurse(ents)
      ents.each { | obj |
        if [Sketchup::Group, Sketchup::ComponentInstance].include? obj.class
          rescale(obj)
          recurse(entities(obj))
        end
      }

    end

    model = Sketchup.active_model
    ents = model.active_entities
    model.start_operation('m15 Repair')
      recurse(ents)
    model.commit_operation
   puts 'm15 repair completed'
  end # M15fix  
end # SW
nil

Should I do this script in the old version or the 2023 version?
I’m guessing the old one…OK, I just saw your last note.

I’ll give it a go.

I tried it, and not surprisingly you run the script in an older SketchUp, then the new saved file will look right in 2023.

The developers have looked at sWilliams’ notes, and the issue is one that was known might occur, but that we didn’t have an example model to show the issue. Your model and his notes will help them to see what needs fixing.

4 Likes

@colin, I’m glad that this helped.

AnsenSeale, the code I posted above had some nasty side effects that would appear in a more complicated scenario. Here’s a better solution (I hope).

module SW
  module M15fix
    def self.rescale(obj)
        m = obj.transformation.to_a
      if m[15] != 1.0        
        p obj
        [ 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13,14].each { | i | m[i] = m[i] / m[15] }
        m[15] = 1.0
        tr = Geom::Transformation.new(m)
        obj.transformation = tr
      end
    end
    
    # Search through the entites and rescale any group or component were the matrix element 15 is not 1.0
    #
    def self.recurse(ents)
      ents.each { | obj |
        if [Sketchup::Group, Sketchup::ComponentInstance].include? obj.class
          rescale(obj)
          recurse(obj.is_a?( Sketchup::Group ) ? obj.entities : obj.definition.entities)
        end
      }
    end

    model = Sketchup.active_model
    ents = model.active_entities
    model.start_operation('m15 Repair')
      recurse(ents)
    model.commit_operation
    puts 'm15 repair completed'
  end # M15fix  
end # SW
nil

Edited: removed an undocumented method call ( obj.transformation = Array )

3 Likes

Hooray! Your script worked! I can now edit my old files in SU2023.

Many thanks!

http://ansenseale.com

1 Like

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