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

If Toolbar is true make it false

Scheduled Pinned Locked Moved Developers' Forum
54 Posts 4 Posters 2.5k Views 4 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.
  • S Offline
    simonstaton
    last edited by 25 Jun 2010, 12:24

    I think you are right! if its working from the ruby console and its working on the toolbar and its not working on load it must be because the toolbar is false until it has loaded.

    anyway to add a delay onto the .rb file and have it only run once sketchup is fully loaded?

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 25 Jun 2010, 12:37

      UI.start_timer
      http://code.google.com/apis/sketchup/docs/ourdoc/ui.html#start_timer

      Note that you can only use whole seconds with the timer.

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

      1 Reply Last reply Reply Quote 0
      • S Offline
        simonstaton
        last edited by 25 Jun 2010, 12:49

        excellent, works like a dream thanks dude. I can now finally say SOLVED

        now I know this isnt related to my initial question however you guys know your stuff and I dont want to go making yet another topic. is there anyway to set a variable in ruby like you can in javascript.

        in my toolbar I have two tools that rely on each other, a compress tool and a checkout tool before you checkout you need to compress.

        is there anyway that only my tools even I can have it so that when you click compress it sets a variable like:
        compress = true

        and my default have compress = false then on my checkout tool have:

        if (compress = true){
        event
        }
        else {
        alert
        }

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 25 Jun 2010, 12:56

          Use
          if compress {...
          or
          if compress == true {...
          to test if compress IS true
          BUT NOT
          if compress = true {...
          Which will set compress to true and therefore always return true ?
          = sets a variable to a value
          == compares two values

          TIG

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 25 Jun 2010, 12:57

            Assuming you have wrapped your code in a module, use an instance variable: @compressed.

            http://www.techotopia.com/index.php/Understanding_Ruby_Variables
            http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Variables_and_Constants

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

            1 Reply Last reply Reply Quote 0
            • S Offline
              simonstaton
              last edited by 25 Jun 2010, 13:04

              I seem to be getting errors am I doing this right:

              @compress = "no"
              
              # EXPLODE TOOL
                   model=Sketchup.active_model
                   cmd = UI;;Command.new("Explode"){
               result = UI.messagebox "This will Compress your Climbing Frame meaning you cannot edit past this point!\n\n Would you like to continue?\n\nNote; Only Do This Once Per Model", MB_YESNO
               if result == 6 # Yes
                 model.entities.to_a.each{|e|e.explode if e.class==Sketchup;;Group or e.class==Sketchup;;ComponentInstance}
                 Morisdov.att_get
                 @compress = "yes"
               end
                   }
                   cmd.small_icon = "finished.png"
                   cmd.large_icon = "finished.png"
                   cmd.tooltip = "Compress | Compress your Climbing Frame"
                   cmd.status_bar_text = "Compressing your Climbing Frame"
                   cmd.menu_text = "Compress"
                   toolbar = toolbar.add_item cmd
                   toolbar.show
              
              # VIEW CART
                   model=Sketchup.active_model
                   cmd = UI;;Command.new("Explode"){
              	 if compress == "yes" {Morisdov.att_get}
              	 if compress == "no" {UI.messagebox("Before Viewing Your Cart Make Sure You Have Compressed Your Climbing Frame\n\nNote; You Only Need to Compress Once")}
                   }
                   cmd.small_icon = "check.png"
                   cmd.large_icon = "check.png"
                   cmd.tooltip = "View Cart | View a List of Items Used"
                   cmd.status_bar_text = "Loading Cart"
                   cmd.menu_text = "View Cart"
                   toolbar = toolbar.add_item cmd
                   toolbar.show
              

              Thanks for the help by the way guys, much appreciated

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 25 Jun 2010, 13:08

                At some point you refer to compress when it should always be @compress πŸ˜’

                TIG

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 25 Jun 2010, 13:10

                  And you are better of using true and false instead of strings "yes", "no" - strings are very slow. and "yes" and "no" both evaluates to true.

                  If you get errors then please post them. They help pinpoint specifically what is going on. "some error" is to vague to make any good guess.

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

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    simonstaton
                    last edited by 25 Jun 2010, 13:11

                    I still seem to be getting this error:

                    C;/Users/Simon/Documents/Action Design Your Own v2/Action 3D 3/Plugins/Utilities/Toolbar.rb;309; syntax error
                    	 if @compress == "yes" {Morisdov.att_get}
                    	                        ^
                    C;/Users/Simon/Documents/Action Design Your Own v2/Action 3D 3/Plugins/Utilities/Toolbar.rb;310; syntax error
                    	 if @compress == "no" {UI.messagebox("Before Viewing Your Cart Make Sure You Have Compressed Your Climbing Frame\n\nNote; You Only Need to Compress Once")}
                    	                       ^
                    C;/Users/Simon/Documents/Action Design Your Own v2/Action 3D 3/Plugins/Utilities/Toolbar.rb;310; syntax errorError Loading File LoadToolbar.rb
                    C;/Users/Simon/Documents/Action Design Your Own v2/Action 3D 3/Plugins/Utilities/Toolbar.rb;309; syntax error
                    	 if @compress == "yes" {Morisdov.att_get}
                    	                        ^
                    C;/Users/Simon/Documents/Action Design Your Own v2/Action 3D 3/Plugins/Utilities/Toolbar.rb;310; syntax error
                    	 if @compress == "no" {UI.messagebox("Before Viewing Your Cart Make Sure You Have Compressed Your Climbing Frame\n\nNote; You Only Need to Compress Once")}
                    	                       ^
                    C;/Users/Simon/Documents/Action Design Your Own v2/Action 3D 3/Plugins/Utilities/Toolbar.rb;310; syntax error
                    
                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      thomthom
                      last edited by 25 Jun 2010, 13:14

                      You're thinking Jsvascript. Your If Else syntax is wrong.
                      http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Control_Structures

                      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 25 Jun 2010, 13:15

                        Try
                        if test; action; end
                        OR
                        action if test

                        or

                        if test
                           action
                        elsif another_test
                           another_action
                        else ### anything else !
                           yet_another_action
                        end
                        

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          simonstaton
                          last edited by 25 Jun 2010, 13:17

                          haha excellent guys, it works thanks the all the help!

                          1 Reply Last reply Reply Quote 0
                          • S Offline
                            simonstaton
                            last edited by 28 Jun 2010, 08:21

                            @thomthom said:

                            UI.toolbar_names
                            http://code.google.com/apis/sketchup/docs/ourdoc/ui.html#toolbar_names

                            @unknownuser said:

                            The toolbar_names method is used to returns the name of all the available toolbars (this differs between PC and Mac).

                            > UI.toolbar_names ["Standard", "Principle", "Camera", "Drawing", "Edit", "Construction", "Walk", "DisplayMode", "StandardViews", "Section", "Google", "GettingStarted", "VCB"]

                            I dont suppose you know what the toolbar name would be for the large toolset do you?

                            Thanks,
                            Simon

                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              simonstaton
                              last edited by 28 Jun 2010, 15:18

                              I see, no worries hope they fix it soon. Thanks

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                Dan Rathbun
                                last edited by 28 Jun 2010, 17:18

                                @simonstaton said:

                                I see, no worries hope they fix it soon. Thanks

                                Updated my previous post, to give send_action integers, and info on the DC ruby toolbar.

                                I'm not here much anymore.

                                1 Reply Last reply Reply Quote 0
                                • D Offline
                                  Dan Rathbun
                                  last edited by 28 Jun 2010, 17:20

                                  @simonstaton said:

                                  I dont suppose you know what the toolbar name would be for the large toolset do you?

                                  It does NOT have a string identifer that works with UI.toolbar_names or UI.set_toolbar_visible, etc.

                                  This is a bug in the API; we have asked that it be fixed.

                                  Misspelled argument: 'Principle' for the Principal toolbar.

                                  The missing arguments: %(#000000)[**identifier]%(#F0F0F0)[____]%(#000000)[tb_ID]%(#F0F0F0)[_]%(#000000)[send_action int "LargeToolSet"]%(#F0F0F0)[_]%(#000000)[(211)]%(#F0F0F0)[__]%(#000000)[23056 "Layers"]%(#F0F0F0)[_______]%(#000000)[(220)]%(#F0F0F0)[__]%(#000000)[21132 "Shadows"]%(#F0F0F0)[______]%(#000000)[(103)]%(#F0F0F0)[__]%(#000000)[10546**]

                                  NOTE: %(#000000)[**"Dynamic Components"]%(#F0F0F0)[_]%(#000000)[(59648)]** is a ruby toolbar (not a native toolbar.)
                                  You must use UI.toolbar('Dynamic Components') with the .visible?, .restore, .hide and .show methods.

                                  I'm not here much anymore.

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

                                  Advertisement