sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [HowTo] update view to make animation

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 327 Views 3 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
      MarcioAB
      last edited by

      Hello - Happy 2009 for all of us.

      I'm just finishing a new version of a script (JointSU) but I can not show the "animation" of an instance in SU. I need help to find how to update the View for each step in a loop. For example, consider the code below:

      
      transf=Geom;;Transformation.rotation(pt,vector,angle)
      for i in 1..10
       instance.transform!(transf)
       sleep(1)
      end
      
      

      When I run this code, I just see the instance in the initial position, 10 seconds of nothing and the instance in the final position and not each intermediary steps.
      In a trial and error basis, I tried Sketchup.active_model.active_view.invalidate, Sketchup.active_model.active_view.show_frame, Sketchup.active_model.active_view.draw but no luck.

      Any help is much welcome.
      Regards
      Marcio

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by

        All you need should be to invalidate the view inside your loop, as long as you have a Tool class. Post a small, complete, failing example.

        Todd

        1 Reply Last reply Reply Quote 0
        • MALAISEM Offline
          MALAISE
          last edited by

          Hello MarcioAB

          Best wishes for 2009
          Your script sounds promiser, let's know us your improvements 😄.

          MALAISE

          La Connaissance n'a de valeur que partagée

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

            @unknownuser said:

            All you need should be to invalidate the view inside your loop, as long as you have a Tool class. Post a small, complete, failing example.
            Todd

            This is the code I was expecting to work:

            
            def callA
              joint=JointSU.new # see explanation below
              Sketchup.active_model.select_tool(ViewSpinner2.new(joint))
            end
            
            class ViewSpinner2
            def initialize(j)
              @jointSU=j
              r=@jointSU.getParentComponents
              @c=r[2]
              t2=r[0].transformation
              @t=Geom;;Transformation.rotation(t2.origin,t2.xaxis,-PI/45.0)
              for i in 1..10
               @c.transform!(@t)
               Sketchup.active_model.active_view.invalidate
               sleep(0.1)
              end
            end
            end # Class
            
            

            No error message. I see the @c instance in the first position and than in the last position. I do not see the intermediary positions.

            Obs: JointSU is now a (long) class (I will post it later today), but for this discussion, the method "getParentComponents" provide data to allow establish a point and an axis for the @t rotation transformation.

            On the meantime I just found this code in the examples and it works:

            
            def callB
              joint=JointSU.new
              Sketchup.active_model.active_view.animation = ViewSpinner.new(joint)
            end
            
            class ViewSpinner
            def initialize(j)
              @jointSU=j
              r=@jointSU.getParentComponents
              @c=r[2]
              t2=r[0].transformation
              @t=Geom;;Transformation.rotation(t2.origin,t2.xaxis,-PI/45.0)
            end
            
            def nextFrame(view)
              @c.transform!(@t)
              view.show_frame
              true
            end
            end # Class
            
            

            But I still prefer the first one - if it worked (must be missing something I can not see ...)

            Thanks
            Marcio

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

              @malaise said:

              Hello MarcioAB

              Best wishes for 2009
              Your script sounds promiser, let's know us your improvements 😄.

              MALAISE

              Welcome. I'm having fun with this. I will post it later today.
              I need to include some animation of the bike based on it's joint-enabled-components.
              ... and some documentation.

              1 Reply Last reply Reply Quote 0
              • T Offline
                todd burch
                last edited by

                Sorry, if I'm going to debug this, I require a complete, small, failing example. I'm not going to try to reverse engineer your snippets.

                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