automator

Print to Second Life

| | | |

Printing to Second LifePrinted to Second Life

My ongoing experiments in Second Life collaborative tools and real-life integration led me to devise a "Print to Second Life" function for Mac OS X. As shown in the pictures, you just select "Second Life" from the PDF pulldown button on the standard print dialog box from any application, and voila, the paged printout shows up on your printer in Second Life.

How it's done.
This uses an OS X Automator workflow with an additional FTP action added, and a scripted printer in Second Life that can load and page through the printout. An Automator workflow placed in the PDF Services folder can be selected to postprocess print-to-PDF output in the Mac's standard print dialog box. The workflow converts the PDF to jpeg pages, and uploads the pages via FTP to a specified location on a web server. The printer in Second Life uses the URL of the web server's specified location and sequential file names to set the parcel media URL. The printer's output page is the media substitution texture, and the printer's buttons control the paging back and forth.

I'm not ready to provide a ready-to-run kit of parts for this, but here's a more detailed version of the recipe for the inspired and/or able. Complicated to make, easy to use.

1. I started with the "Upload to FTP" Automator action for OS X.
Using this action as-is caused new printouts to pick up any excess pages from older but longer printouts. But Peter Dekker was kind enough to provide the source code for the action, so I added two lines of code and rebuilt the action (using Apple's Xcode) as "Delete Dropbox then FTP":

# Warning Will Robinson: this is where we remove all the contents of the dropbox and its folder!
$ftp->rmdir($ftp_dir , 1) or myerr("Could not remove directory: $ftp_dir.");
$ftp->mkdir($ftp_dir) or myerr("Could not create directory: $ftp_dir.");

(As the note indicates, this action will first remove the directory named in the action, without warning, so don’t accidentally doom your favorite directory of recipes!) To change the name, you’ll also have to poke around various files in the action source. The new action, “Delete Dropbox then FTP” is then placed in either the Library/Automator or ~/Library/Automator folder.

2. I created a workflow called “Second Life” using Automator.
The actions I used were:

  1. Get Folder Contents
  2. Render PDF Pages as Images (RGB, JPEG image, 200 dpi)
  3. Move Finder Items (replacing existing files, to a temp directory that I had to set up)
  4. Rename Finder Items (Make Sequential, new name “PDF”, place number after name, start numbers at 1, separated by dash)
  5. Move Finder Items (replacing existing files, to a second temp directory that I had to set up)
  6. Store Disk Item References
  7. Delete Dropbox then FTP (here you put my Server, Username, Password, Directory and Base URL info)
  8. Retrieve Disk Item References
  9. Move to Trash (clears out your second temp directory).
This workflow is placed in either the Library/PDF Services or ~/Library/PDF Services folder Now, when I print, and chose “Second Life” from the PDF pulldown button, the Automator script will kick in and load up the pages on my server.

3. I created a printer in Second Life
The basic printer loads up a media parcel URL from a known location, and pages through the printer output. I have buttons to load and play the first page, load and play next and previous pages, and a button to set up the base URL of the printout directory on your server. The buttons talk to each other to sync up what page is currently being displayed (kept in memory) and what the base URL is (kept in the button’s description field). The real action is done by the llParcelMediaCommandList command. You have to either be the owner of the printer and the land under it, or the land belongs to a group you belong to, and you deed the printer to the group. [Update: I added portrait/landscape mode buttons to flip the printout page to a vertical or horizontal orientation.]

30 years ago, I would take a stack of cards up to a counter, where there was a sign that said “Turnaround Time”, usually something like 45 minutes. 45 minutes later, I’d pick up my printout, find the syntax error, repunch a card and put it in again. Little did I know that all I had to do was wait 30 years and I could sit in my easy chair, push the print button, and have it show up in my own little world of make believe.
Syndicate content