sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Face.position_material SketchUp 2014 regression

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 529 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      Marginal
      last edited by

      Here's a weird one.

      Under SketchUp 2014.0.4900 a (caught) exception generated by a call to Face.position_material appears to cause SketchUp to unwind everything back to the last Model.start_operation. It's as if SketchUp is internally calling Model.abort_operation (but no ModelObserver.onTransactionAbort is generated).

      Example code:

      Sketchup.active_model.start_operation('Do stuff', true)
      entities = Sketchup.active_model.active_entities
      f1 = entities.add_face([[0,0,1.m], [10.m,0,1.m], [0,10.m,1.m]])
      f2 = entities.add_face([[10.m,10.m,1.m], [10.m,0,1.m], [0,10.m,1.m]])
      material = Sketchup.active_model.materials.add("MyMaterial")
      material.texture = "/path/to/some/texture/on/your/disk.png"
      begin
        f1.position_material(material, [[0,0,0],[0,0,1], [0,10.m,1.m],[0,0,1], [10.m,0,1.m],[0,0,1]], true)  # bogus texture layout
      rescue ArgumentError => e
        p "Oops #{e.inspect}"
      end
      f2.position_material(material, [[10.m,10.m,1.m],[1,1,1], [10.m,0,1.m],[1,0,1], [0,10.m,1.m],[0,1,1]], true)
      Sketchup.active_model.commit_operation
      

      Under SketchUp 8 & 2013 this creates two triangles, the second of which is textured. The console says:

      "Oops #<ArgumentError; Could not compute valid matrix from points>"
      

      Under SketchUp 2014, no triangles are created and the console says:

      "Oops #<ArgumentError; Could not compute valid matrix from points>"
      Error; #<TypeError; reference to deleted Face
      

      It's as if the operation was aborted - the material and Face f1 have been deleted.

      Weirdly, if I remove the start_operation and commit_operation calls the code behaves correctly (but naturally clutters up the Undo stack).

      Has anyone seen anything like this before, and can anyone suggest a workaround?

      (I could perhaps convert the faces to be textured into a PolygonMesh, use PolygonMesh.set_uv, and convert back again. But this implies deleting and re-creating the Faces which seems ugly).

      1 Reply Last reply Reply Quote 0
      • tt_suT Offline
        tt_su
        last edited by

        Hmmm... I can reproduce what you describe... Hang on.

        1 Reply Last reply Reply Quote 0
        • tt_suT Offline
          tt_su
          last edited by

          Yup! That's a regression in SU2014. An abort was added - with the intent that if the method failed it'd revert any changes it'd made so far. But the side-effect here appeared to be that it reverts the whole of the current operation - not just the current Ruby API method.
          I'm logging this bug internally.

          1 Reply Last reply Reply Quote 0
          • M Offline
            Marginal
            last edited by

            @tt_su said:

            I'm logging this bug internally.
            Thanks.

            1 Reply Last reply Reply Quote 0
            • M Offline
              Marginal
              last edited by

              Fixed in 14.1.1282. Thanks.

              1 Reply Last reply Reply Quote 0
              • tt_suT Offline
                tt_su
                last edited by

                Thanks for reporting! πŸ˜„

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement