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

    [tutorial] Sketchup Macros (OSX)

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    18 Posts 5 Posters 5.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

      ever wanted to make a macro for sketchup? here's how.

      for this example, i'll be using only keystrokes to build the macro.. for each command you'd like to include in the macro, you'll need to assign a keyboard shortcut to it via sketchup's preferences..

      i'll be using Automator to make the service (in the applications folder)..

      steps:

      1. Launch Automator and choose 'service' as the type
      2. at the top of the workflow window, select 'no input' for 'service receives selected' then choose sketchup as the application
      3. choose 'Run AppleScript' for the action
      4. use the following for the basis of the script:
      on run
      tell application "System Events"
      
      (your keystroke commands will go here)
      
      end tell
      end run
      
      1. enter the series of sketchup keyboard shortcuts using applescript's keystroke" " command
        some notes:

      for keystrokes with the shift key, just type a capital letter.. i.e.- shift x would be written: keystroke "X"
      for keystrokes with a modifier key, type 'using' afterwards.. i.e.- command w would be written: keystroke "w" using command down
      for keystrokes with more than one modifier key, make a list {} i.e.- shift/cmmd/ctrl + g would be written: keystroke "G" using {command down, control down}

      1. save the service and your macro will now appear at Sketchup->Services.

      here's a video showing the process:

      [flash=1280,720:1njg30yv]http://www.youtube.com/v/hywbEDm7WiI?version=3&hl=en_US&rel=0[/flash:1njg30yv]
      (sorry about the big video.. its a full screen capture scaled down.. hard to see the details if i posted smaller.. let me know if the big size is messing anybody up.. πŸ˜‰)

      so, this is a fairly simple example but you should be able to accomplish quite a bit with keystrokes alone.. there are ways to have the script interact with sketchup directly which opens up even more options (and i even have a way to enter some ruby commands via the services so you'll also be able to accomplish that eventually)

      i'll try to put up a better example later today/tmmr which shows my dynamic staircase in it's entirety and how this macro writing method saves a whole lot of time..
      good luck.

      (oh, i should note that i'm using lion.. while services have been around since leopard (or was it tiger?), lion makes them super easy to make.. if you're not on lion, you can still do this but there might be an extra step or two… (but i'll also say that lion is ready.. i was an early adopter but those people that are scared to update should go ahead and do it by now πŸ˜„ )

      dotdotdot

      1 Reply Last reply Reply Quote 0
      • Rich O BrienR Offline
        Rich O Brien Moderator
        last edited by

        That's incredibly useful. Super simple too πŸ‘

        Shame it's Mac only

        Download the free D'oh Book for SketchUp πŸ“–

        1 Reply Last reply Reply Quote 0
        • jeff hammondJ Offline
          jeff hammond
          last edited by

          @unknownuser said:

          That's incredibly useful. Super simple too πŸ‘

          Shame it's Mac only

          well Jim and Dan were talking about GUI scripting in windows so this stuff is probably possible on windows.. i doubt you would be able to create it as easily as I've done on Mac (this is all preinstalled software doing this).. but with a ruby as the front end, they might be able to make something that would allow for even easier creation of custom macros and cross platform as well.
          we'll see

          dotdotdot

          1 Reply Last reply Reply Quote 0
          • Rich O BrienR Offline
            Rich O Brien Moderator
            last edited by

            Can you shortcut to the services>macro?

            Download the free D'oh Book for SketchUp πŸ“–

            1 Reply Last reply Reply Quote 0
            • jeff hammondJ Offline
              jeff hammond
              last edited by

              @unknownuser said:

              Can you shortcut to the services>macro?

              yes. your services can be activated via keyboard shortcuts. there's also a real easy way to turn them on/off.. group them etc.

              dotdotdot

              1 Reply Last reply Reply Quote 0
              • bmikeB Offline
                bmike
                last edited by

                nice... thanks much.
                i have similar issues as your stringer with compound roof components.
                pretty sure i can combine your method here with what i've started to work out in a compound timber valley / hip DC.

                here's a video of the DC i started on awhile ago but abandoned due to its complexity turning it into something like a solid or single component:

                mike beganyi design + consulting llc

                1 Reply Last reply Reply Quote 0
                • jeff hammondJ Offline
                  jeff hammond
                  last edited by

                  here's another one i made yesterday (wouldn't really call this a sketchup macro though)..

                  it's does a 'save a copy as' plus assigns an interactive screenshot as a 512px icon to the file.. 😎

                  [flash=853,480:1yl5v7i5]http://www.youtube.com/v/IFpNr2V0hRI?version=3&hl=en_US&rel=0[/flash:1yl5v7i5]

                  [a sort of attempt at mimicking osx lion's Versions though this still creates multiple .skps instead of the snapshots being in a single file]

                  dotdotdot

                  1 Reply Last reply Reply Quote 0
                  • Rich O BrienR Offline
                    Rich O Brien Moderator
                    last edited by

                    Setting the screenshot to a fixed ratio would be nice, with a timestamp/watermark

                    Download the free D'oh Book for SketchUp πŸ“–

                    1 Reply Last reply Reply Quote 0
                    • jeff hammondJ Offline
                      jeff hammond
                      last edited by

                      @unknownuser said:

                      Setting the screenshot to a fixed ratio would be nice, with a timestamp/watermark

                      yeah.. i agree.. the popup alerting you to take a screenshot then the selection window is getting annoying..

                      i think i'm going to set it up as a square ratio (height of window determines how wide to make it.. (i.e.- the same thing as choosing medium format 6x6 in advanced camera tools)

                      probably won't do the timestamp.. osx makes it easy to view/sort by pretty much anything that could be associated with a file…

                      (i will say, this service, while definitely helpful for me, is nowhere as neat/integrated as what's possible to do with osx itself.. i might upload an example of how saving works in Rhino (which is tied into osxVersions).. it's great.. it does take a bit of getting used to at first because typical 'save' 'save as' etc is so ingrained in us now and versions changes that (i.e.- you never save πŸ˜„ )..

                      i'm sure it will come to windows soon..

                      dotdotdot

                      1 Reply Last reply Reply Quote 0
                      • bmikeB Offline
                        bmike
                        last edited by

                        @unknownuser said:

                        @unknownuser said:

                        Setting the screenshot to a fixed ratio would be nice, with a timestamp/watermark

                        yeah.. i agree.. the popup alerting you to take a screenshot then the selection window is getting annoying..

                        i think i'm going to set it up as a square ratio (height of window determines how wide to make it.. (i.e.- the same thing as choosing medium format 6x6 in advanced camera tools)

                        probably won't do the timestamp.. osx makes it easy to view/sort by pretty much anything that could be associated with a file…

                        (i will say, this service, while definitely helpful for me, is nowhere as neat/integrated as what's possible to do with osx itself.. i might upload an example of how saving works in Rhino (which is tied into osxVersions).. it's great.. it does take a bit of getting used to at first because typical 'save' 'save as' etc is so ingrained in us now and versions changes that (i.e.- you never save πŸ˜„ )..

                        i'm sure it will come to windows soon..

                        i so need to get on board with the saving stuff in OSX. still dating each file nearly every other day and having a hard time getting used to where to find stuff when i need a particular file. 'date modified' was my favorite sort in windows... that seems hit and miss in OSX.

                        this is good stuff. thanks for sharing.

                        mike beganyi design + consulting llc

                        1 Reply Last reply Reply Quote 0
                        • bmikeB Offline
                          bmike
                          last edited by

                          that last video is great...
                          will have to investigate that for sure.

                          mike beganyi design + consulting llc

                          1 Reply Last reply Reply Quote 0
                          • jeff hammondJ Offline
                            jeff hammond
                            last edited by

                            @bmike said:

                            that last video is great...
                            will have to investigate that for sure.

                            I'll rewrite parts of it so it's not specific to my machine and share it.
                            (if you're on lion, sharing services is a breeze.. still possible to share on 10.5 & 6 but the user has to manually place it in the services folder)

                            dotdotdot

                            1 Reply Last reply Reply Quote 0
                            • pilouP Offline
                              pilou
                              last edited by

                              Cool Stuff ! 😎
                              Why only just now and not from many years ago ? 😲

                              Any idea for make the same on PC (the first macro) ❓

                              Frenchy Pilou
                              Is beautiful that please without concept!
                              My Little site :)

                              1 Reply Last reply Reply Quote 0
                              • wind-borneW Offline
                                wind-borne
                                last edited by

                                did create a couple macros 😎

                                would like guidance on creating macro of full SU window capture for icon/preview followed by cmd S without creating new file.

                                I'll let ForeverSave keep the manual(Automator) versions with it's autosave unchecked and sort from there.


                                ForeverSave 2.png

                                "To read between the lines was easier than to follow the text."OSX 10.11.6

                                %(#BF80BF)[SU 8 pro

                                1 Reply Last reply Reply Quote 0
                                • wind-borneW Offline
                                  wind-borne
                                  last edited by

                                  Jeff,

                                  having problems with the final applescript, doesn't seem to access SU.
                                  "A" toggles axes off, but doesn't toggle back on with last script. Other test was trying "cmd a" in final script which should have selected all in SU but selected all on desktop instead. Tried shifting order?
                                  Screen Shot 2012-04-15 at 8.44.27 AM.png

                                  other problem is this SU dialog which pops up after every first save after running macro. Can I automate a Save for this?
                                  SketchUp.png

                                  if I use GC, icon updates on main file which is probably my main goal as I don't often use ForeverSave2 as was icing on a big Mac bundle...


                                  Screen Shot 2012-04-15 at 8.46.12 AM.png

                                  "To read between the lines was easier than to follow the text."OSX 10.11.6

                                  %(#BF80BF)[SU 8 pro

                                  1 Reply Last reply Reply Quote 0
                                  • jeff hammondJ Offline
                                    jeff hammond
                                    last edited by

                                    @wind-borne said:

                                    Jeff,

                                    having problems with the final applescript, doesn't seem to access SU.

                                    yeah.. you've left the sketchup environment at this point in your script by going to finder and maybe graphic converter..

                                    to get back to sketchup, you'll have to add this prior to your final system events tell

                                    tell application "sketchup" to activate

                                    this will bring sketchup back to the front application.

                                    @unknownuser said:

                                    other problem is this SU dialog which pops up after every first save after running macro. Can I automate a Save for this?
                                    [attachment=2:32yjarrq]<!-- ia2 -->SketchUp.png<!-- ia2 -->[/attachment:32yjarrq]

                                    hmm.. i'll have to look into this a little later to see what's going on..

                                    fwiw, getting a non interactive screenshot (unless it's the entire screen) has proven to be a lot more difficult than i originally though it would be.. i'm in a thread at an applescript forum right now trying to reach a solution but it's not looking too good..

                                    i also tried going the route of using sketchup's 2d export to create the icon image (which is actually pretty awesome because you could do pngs with transparent backgrounds.. it also eliminates what you're doing with hiding the axes because a 2d export doesn't include it).. the problem with that is there's about a 5 second delay in there because of something weird going on with the export dialogs (and i've posted about this on the google sketchup forums)..

                                    if you open 'activity monitor' then go to sketchup's 2D export -> Options… you'll see a ginormous spike in cpu usage.. something is wrong with opening those panels which causes a slow down in the script i was trying to make..

                                    still researching though.. non conclusive as of now.

                                    dotdotdot

                                    1 Reply Last reply Reply Quote 0
                                    • wind-borneW Offline
                                      wind-borne
                                      last edited by

                                      Thanks,

                                      I had tried moving script between Screenshot and Finder section.

                                      tell application "sketchup" to activate

                                      needs to be

                                      tell application "SketchUp" to activate πŸ˜†

                                      Works now.

                                      I was trying the " Watch Me Do" to automate pick window, didn't work how I tried.

                                      "To read between the lines was easier than to follow the text."OSX 10.11.6

                                      %(#BF80BF)[SU 8 pro

                                      1 Reply Last reply Reply Quote 0
                                      • jeff hammondJ Offline
                                        jeff hammond
                                        last edited by

                                        @wind-borne said:

                                        Thanks,

                                        I had tried moving script between Screenshot and Finder section.

                                        tell application "sketchup" to activate

                                        needs to be

                                        tell application "SketchUp" to activate πŸ˜†

                                        Works now.

                                        I was trying the " Watch Me Do" to automate pick window, didn't work how I tried.

                                        yeah.. watch me do doesn't work out as good as it seems.. super slow and whatnot..

                                        i'm now messing around with the idea of getting the icon image via ruby instead of a screenshot or GUI scripting sketchup.. ruby confuses the hell out of me though πŸ’š ..i'll make a post in the developers forum real quick.. those guys will help me sort it out.. πŸ˜‰

                                        dotdotdot

                                        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