• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Select component with ruby?

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 5 Posters 1.1k Views
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.
  • J Offline
    jeff hammond
    last edited by 10 Apr 2012, 17:23

    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
    • T Offline
      thomthom
      last edited by 10 Apr 2012, 18:39

      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
      • J Offline
        jeff hammond
        last edited by 10 Apr 2012, 20:03

        sweet.. thanks!

        so far so good..

        dotdotdot

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by 10 Apr 2012, 23:38

          @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
          • J Offline
            jeff hammond
            last edited by 11 Apr 2012, 03:08

            @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
            • T Offline
              thomthom
              last edited by 11 Apr 2012, 08:05

              @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
              • T Offline
                TIG Moderator
                last edited by 11 Apr 2012, 09:14

                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
                • D Offline
                  Dan Rathbun
                  last edited by 11 Apr 2012, 10:49

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

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  1 / 1
                  • First post
                    1/8
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement