sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Getting model to fix itself

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 563 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.
    • Al HartA Offline
      Al Hart
      last edited by

      About a year ago I had a problem where a model would "re glue" its components when it did a save. I discovered something I called to get the model to check, update, validate (or something) itself after I performed an operation - such as moving a component - so it would reglue things.

      I remember posting the problem and the solution on the SketchUp ruby forum, but that forum is gone now and I cannot find it.

      Can anyone remember what operation you pass in Ruby to get SketchUp to repair the model after an edit

      and/or

      does anyone know if the ruby forum posts are archived anywhere>

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • GaieusG Offline
        Gaieus
        last edited by

        Al,

        Some 30 pages of the ruby forums have been transferred to the new, Google Pro Groups:
        http://groups.google.com/group/Ruby-API/topics

        It seems there's something wrong with the GGroups software (or just the board settings) there for on the index page it looks as if it were empty.

        The internal links haven't been fixed (transferred) though so they does not work.

        Gai...

        1 Reply Last reply Reply Quote 0
        • Al HartA Offline
          Al Hart
          last edited by

          Thanks Gai. I searched there and could not find what I was looking for. But it is good to know that it is there.

          I remembered what we had to do (finally).

          If, during execution of ruby, you change the model, (even just adding an attribute), then all smoothing normals are lost. They get restored when the ruby exits. But you cannot use them -- for instance when exporting faces from Ruby -- unless you let the ruby routine (and any routines which called it), exit first.

          We get around this by altering the drawing, and then executing the next function with a 0 length timer. This causes the second function to get executed after the first function completes.

          This code will not work because the normals do not get recalculated.

          
          def do_export
              Sketchup.active_model.active_entities.set_attribute("t1","t2","t3")
              export_data # calls another ruby to export faces and normals
              # normals are not recalculated properly after the model was changed...
          end#def
          
          def export_data
              #export the data
          end#def
          
          

          This code, which sets the attribute and then uses a time to execute "export_data", will work properly.

          
          def do_export
              Sketchup.active_model.active_entities.set_attribute("t1","t2","t3")
              # use time to run second routine after model cleanup
              UI.start_timer(0, false) {UI.stop_timer(id); export_data}
          end#def
          
          def export_data
              #export the data
          end#def
          
          

          I seem to remember that there is some command you can issue to get SketchUp to clean up or repair the model, but I can't remember what it is. If anyone remembers, let me know! 😄

          Al Hart

          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
          IRender nXt from Render Plus

          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