sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Selection !

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 241 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.
    • mtripleM Offline
      mtriple
      last edited by

      im new in dev, im working on my first plugin.

      i want to select 2 lines in way that when the method is called, u can only select lines
      also u dont have free selection (u can select by clicking only - one by one entity )
      because i need to retrieve the axis of the click to determine which endpoint or startpoint is closer to the axis click.

      i tried to do this on ruby console, but i got no success.
      Sketchup.active_model.selection.each
      but when i used "Sketchup.active_model.selection.clear" after i selected a line, it does work .

      i need guide plz , i couldnt get much from this :
      http://www.sketchup.com/intl/en/developer/docs/ourdoc/selection

      compospray workin 2014

      1 Reply Last reply Reply Quote 0
      • A Offline
        Aerilius
        last edited by

        The simplest way is to allow the user to select any entities. Just care only about those selected entities that are edges:
        edges = Sketchup.active_model.selection.grep(Sketchup::Edge)
        Let's say you now need to be sure there is a minimum of edges:
        return UI.messagebox("You need to select two or more edges.") if edges.length < 2

        The cleanest way would be to implement your own tool class for selecting entities. You would use a PickHelper to get whatever is below the point that the user clicked, and only if it is an edge you would add it to an array or selection (actually you do not really need to add it to the real selection), and then draw/highlight what is selected.
        Don't do this until you have enough experience.

        If something does not work, please give complete (and minimal!) examples and say what does not work. All I could say about Sketchup.active_model.selection.each is that it raises an error because it is an iterator method with missing block ("each" is not "edge").

        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