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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    How do i call subroutine in animation / onclick?

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    3 Posts 1 Posters 1.5k Views 1 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.
    • S Offline
      skyfish
      last edited by

      I have a component which rolls on a track. I have been using a formula for intersection of line-circle and line-line to change the component coords at each increment of the animation in Sketchup Pro 7. Works great.

      The formula's are in the enclosing component which holds the sub-components like wheels,track etc.

      With onclick I calculate the coords with every increment of the animation. Unfortunately I have separate intersection calculations for each sub-component and it is getting messy.

      I would like to implement something like Line_Line_intersect(ParmIN, ParmOUT) & Line_Circle_Intersect(ParmIN,ParmOUT) which I would call in my IF().. statement.

      I scanned ruby but it is not clear to me that this is possible. Surprised I couldn't find a clear answer to this anywhere.

      skyfish

      1 Reply Last reply Reply Quote 0
      • S Offline
        skyfish
        last edited by

        I restructured the code and changed the algorithm. Now I can create rolling elements by

        • copying typical component
        • make unique
        • renaming
        • change offset

        If you would like to see example, I have attached a file.

        skyfish

        EDIT:
        Oops, now I remember the problem with this algorithm. The
        distance between balls is a measure of the curved path. It
        doesn't maintain a rigid connection between balls. Going
        around the curve, the inter-distance is slightly small.


        trackroller.skp

        1 Reply Last reply Reply Quote 0
        • S Offline
          skyfish
          last edited by

          Since I am not getting any replies about subroutines, I did restructure again so that I can copy DC and make a few changes to produce a component that maintains distances.

          The example would work for a garage door ( using ASIN & ACOS for angles ).

          The calculations were adapted from

          http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/
          http://local.wasp.uwa.edu.au/~pbourke/geometry/2circle/

          There are some weird bugs in sketchup when using large numbers, in addition to the SQRT problems.

          skyfish


          trackroller II.skp

          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