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

    ICON MF_ENABLED, MF_CHECKED

    Scheduled Pinned Locked Moved Developers' Forum
    37 Posts 5 Posters 3.7k 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.
    • TNTDAVIDT Offline
      TNTDAVID
      last edited by

      Hello everybody. ☀

      I want to create an icon linked to another icon.
      If I enable "Icon A", "Icon B" is automatically désativé, and it must be the same in the other direction.

      To be as clear as possible, here is the example GIF:

      http://i.imgur.com/Q3gE9pf.gif

      Thank you in advance for your help.

      David

      [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

        You issue is one of convoluted logic...
        You need both buttons to be enabled as the toolbar first opens.
        The two commands need setting up in your module as enduring references - e.g. @cmdA and @cmdB...
        When the user clicks on @cmdA a specified method runs [ let's call it self.cmdA() set up in the @cmdA=UI.command.new('cmdA'){self.cmdA()) section of your code ] immediately @cmdB is disabled [ @cmdB.set_validation_proc{MF_GRAYED} ] and some actions then take place, on their completion / cancellation @cmdB is ALWAYS re-enabled [ @cmdB.set_validation_proc{MF_ENABLED} ] - otherwise you would never again be able to click on it, without a restart !
        The converse is true for using @cmdB and disabling @cmdA temporarily...

        TIG

        1 Reply Last reply Reply Quote 0
        • TNTDAVIDT Offline
          TNTDAVID
          last edited by

          Please, Can you show me a complete sample code, with all these elements:

          ` def self.cmdA

          end

          def self.cmdB

          end`

          the creation of the command:

          @cmdA=UI.command.new('cmdA'){self.cmdA()) @cmdB=UI.command.new('cmdB'){self.cmdB())

          and also the validation:

          @cmdA.set_validation_proc{MF_ENABLED} @cmdB.set_validation_proc{MF_GRAYED}

          You can take into account these objectives:

          "CMDA" disables "CMDB" / "CMDB" off "CMDA".

          Thank you in advance for your help. 😉

          David

          [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

            module ...
            ### set up menu/toolbar with commands [@cmdA and @cmdB] which run the methods [cmdA() and cmdB()] etc...
            ###
            def self.cmdA()
              ### disable the @cmdB command for the duration of the process...
              @cmdB.set_validation_proc{MF_GRAYED}
              ###
              ### do some code here, why else has the user click the button ???
              ###
              ### note IF the user cancels you MUST re-enable @cmdB command
              ### perhaps do some more code here...
              ###
              ### finally the process completes, so enable @cmdB command anyway.
              @cmdB.set_validation_proc{MF_ENABLED}
            end
            ###
              ### repeat for def self.cmbB() ... end
              ### but swapping cmdB for cmdA and vice versa...
            ###
            end#module
            

            TIG

            1 Reply Last reply Reply Quote 0
            • TNTDAVIDT Offline
              TNTDAVID
              last edited by

              Hello,

              Your method seems much more simple and logical, that my research. 👍

              This is a very good thing, but I can not make it work. 😕

              Here is part of my code:

              
              
                    def self.panel #method called by the command17, which must temporarily disable the command 18.
                    command18.set_validation_proc{MF_GRAYED}
                    methode00
                    panelmove
                    $dc_observers.get_latest_class.close_configure_dialog 
                    Sketchup.active_model.select_tool(DCInteractTool.new($dc_observers))
                    model = Sketchup.active_model 
                    layers = model.layers 
                    new_layer = layers.add "Click-Window 3D"
                    new_layer.visible = true
              
                    sang = Sketchup.active_model  
                    sang_definition = sang.definitions
                    sang_def = sang_definition['Control Panel']
              	  
                    sang_def.set_attribute 'dynamic_attributes','a0000mode', '1'
                    sang_def.set_attribute 'dynamic_attributes','_a0000mode_label', 'a0000mode'
                    sang_def.set_attribute 'dynamic_attributes','_a0000mode_units', 'STRING'
                    sang_def.set_attribute 'dynamic_attributes','_a0000mode_access', 'TEXTBOX'
              	  
                    $dc_observers.get_latest_class.redraw_with_undo(sang_def)
              	  
                    command18.set_validation_proc{MF_ENABLED}
                    end
              
                    
                    ########
              
              
                    command18 = UI;;Command.new("Opens Settings SketchUp"){ CW_Pro_mm.options }
              
                    command18.small_icon = File.join(@@path_to_resources,"add_18.png")
              
                    command18.large_icon = File.join(@@path_to_resources,"add_18.png")
              
                    command18.tooltip = %Q(Opens Settings SketchUp)
              
                    command18.status_bar_text = %Q(Opens Settings SketchUp)
              
                    command18.menu_text = %Q(Opens Settings SketchUp)
              	  
                    cc_menu.add_item(command18)
              
                    tb.add_item(command18)
              

              When I click on my icon, nothing happens because " command18.set_validation_proc{MF_GRAYED}" does not work.

              Or is my mistake?

              What does the "@" is it essential?

              Thank you

              [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

              1 Reply Last reply Reply Quote 0
              • fredo6F Offline
                fredo6
                last edited by

                @TNTDAVID

                Just put an instance variable between the brace, say @status_icon1.
                command18.set_validation_proc { @status_icon }

                Depending on your context, your script will change the variable between the values MF_ENABLED, MF_GRAYED or MF_ENABLED.

                This is a proc, so it is called by Sketchup and expect a return value to set the state of the icon. It is called almost continuously (you can check that by the statement command18.set_validation_proc { puts "icon proc" ; MF_GRAYED }.

                This is just State programming (as opposed to Event programming).

                Fredo

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

                  Note that the validation proc is bugged for toolbars on Mac. They don't update right. In my extensions I ended up not using validation procs for commands used for toolbars - but still use them for menus.

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

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

                    @TNTDAVID

                    You have failed to appreciate that you need an instance variable @ to make it become available within a related module's methods [aka def]
                    I explained the difference of the variable types at some length, last week...

                    If you suddenly "out-of-the-blue" refer to something called command18, then that method will NOT understand what you mean by it.
                    BUT if you had set it up earlier, within the module, as @command18=... then it would also be visible within the nested method...

                    Also, please stop using confusing terminology !
                    sang = Sketchup.active_model
                    Why ??
                    The sang is component in an old default template.
                    Use model= or mod= etc
                    Using 'ang' in a name hints that it might be an angle !

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • TNTDAVIDT Offline
                      TNTDAVID
                      last edited by

                      Wow I am very pleased to see the Great Masters of ruby ready to help me. 😍

                      I discovered the ruby, so thank you for your extreme indulgence.

                      I added the "@", but it's always the same problem.

                      Here is the updated code:

                      def self.panel #method called by the command17, which must temporarily disable the command 18.
                            command18.set_validation_proc{@MF_GRAYED}
                            methode00
                            panelmove
                            $dc_observers.get_latest_class.close_configure_dialog 
                            Sketchup.active_model.select_tool(DCInteractTool.new($dc_observers))
                            model = Sketchup.active_model 
                            layers = model.layers 
                            new_layer = layers.add "Click-Window 3D"
                            new_layer.visible = true
                      
                            model = Sketchup.active_model  
                            model_definition = model.definitions
                            model_def = model_definition['Control Panel']
                           
                            model_def.set_attribute 'dynamic_attributes','a0000mode', '1'
                            model_def.set_attribute 'dynamic_attributes','_a0000mode_label', 'a0000mode'
                            model_def.set_attribute 'dynamic_attributes','_a0000mode_units', 'STRING'
                            model_def.set_attribute 'dynamic_attributes','_a0000mode_access', 'TEXTBOX'
                           
                            $dc_observers.get_latest_class.redraw_with_undo(model_def)
                      	  
                            command18.set_validation_proc{@MF_ENABLED}
                            end
                      
                            ###########
                      
                            command18 = UI;;Command.new("Opens Settings SketchUp"){ CW_Pro_mm.options }
                      
                            command18.small_icon = File.join(@@path_to_resources,"add_18.png")
                      
                            command18.large_icon = File.join(@@path_to_resources,"add_18.png")
                      
                            command18.tooltip = %Q(Opens Settings SketchUp)
                      
                            command18.status_bar_text = %Q(Opens Settings SketchUp)
                      
                            command18.menu_text = %Q(Opens Settings SketchUp)
                           
                            cc_menu.add_item(command18)
                      
                            tb.add_item(command18)
                      
                      

                      What is my mistake?

                      Thank you

                      [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                        Please indent your coe consistently and helpfully...
                        You have NOT added the @ !
                        None of your commands have a @ prefix.
                        If this is all of your code it's also wrong in other ways.
                        The various @ references need a commond 'parent' module, so they can be seen by the methods...
                        It all needs to be inside your own module[s].
                        The commands are set up as the code loads.
                        These should have @ names so that the methods can also access them.
                        Here is an outline - I have already given you something like this earlier in the week...
                        Do NOT following the exact naming etc just understand how the parts work, and apply them to your own needs...

                        module TNTDAVID
                          module ClickWindow
                            ### set up commands
                            @commandA = UI.command.new('CmdA'){self.cmdA()}
                            ### add icons, tooltips etc
                            @commandB = UI.command.new('CmdB'){self.cmdB()}
                            ### add icons, tooltips etc
                            ### add it's toolbar
                            ### add the buttons to toolbar to run the commands
                            ### etc
                            ### the methods run by the commands...
                            ###
                            def self.cmdA() ### the code run by commandA
                              ### do stuff here, that can then 'see' the @commandA and @commandB
                              ### which are instance variable references to the two commands !
                              ### disable @commandB
                              ### do some processing...
                              ### if the user jumps out of processing before the end ensure that @commandB is re-enabled
                              ###
                              ### at the end re-enable @commandB
                            end#method
                            ### you say you want vice vers affects from the two toolbar buttons !
                            def self.cmdB() ### the code run by commandB
                              ### do stuff here, that can then 'see' the @commandA and @commandB
                              ### which are instance variable references to the two commands !
                              ### disable @commandA 
                              ### do some processing...
                              ### if the user jumps out of processing before the end ensure that @commandA is re-enabled
                              ###
                              ### at the end re-enable @commandA 
                            end#method
                          end#module
                        end#module
                        

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • TNTDAVIDT Offline
                          TNTDAVID
                          last edited by

                          @tig said:

                          o NOT following the exact naming etc just understand how the parts work, and apply them to your own needs...

                          I understand your logic in your example!

                          If I miss is the formulation of the code ....

                          **module TNTDAVID
                          module ClickWindow
                          ### set up commands OK
                          @commandA = UI.command.new('CmdA'){self.cmdA()}

                          ### add icons, tooltips etc %(#FF0000)[OK]
                          
                          @commandB = UI.command.new('CmdB'){self.cmdB()}
                          
                          ### add icons, tooltips etc %(#FF0000)[OK]
                          
                          ### add it's toolbar %(#FF0000)[OK]
                          
                          ### add the buttons to toolbar to run the commands %(#FF0000)[OK]
                          ### etc
                          ### the methods run by the commands... %(#FF0000)[OK]
                          ###
                          
                          def self.cmdA() ### the code run by commandA %(#FF0000)[OK]
                          
                            ### do stuff here, that can then 'see' the @commandA and @commandB %(#FF0000)[OK]
                          
                            ### which are instance variable references to the two commands ! %(#BF0000)[OK]
                          
                            ### disable @commandB %(#FF0040)[**1.how?**
                          

                          @cmdB.set_validation_proc{MF_GRAYED}

                          The code does not work, even if I add an "@", between maybe curly braces.]

                            ### do some processing... %(#FF0000)[OK]
                          
                            ### if the user jumps out of processing before the end ensure that @commandB is re-enabled 
                          

                          2.How should write the code?

                            ### at the end re-enable @commandB **%(#FF0000)[3.how?]**
                          
                          end#method
                          
                          ### you say you want vice vers affects from the two toolbar buttons !** %(#FF0000)[OK]
                          

                          I think I expressed myself badly, is you do not have can understand my goals. 😕

                          "cmdA" is "GRAYED" by défeaut which is (mode1), even when you start SketchUp.

                          It remains "GRAYED" all the TIME! unless the user clicks on the icon "CMDB" to enter in the (mode2).

                          Under this condition, the icon "cmdB" becomes "GRAYED" is "cmdA" becomes "ENABLED".

                          ---cmdA- cmdB

                          http://i.imgur.com/WakoRGT.gif

                          4.I think your example, does not have the same objectives?

                          Thank you

                          David

                          [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                            Reread what you wrote...
                            @cmdB
                            is a method NOT a command, so try
                            @commandB.set_validation_proc{MF_GRAYED}

                            In Ruby there is the:
                            begin ... #a rescue ... #b ensure ... #c end
                            function

                            After you disable @commandB then you ought to do all of your remaining processing within the ' begin......end' - starting at #a

                            If these is a possibility that the user stops the process part way through, then you need to somehow spot it and then re-enable @commandB - that depends on your own code...

                            If it fails with an error - it invokes 'rescue' at #b - so then you also need to re-enable @commandB in that part.

                            The safety-net is the 'ensure' at #c - then you also need to re-enable @commandB in that part as well.

                            For further confidence I'd also add a re-enable for @commandB after the end of the begin......end - although I think it'll survive without it [obviously I haven't tested any of the is !]

                            NB: The re-enable code is:
                            @commandB.set_validation_proc{MF_ENABLED}

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • TNTDAVIDT Offline
                              TNTDAVID
                              last edited by

                              TIG, I just write code that conforms to your example:

                              module TesteCube
                              
                                module ClickWindow
                                
                                  @@path_to_resources = File.join(File.dirname(__FILE__), 'Resources')
                                
                                  if !file_loaded?(__FILE__)
                              	
                                  su_menu = UI.menu("Plugins")
                                  cc_menu = su_menu.add_submenu(%Q(TesteCube))
                                  tb = UI;;Toolbar.new(%Q(TesteCube))
                              
                                  @commandA = UI;;Command.new("mode1"){ ClickWindow.cmdA()}
                                  @commandA.small_icon = File.join(@@path_to_resources,"add_A.png")
                                  @commandA.large_icon = File.join(@@path_to_resources,"add_A.png")
                                  @commandA.tooltip = %Q(Opens Settings SketchUp)
                                  @commandA.status_bar_text = %Q(Opens Settings SketchUp)
                                  @commandA.menu_text = %Q(Opens Settings SketchUp)
                                  cc_menu.add_item(commandA)
                                  tb.add_item(commandA)
                              	
                                  @commandB = UI;;Command.new("mode1"){ ClickWindow.cmdB()}
                                  @commandB.small_icon = File.join(@@path_to_resources,"add_B.png")
                                  @commandB.large_icon = File.join(@@path_to_resources,"add_B.png")
                                  @commandB.tooltip = %Q(Opens Settings SketchUp)
                                  @commandB.status_bar_text = %Q(Opens Settings SketchUp)
                                  @commandB.menu_text = %Q(Opens Settings SketchUp)
                                  cc_menu.add_item(commandB)
                                  tb.add_item(commandB)
                              	
                                  tb.restore
                                  file_loaded(__FILE__) 
                                  end
                              	
                                  def self.cmdA() 
                                  model = Sketchup.active_model  
                                  model_definition = model.definitions
                                  model_def = model_definition['Box']
                                   
                                  model_def.set_attribute 'dynamic_attributes','mode', '1'
                                  model_def.set_attribute 'dynamic_attributes','_mode_label', 'mode'
                                  model_def.set_attribute 'dynamic_attributes','_mode_units', 'STRING'
                                  model_def.set_attribute 'dynamic_attributes','_mode_access', 'TEXTBOX'
                              	
                                  @commandA.set_validation_proc{MF_GRAYED}
                                  @commandB.set_validation_proc{MF_DISABLED}
                                  end
                              	
                                  ### you say you want vice vers affects from the two toolbar buttons ! ?????
                              	
                                  def self.cmdB() 
                                  model = Sketchup.active_model  
                                  model_definition = model.definitions
                                  model_def = model_definition['Box']
                                   
                                  model_def.set_attribute 'dynamic_attributes','mode', '2'
                                  model_def.set_attribute 'dynamic_attributes','_mode_label', 'mode'
                                  model_def.set_attribute 'dynamic_attributes','_mode_units', 'STRING'
                                  model_def.set_attribute 'dynamic_attributes','_mode_access', 'TEXTBOX'
                              	
                                  @commandB.set_validation_proc{MF_GRAYED}
                                  @commandA.set_validation_proc{MF_DISABLED}
                              	
                                  end
                              
                                end
                                 
                              end
                              

                              Error message:

                              @unknownuser said:

                              Error: #<NameError: undefined local variable or method `commandA' for TesteCube::ClickWindow:Module>

                              There is a problem with "@" because without it, there is no error.

                              Or are my mistakes?

                              Thank you

                              [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

                              1 Reply Last reply Reply Quote 0
                              • K Offline
                                kaas
                                last edited by

                                Just looking at the error: Error: #<NameError: undefined local variable or methodcommandA'`
                                My guess would be you forgot to add the @ in these lines. If you don't add it, the commandA is not initialized/set.


                                command.jpg

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

                                  As @kaas succinctly says...

                                  Your code is full of typos or un-corrected errors. 😕
                                  Please proofread more closely [see below]...

                                  Also learn to read the error messages - where the reference or the line is given in the error-message in the Ruby Console...

                                  If you have Notepad++ and still can't locate the erroneous line, then you could select a variable's name and use 'find' to 'mark' all matching strings in your code.
                                  Any strings with a similar, BUT not exactly-matching, name can be found using a 'find' etc...

                                  This is an issue of attention to detail and care, rather than understanding how the code might work...
                                  5/10 😮

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • TNTDAVIDT Offline
                                    TNTDAVID
                                    last edited by

                                    Thanks you kaas for your advices.

                                    I added the "@", and there is always the same error message.

                                    @tig said:

                                    Your code is full of typos or un-corrected errors.

                                    Or are errors frape TIG?

                                    That surprises me because the code works without any error message if there is no longer the @. 😮

                                    To my typos, you refer to your examples:

                                    @tig said:

                                    @cmdA=UI.command.new('cmdA'){self.cmdA())

                                    I had to correct like this:

                                    @commandA = UI::Command.new("cmdA"){ ClickWindow.cmdA()}

                                    If not, there was a lot of error messages for a single line.

                                    Thank you to tell me that I have errors in my code, I would be happier if you show me. 😉

                                    Thank you

                                    David

                                    [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                                      OK, gloves off... 😕

                                      You do not seem to be able to understand OR to appreciate good advice...
                                      Many of us had offered tips, which you then ignore - often annoyingly !
                                      ...

                                      In the example code you posted, you use 'commandA' and 'cmdA' with no thought as to what they refer to !!!
                                      One is a 'command' and the other is a 'method' resulting from that command...

                                      So as it is this will certainly fail.

                                      Please learn how to inspect your code, for at least some semblance of order, and correct it...


                                      The rest of us have other lives to lead and work to do - please try to help us to help you................

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • TNTDAVIDT Offline
                                        TNTDAVID
                                        last edited by

                                        @tig said:

                                        OK, gloves off...

                                        You do not seem to be able to understand OR to appreciate good advice...
                                        Many of us had offered tips, which you then ignore - often annoyingly !

                                        Of course I'm taking your advice and I'm doing my best to move forward.

                                        I voluntarily writing new code, to follow your example, so it is not fair to say things like that. 😮

                                        @tig said:

                                        In the example code you posted, you use 'commandA' and 'cmdA' with no thought as to what they refer to !!!
                                        One is a 'command' and the other is a 'method' resulting from that command...

                                        I did the same thing on your example, "cmdA" is a method of command is "commandeA".

                                        So I do not understand or you see a problem?

                                        Perhaps if you do a simple copy / paste my code with your corrections, it would be much simpler and effective?
                                        It's allow myself to understand my mistakes very quickly.

                                        [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                                          Sorry I got overwrought. 😳
                                          But you can be very frustrating...

                                          def self.cmdA() is the method that is run by the command @commandA

                                          The reason you make it an instance variable with the @ is that the method should see the reference to the command, without it it will not.

                                          As @kaas highlighted in yellow boxes you [correctly] set up @commandA and later on make a reference to commandA which will not work !
                                          You also make the same error for @commandB...

                                          Please read your code carefully.

                                          With Notepad++ if you select the text @commandA all occurrences of it will be colored.
                                          You can then 'mark' then, then select commandA [sans @] and all will color - including so that were not marked in the earlier step, because of the missing @...

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • TNTDAVIDT Offline
                                            TNTDAVID
                                            last edited by

                                            TIG no problem. 😉

                                            Indeed "Kaas" had identified the problem!

                                            As a noodle, I did not understand that the "@" missing, should be in brackets.

                                            The solution to the error message is simply this:

                                            cc_menu.add_item (@commandA) tb.add_item (@commandA)

                                            And it's the same for "commandeB".

                                            As this problem is resolved, we can move forward hopefully. 💚

                                            TIG, the line of code:

                                            @commandA.set_validation_proc{MF_DISABLED}

                                            Does not work!

                                            If there are orders below this line, they will not be executed.

                                            I tried all possible variants, with the "@" among the accolades, but it does not change ...

                                            1.Do you knows why?


                                            Other subject:

                                            The more I discovered the ruby, the more I realize that it is an incredible complexity. 😮

                                            If I write this in ruby ​​consol:

                                            model = Sketchup.active_model  
                                            model_definition = model.definitions
                                            model_def = model_definition['box']
                                            valeur = model_def.get_attribute 'dynamic_attributes','mode'
                                            

                                            She references me the value of the "mode" attribute, which exists in the dynamic component, "box".

                                            Let's say the result is 1.

                                            If I add this logic test:

                                            if valeur == 1
                                            puts "MODE 1"
                                            else
                                            puts "MODE2"
                                            end
                                            

                                            He answer each time, "Mode 2".

                                            Or am i completely off base of wall, if who is the safest, or the ruby ​​script is not logical. 😮 😮 😮

                                            2.Can you tell me, how such a thing is possible?

                                            I thank you for your emotional support.

                                            David

                                            [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                                            Advertisement