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!
    ⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

    Select component with ruby?

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 5 Posters 1.3k Views 5 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.
    • jeff hammondJ
      jeff hammond
      last edited by

      what's the code for selecting a component by name?
      (or is there one?)

      ie- what exactly would I type into the console to select a component named "board"..

      (and I realize it may require more than one line.. in the past, I've typed multiple lines in a text editor then copy/pasted into the console.. and it works ok.. is there a better way to do that if need be?)

      gracias!

      dotdotdot

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

        Sketchup.active_model.selection.add( Sketchup.active_model.definitions['board'].instances )

        Note that this selects all instances in model - which might not be in the current context. Selections across context can make SketchUp behave oddly. Ye have been warned!

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

        1 Reply Last reply
        Reply Quote 0
        • jeff hammondJ
          jeff hammond
          last edited by

          sweet.. thanks!

          so far so good..

          dotdotdot

          1 Reply Last reply
          Reply Quote 0
          • D
            driven
            last edited by

            @unknownuser said:

            in the past, I've typed multiple lines in a text editor then copy/pasted into the console.. and it works ok.. is there a better way to do that if need be?)

            gracias!

            hi Jeff,

            did you know you can input multi-line scripts into 'Ruby Console' by using Alt/Return at the end of each typed line and then Return [on it's own] to enter/use it.
            Also once somethings been entered you can re-use those same lines by toggling the up/down arrows to go back to a previously entered snip then hit return...

            john

            learn from the mistakes of others, you may not live long enough to make them all yourself...

            1 Reply Last reply
            Reply Quote 0
            • jeff hammondJ
              jeff hammond
              last edited by

              @unknownuser said:

              did you know you can input multi-line scripts into 'Ruby Console' by using Alt/Return at the end of each typed line and then Return [on it's own] to enter/use it.
              Also once somethings been entered you can re-use those same lines by toggling the up/down arrows to go back to a previously entered snip then hit return...

              john

              tip 1 -- thank you… that's good to know.. how about a way to type a long line with some sort of character in it indicating it's a new line..

              something®like®this =

              something
              like
              this

              ?

              tip 2
              awesome. that's a good one too!

              dotdotdot

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

                @driven said:

                did you know you can input multi-line scripts into 'Ruby Console' by using Alt/Return at the end of each typed line and then Return [on it's own] to enter/use it.

                Only on OSX. Not on Windows. 😞

                @driven said:

                Also once somethings been entered you can re-use those same lines by toggling the up/down arrows to go back to a previously entered snip then hit return...

                This works on both platforms, but I think OSX is a little bit smarter. If you execute a command multiple times OSX it will merge them together onto one item in the history stack.

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

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

                  Of course adding a ' ;' into a line works as if it were a 'newline', needed in some code...
                  So puts 123;puts 456;puts 789 in the one line is like typing the commands on three separate lines in turn...

                  TIG

                  1 Reply Last reply
                  Reply Quote 0
                  • Dan RathbunD
                    Dan Rathbun
                    last edited by

                    ruby will allow spanning lines with a \ (in some cases.)

                    I'm not here much anymore.

                    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