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!
    FredoBend | Powerful new bending tool for SketchUp Download

    New translate request?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 192 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.
    • T Offline
      tomot
      last edited by

      I believe Didier devised this brilliant bit of code, I have been using it mainly because the new point it creates are not static and works in any 3d orientation.

      # creates a new point from p1 in the direction of p2-p3 with length d
          # params are Point3d, 2 vertices, a length, returns a Point3d
          def translate(p1, p2, p3, d)
              v = p3 - p2
              v.length = d
              trans = Geom;;Transformation.translation(v)
              return p1.transform(trans)
          end
      

      I'm not skilled enough in Ruby to develop a similar new bit of code. So I'm hoping someone here can help me. I would like this new bit of code help me find a point p3? given the "dotted" distance which lies outside and inline with p1 and p2 The attached pic. illustrates what the current code does, and what I'm requesting.

      Tia!


      translate.jpg

      my plugins
      tomot

      1 Reply Last reply Reply Quote 0
      • fredo6F Offline
        fredo6
        last edited by

        @tomot said:

        So I'm hoping someone here can help me. I would like this new bit of code help me find a point p3? given the "dotted" distance which lies outside and inline with p1 and p2 The attached pic. illustrates what the current code does, and what I'm requesting.

        Tia!

        Assuming the dotted distance is < dd> and you name p3? by p4, just use

        p4 = p2.offset p3.vector_to(p2), dd
        

        The line oriented vector is p3.vector_to(p2), and you just offset p2 by the distance dd.

        Fredo

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

          @unknownuser said:

          Assuming the dotted distance is < dd> and you name p3? by p4, just use

          p4 = p2.offset p3.vector_to(p2), dd
          

          The line oriented vector is p3.vector_to(p2), and you just offset p2 by the distance dd.
          Fredo

          Thanks Fredo6: I see my use of English has failed me again 😳 My p3? would actually become the new location of p3 similar to the original code starting with a new name to distinguish it it for other code snippets hence the first line would start something like this

          def translate_extend(p1, p2, p3, d)
          

          followed by the technical stuff, and so I can reuse it again in other places where required in any other script.

          my plugins
          tomot

          1 Reply Last reply Reply Quote 0
          • fredo6F Offline
            fredo6
            last edited by

            Then use

            p3 = p2.offset p2.vector_to(p1), d
            

            This gives the point p3, which at distance d of P2 in the direction of p1

            Fredo

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better πŸ’—

            Register Login
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement