sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Selection start/end detection

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 170 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.
    • Y Offline
      YamaArashi
      last edited by

      Hello Ruby noob alert πŸ˜„

      I manually draw a line with the pencil tool and select it. If I then have a script with the code below the variable selection contains my line,I know because the clear deselects my line on the screen. My question is how do i get the start and end points of the selected line? I have been reading the google api site, but tbh the code examples are very fragmentry and putting stuff together is hard.

      
      model = Sketchup.active_model
      selection = model.selection
      selection.clear
      
      
      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        I made this mistake just yesterday (with def), but end is a Ruby keyword and not such a good name for a variable.

        Hi

        1 Reply Last reply Reply Quote 0
        • C Offline
          cjthompson
          last edited by

          @jim said:

          I made this mistake just yesterday (with def), but end is a Ruby keyword and not such a good name for a variable.

          😳

          1 Reply Last reply Reply Quote 0
          • C Offline
            cjthompson
            last edited by

            A "Selection" is a collection of entities (lines, faces, etc.)
            In order to get the line, you have to get the first object in the Selection, since you only have one thing selected:
            line = selection[0]

            Then, once you have the line, you can get the start and end vertices like this:
            vtxStart = line.start vtxEnd = line.end

            To get the positions of the vertices, just type either: startPosition = vtxStart.position or endPosition = vtxEnd.position

            Hopefully this is clear enough to get you started.

            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