SketchUcation Premium Membership

 

 

[tutorial] Sketchup Macros (OSX)

General discussion related to SketchUp. No off topic threads please.

[tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Mon Apr 09, 2012 8:32 pm

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:

Code: Select all
on run
tell application "System Events"

(your keystroke commands will go here)

end tell
end run


5) 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}

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

here's a video showing the process:

http://youtu.be/hywbEDm7WiI?hd=1


(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.. :wink:)

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 :D )
dotdotdot
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby Rich O Brien » Tue Apr 10, 2012 12:17 am

That's incredibly useful. Super simple too :thumb:

Shame it's Mac only
:::Blog:::

I'm a Trimbler now!
User avatar
Rich O Brien
Administrator
 
Posts: 8266
Joined: Fri Oct 31, 2008 9:05 am
Location: Limerick, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Tue Apr 10, 2012 12:28 am

Rich O'Brien wrote:That's incredibly useful. Super simple too :thumb:

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
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby Rich O Brien » Tue Apr 10, 2012 12:36 am

Can you shortcut to the services>macro?
:::Blog:::

I'm a Trimbler now!
User avatar
Rich O Brien
Administrator
 
Posts: 8266
Joined: Fri Oct 31, 2008 9:05 am
Location: Limerick, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Tue Apr 10, 2012 1:18 am

Rich O'Brien wrote: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
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby bmike » Tue Apr 10, 2012 3:51 am

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:

http://youtu.be/wizUYwZH0Vs
User avatar
bmike
 
Posts: 487
Joined: Mon Dec 15, 2008 6:42 pm
Location: vermont

Re: [tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Wed Apr 11, 2012 6:43 pm

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.. :fro:

http://youtu.be/IFpNr2V0hRI?hd=1




[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
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby Rich O Brien » Wed Apr 11, 2012 6:58 pm

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

I'm a Trimbler now!
User avatar
Rich O Brien
Administrator
 
Posts: 8266
Joined: Fri Oct 31, 2008 9:05 am
Location: Limerick, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Wed Apr 11, 2012 7:12 pm

Rich O'Brien wrote: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 :D )..

i'm sure it will come to windows soon..
dotdotdot
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby bmike » Wed Apr 11, 2012 7:23 pm

Jeff Hammond wrote:
Rich O'Brien wrote: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 :D )..

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.
User avatar
bmike
 
Posts: 487
Joined: Mon Dec 15, 2008 6:42 pm
Location: vermont

Re: [tutorial] Sketchup Macros (OSX)

Postby bmike » Wed Apr 11, 2012 7:29 pm

that last video is great...
will have to investigate that for sure.
User avatar
bmike
 
Posts: 487
Joined: Mon Dec 15, 2008 6:42 pm
Location: vermont

Re: [tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Wed Apr 11, 2012 7:59 pm

bmike wrote: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
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby Pilou » Wed Apr 11, 2012 10:45 pm

Cool Stuff ! :fro:
Why only just now and not from many years ago ? :shock:

Any idea for make the same on PC (the first macro) :?:
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
Pilou
Top SketchUcator
 
Posts: 10027
Joined: Wed Jan 23, 2008 10:33 pm
Operating system: Windows
SketchUp version: 6
License type: Free
SketchUp use: hobby
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby wind-borne » Thu Apr 12, 2012 4:33 am

did create a couple macros 8-)

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.
Please, register (free) to access all the attachments on the forums.
"To read between the lines was easier than to follow the text."OSX 10.8.3 _ _ _ _ _ SU 8.0.16845 pro
User avatar
wind-borne
Premium Member
Premium Member
 
Posts: 152
Joined: Thu Sep 17, 2009 4:05 am
Location: HI

Re: [tutorial] Sketchup Macros (OSX)

Postby wind-borne » Sun Apr 15, 2012 8:46 pm

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...
Please, register (free) to access all the attachments on the forums.
"To read between the lines was easier than to follow the text."OSX 10.8.3 _ _ _ _ _ SU 8.0.16845 pro
User avatar
wind-borne
Premium Member
Premium Member
 
Posts: 152
Joined: Thu Sep 17, 2009 4:05 am
Location: HI

Re: [tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Sun Apr 15, 2012 9:16 pm

wind-borne wrote: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.


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


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
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [tutorial] Sketchup Macros (OSX)

Postby wind-borne » Sun Apr 15, 2012 9:33 pm

Thanks,

I had tried moving script between Screenshot and Finder section.

tell application "sketchup" to activate

needs to be

tell application "SketchUp" to activate :lol:

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.8.3 _ _ _ _ _ SU 8.0.16845 pro
User avatar
wind-borne
Premium Member
Premium Member
 
Posts: 152
Joined: Thu Sep 17, 2009 4:05 am
Location: HI

Re: [tutorial] Sketchup Macros (OSX)

Postby Jeff Hammond » Sun Apr 15, 2012 9:47 pm

wind-borne wrote:Thanks,

I had tried moving script between Screenshot and Finder section.

tell application "sketchup" to activate

needs to be

tell application "SketchUp" to activate :lol:

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 :mrgreen: ..i'll make a post in the developers forum real quick.. those guys will help me sort it out.. ;)
dotdotdot
User avatar
Jeff Hammond
Global Moderator
 
Posts: 4308
Joined: Thu Jan 24, 2008 11:16 pm
Location: newyorkcity
Operating system: Mac
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Artisan Organic Toolset - a set of powerful organic modeling tools.

Premium Members get 20% discount!

Ad Machine
Robot
 
Posts: 2012



 

Return to SketchUp Discussions

Who is online

Users browsing this forum: No registered users and 4 guests