sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Select component with ruby?

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 5 Posters 1.1k 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 Offline
      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 Offline
        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 Offline
          jeff hammond
          last edited by

          sweet.. thanks!

          so far so good..

          dotdotdot

          1 Reply Last reply Reply Quote 0
          • D Offline
            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 Offline
              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 Offline
                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 Offline
                  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 Offline
                    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
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement