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

    Toggle X-Ray Button Held Down

    Scheduled Pinned Locked Moved Plugins
    4 Posts 3 Posters 1.2k Views 3 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.
    • R Offline
      rossthompson
      last edited by

      Hi guys,

      I have written a very basic script that allows me to toggle X-ray rendering mode on and off from a custom made toolbar. However when the mode is active the icon does not remain 'pressed' as it does on the official 'Face Style' toolbar. The image below hopefully illustrates the effect I want. The code is also included.

      Any help would be greatly appreciated. I have no idea how to approach this.

      Thanks

      Ross

      
      toolbar = UI;;Toolbar.new "View"
      	cmd = UI;;Command.new("X-Ray") { xray }
      	cmd.large_icon = "CBG/togglexray_lg.png"
      	cmd.small_icon = "CBG/togglexray_sm.png"
      	cmd.tooltip = "Toggle X-Ray"
      	toolbar = toolbar.add_item cmd
      	toolbar.show
      # Toggle X-ray
      def xray
        if Sketchup.active_model.rendering_options["ModelTransparency"] == false
          Sketchup.active_model.rendering_options["ModelTransparency"] = true
        else
          Sketchup.active_model.rendering_options["ModelTransparency"] = false
        end
      end
      
      
      

      Pressed Icon.JPG

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

        I made an experimental feature like this recently - the Peek feature you see in this video: http://youtu.be/19BnGnR7bSs

        What I did was create a tool that would detect which keyboard shortcut was assigned to the function that activates it. It then detect when the key(s) that triggered it is released where it then deactivates the tool.

        The challenge is that you need to parse the list of shortcuts you get from Sketchup.get_shortcuts and translate it into what key codes and key flags. I just make a quick proof of concept and haven't mapped out things properly yet. Before I can post what I have as an example I need to extract the rest of the functions.

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

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

          Ross,

          There is a possibility to do that

          
          
             toolbar = UI;;Toolbar.new "View"
             cmd = UI;;Command.new("X-Ray") { xray }
             cmd.large_icon = "CBG/togglexray_lg.png"
             cmd.small_icon = "CBG/togglexray_sm.png"
             cmd.tooltip = "Toggle X-Ray"
             cmd.set_validation_proc { (Sketchup.active_model.rendering_options["ModelTransparency"]) ? MF_CHECKED ; MF_UNCHECKED }
             toolbar = toolbar.add_item cmd
             toolbar.show
          
          def xray()
             opts = Sketchup.active_model.rendering_options
             opts["ModelTransparency"] = !opts["ModelTransparency"] 
          end
          
          
          

          Fredo

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

            Oh 😳 I completely misunderstood the question! Never mind me! πŸ˜’

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

            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