• Login
sketchucation logo sketchucation
  • Login
🤑 30% Off | Artisan 2 on sale until April 30th Buy Now

Getting model to fix itself

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 563 Views
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.
  • A Offline
    Al Hart
    last edited by 26 Dec 2007, 22:52

    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.com/images/e/ef/Render_plus_colored30x30%29.PNG
    IRender nXt from Render Plus

    1 Reply Last reply Reply Quote 0
    • G Offline
      Gaieus
      last edited by 26 Dec 2007, 22:52

      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
      • A Offline
        Al Hart
        last edited by 26 Dec 2007, 22:53

        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.com/images/e/ef/Render_plus_colored30x30%29.PNG
        IRender nXt from Render Plus

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

        Advertisement