sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Global/Local (component) axis

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 2.7k 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.
    • A Offline
      alz
      last edited by alz

      I'm trying to create a keystroke (or context menu command) to call the "Show Component Axes" option under Model Info/Components.

      Does anyone know what this is?

      By sorting out the current Axis-related items, I created this reference list:

      Move Global Axes
      desc: moves axis
      key: "Tools/Axes"
      code: { Sketchup.send_action "selectAxisTool:" }

      Toggle Global Axes
      desc: show/hide global axis
      key: "View/Axes"
      code: { Sketchup.send_action "viewShowAxes:" }

      Reset Global Axes
      desc: reset global axis to 0,0,0
      key: "View/Reset axis (World)"
      code: ?

      Context Menu (over global axis):
      - Place= desc: see "Axes tool" above
      - Move= desc: Dialog Box (X,Y,Z)
      ...code: ?
      - Reset= desc: see "Reset Axes" above
      - Align= desc: Top view, centered on global axis
      ...code: ?
      - Hide= desc: see "View Axes" above

      Move Local Axes
      desc: move component axis
      key: "Edit/Item/Change Axes"
      code: ?

      "Toggle Local Axes"
      desc: show component axis (in Model Info/Components)
      key:
      code: ?

      Toggle Edges Axis
      desc: color X,Y,Z axis-aligned edges
      key: "View/Rendering/Edge/By Axis"
      code: ?

      Display Tool Crosshairs
      desc: show/hide Tool crosshairs (in Preferences/Drawing)
      key: "Drawing/Display Crosshairs"
      code: ?

      1 Reply Last reply Reply Quote 0
      • Didier BurD Offline
        Didier Bur
        last edited by

        Sketchup.active_model.rendering_options["DisplayInstanceAxes"]=true
        will display components axes, and guess what
        Sketchup.active_model.rendering_options["DisplayInstanceAxes"]=false
        will do ?

        DB

        1 Reply Last reply Reply Quote 0
        • A Offline
          alz
          last edited by

          Thanks Didier!

          I was able to generate a quick test menu for these options with your direction:

          require 'sketchup.rb'
          
          #########################################
          if( not file_loaded?("Menu_Axis.rb") )
          
          ### CONTEXT MENU
          
            UI.add_context_menu_handler do | menu |
              submenuz=menu.add_submenu("Axis...")
              
              submenu01=submenuz.add_item("Move Global Axis") { Sketchup.send_action "selectAxisTool;" }
              submenu02=submenuz.add_item("Toggle Global Axis") { Sketchup.send_action "viewShowAxes;" }
              submenu03=submenuz.add_item("Reset Global Axis ...?") { UI.messagebox("Missing Command!") }
              submenu04=submenuz.add_item("XYZ Global Axis ...?") { UI.messagebox("Missing Command!") }
              submenu05=submenuz.add_item("Align to Global Axis ...?") { UI.messagebox("Missing Command!") }    
          	    submenuz.add_separator
              submenu06=submenuz.add_item("Move Local Axis ...?") { UI.messagebox("Missing Command!") }
              submenu07=submenuz.add_item("Toggle Local Axis") { if Sketchup.active_model.rendering_options["DisplayInstanceAxes"]
                          Sketchup.active_model.rendering_options["DisplayInstanceAxes"]=false
                      else
                          Sketchup.active_model.rendering_options["DisplayInstanceAxes"]=true
                      end }
          	    submenuz.add_separator
              submenu08=submenuz.add_item("Toggle Edge Axis") { if Sketchup.active_model.rendering_options["EdgeColorMode"]
                          Sketchup.active_model.rendering_options["EdgeColorMode"]=1
                      else
                          Sketchup.active_model.rendering_options["EdgeColorMode"]=2
                      end }
              submenu09=submenuz.add_item("Toggle Tool Crosshairs ...?") { UI.messagebox("Missing Command!")  }
          
          
             end #do
          
          end #if
          
          #-----------------------------------------------------------------------------
          file_loaded("Menu_Axis.rb")
          ###
          

          ...although the EdgeColorMode doesn't want to toggle back and forth (hm!)

          I poked through the API, but didn't find anything immediate that suggested the RESET, or TOOL CROSSHAIRS.


          Menu_Axis.rb

          1 Reply Last reply Reply Quote 0
          • Didier BurD Offline
            Didier Bur
            last edited by

            Maybe a "view.invalidate" instruction will refresh the view after edges mode toggle ?

            DB

            1 Reply Last reply Reply Quote 0
            • A Offline
              alz
              last edited by

              Hmm, didn't do the trick.

              Looks like I have to code a function that gets the value then checks it before changing it. I thought I could skip this bit (based on the above example for ["DisplayInstanceAxes"]=false/true).

              1 Reply Last reply Reply Quote 0
              • R Offline
                RickW
                last edited by

                You have a line near the end of your code:

                if Sketchup.active_model.rendering_options["EdgeColorMode"]
                

                Since that will always return true (non-nil), then it always evaluates the first conditional. That's why it doesn't ever toggle.

                RickW
                [www.smustard.com](http://www.smustard.com)

                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