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!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    How to receive the size of a line Sketchup rubi

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 1.7k 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.
    • Z Offline
      Z11
      last edited by

      ruby script draw square

      model = Sketchup.active_model    
      entities = model.entities  
      pt1 = [0.m,  0.m, 0.m]    
      pt2 = [10.m, 0.m, 0.m]
      
      pt3 = [10.m, 10.m, 0.m]
      pt4 = [0.m,  10.m, 0.m]
      new_face = entities.add_face pt1, pt2, pt3, pt4
      

      How to receive the size of a line Sketchup rubi ?


      img1.JPG

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        The len=edge.length returns the length in inches, len.to_m returns it in meters.
        In your example you know the length from the code but the len= method works for any edge...
        So face.edges.each{|e| puts e.length.to_m} would print the length of the face's edges - in your case 10m ...

        TIG

        1 Reply Last reply Reply Quote 0
        • Z Offline
          Z11
          last edited by

          I should draw simply in model a dimensional line.

          What method Sketchup to construct a dimensional line

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @z11 said:

            What method Sketchup to construct a dimensional line

            No access to dimensions via the Ruby API. 😞

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • Z Offline
              Z11
              last edited by

              @thomthom said:

              @z11 said:

              What method Sketchup to construct a dimensional line

              No access to dimensions via the Ruby API. 😞

              Thanks for the answer.
              It is a pity.
              😞

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                You CAN sort of fudge it... make a separate SKP file containing a dimension 1" long and 1" offset.
                Then in code load it as a component into your SKP.
                Add an instance at a point and scale it in the X to match the length to another point and in the Y for the offset needed.
                You also need to transform-rotate it so that it aligns with the vector of the two points etc...
                When done you can explode the dim-component instance back into a plain dimension.
                An dims added this way will ever be linked to an edge or vertex as in a manually added one...
                You could perhaps include a 1" long edge in the dim-component that the dim refers to... and if that then replaced the original line below it when exploded it might keep some linking ?
                It's better than nothing... but only just... πŸ˜’

                TIG

                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