Bricksmith Custom Categories

Here is a hack to add new categories to the Bricksmith part browser. The part catalog is normally organized into categories based on the type of each part (such as brick, plate, or tile). However, if you’re building a model based on a real set, it’s just as useful to present the parts from that set in one category.

Adding a category from a Peeron inventory

To create a category consisting of the parts from set 4891, enter 4891 and click Peeron Inventory:

Screenshot: Naming a category based on a Peeron inventory

The script will retrieve the corresponding list of parts and populate a new category containing them:

Screenshot: Browsing a category retrieved from Peeron

Adding a category from a file

To create a category based on an arbitrary group of parts, save a list of part file names, like this:

3005.dat
3004.dat
3003.dat
3001.dat

Then enter a name for your category and click From File. You’ll be prompted to select the list you just created.

Screenshot: Naming a category to be loaded from a file

The script will add the listed parts to the named category:

Screenshot: Browsing a category loaded from a file

Limitations

The script is awfully slow. AppleScript’s property list commands are not well suited for making many changes.

Parts listed in the file or inventory which are not already present in your part library will not be included in the category.

New categories are not visible until you restart Bricksmith. (I recommend quitting Bricksmith before running the script anyway.) Custom categories are lost when you reload the part list from Bricksmith’s Parts preferences.

No feedback is provided while the script is running.

Errors are not handled particularly well.

Mac OS X 10.5 is required.

It’s really slow.

Download

Bricksmith Catalog Custom Categories 26.4 KB

Posted on Saturday, June 21st, 2008.

Mis Bicicletas

I bought an old road bike for $9 last week. I’ve enjoyed tuning it up and thinking of new missions for it and my other bike.

Mountain Bike Nine Dollar Road Bike

The basket on the red bike is neat because it can be unclipped and carried around like a regular shopping basket. Quite practical! I’ll upload more pictures to my bikes set as the fleet evolves. I expect a rack and further repairs may be in store for the blue bike.

Posted on Thursday, June 19th, 2008.

A New Study Suggests That…

My friend Dan has authored a study which has received considerable press coverage this week. It is about the circumstantial advantages of ADHD. Articles about his paper have appeared at Scientific AmericanSlate, The Economist, New Scientist, The Daily Telegraph, and elsewhere.

It’s all in a day’s work for Dan, but it’s nice to see such widespread recognition for his research. He’s given me many insights into the evolutionary elegance of the world around us, and now the world has a chance to consider his insight.

Posted on Friday, June 13th, 2008.

Unnatural Selection

As you may know, the runner-up at this year’s Kentucky Derby, Eight Belles, was euthanized shortly after the race due to ankle injuries she sustained just after crossing the finish line.

Interestingly, Eight Belles and all of her Kentucky Derby competitors were in part descended from Native Dancer, an accomplished racehorse whose career was eventually curtailed by a “recurring foot injury” and whose bloodline has a reputation for “producing fragile horses”.

Selective breeding leads to the inheritance of desired traits like being fast and light. When taken to extremes (as with the inbred pure-breeding of some Thoroughbreds, arguably), it’s not too surprising that narrow emphasis on a few traits breeds animals that may otherwise be unfit to withstand aspects of the stress they’re expected to endure.

But then again, Kentucky is home to the Creation Museum. Maybe if they ask nicely someone upstairs will just intelligently design a stronger racehorse.

Posted on Thursday, June 5th, 2008.

Fuel Economy

In the sixteen years since it was manufactured, my truck has travelled some 190000 miles. Supposing an average fuel economy of 14 miles per gallon, the truck has burned about 13571 gallons of fuel. That’s a lot.

A Boeing 777-200, smallest of the 777s, has a maximum fuel capacity of 31000 gallons. That’s more than twice as much as a lot. The 777-200’s maximum range is listed as 5235 nautical miles, or some 6024 miles. Disregarding other factors, and the possible irrelevance of such limits to typical operation, these maximums suggest a fuel economy between 0.19 and 0.2 miles per gallon.

These calculations are contrived, but it should be clear that a transcontinental flight consumes more than peanuts.

Nevertheless, this comparison should not be construed as an indictment of air travel. There are millions of trucks like mine but only a handful of airliners. Furthermore, airplanes carry many passengers, and cars do not. Last but not least, cars cannot fly. Flight is intrinsically cool.

So, I leave it as an exercise for the reader to figure out how many people a 777-200 would have to carry from NY to LA to use less fuel than those people would use if they each drove a truck like mine the same distance.

Posted on Tuesday, May 13th, 2008.

Fox Kits

Here’s a video clip my mom took of some little foxes frolicking around their den.

Posted on Monday, May 12th, 2008.

Note Poster

Here’s a script to create a new post in MarsEdit from a note selected in Yojimbo. Why use a script when it’s already as easy as copy and paste? Well, maybe your computer is running out of paste.

tell application "Yojimbo"
	set _items to selected items of browser window 1
	if (_items is {}) or (_items is missing value) then return
	set _note to item 1 of _items
	if class of _note is not note item then return
end tell

tell application "MarsEdit"
	set _post to make new document
	set body of _post to contents of contents of _note
	set title of _post to name of _note
	activate
end tell

Click here to open the script directly in Script Editor. Save it in ~/Library/Scripts/Applications/Yojimbo and you’re ready to run.

Posted on Sunday, May 11th, 2008.

LDTrim

LDTrim is a simple program that condenses or formats LDraw code by trimming extraneous characters like spaces – or inserting them to align values in columns.

LDTrim was developed to help “pretty-print” examples for documentation or discussion, but it could also be used to reduce file size or to standardize the format of many models.

Much of what LDTrim does is already possible with LDraw Design Pad. For example, see “Trim Lines” and “Auto Round Selection” under the “Tools” menu.

Usage

Here is the output of ldtrim -help:

LDTrim 1.1
Usage: ldtrim                         Default:
    [-in FILE]  | [-in FILE FILE...]    stdin (use -ing to glob wildcards)
    [-out FILE] | [-out DIRECTORY]      stdout
    [-precision DIGITS]                 all significant digits preserved
    [-trim zeros|none]                  zeros (trims redundant trailing zeros)
    [-justify left|right|none]          none (alignment of values in field)
    [-invalid omit|keep]                omit (keep retains unrecognized lines)
    [-width CHARACTERS|max]             variable (minimum width of all fields)
    [-1..15 CHARACTERS]                 variable (override width for one field)
    [-h|--h|-help|--help]               display this usage summary

If multiple input files are specified without -out, they are modified in place.
If -out is given with multiple input files, output is saved to that directory.

The -precision option causes values to be rounded down and may append zeros to
reach the specified precision unless -trim zeros is explicitly specified.

Whitespace between fields is condensed to a single space.

The -width option pads values with spaces to reach the specified field width.
If -width max is given, the widest value is used as the width for all fields.
(Sub-part names are ignored for this comparison.) If a field value exists that
is wider than the requested width, that width is used as the field width.

Right justification is used if -width or -1..15 is specified without -justify.
If none of -width, -1..15, or -justify is specified, fields are unaligned.

If environment variable GATEWAY_INTERFACE is defined, LDTrim is a CGI script.

Example

Suppose you have saved this LDraw code as sample.ldr:

1 0 20.000000 0.000000 20.000000 0.000000 -1.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 4085c.dat 1 1 28.000000 7.000000 27.000000 0.000000 -1.000000 0.000000 0.500000 0.000000 -0.866025 0.866025 0.000000 0.500000 3023.dat 1 25 36.000000 -5.000000 11.000000 0.000000 -1.000000 0.000000 0.707106 0.000000 -0.707106 0.707106 0.000000 0.707106 2412b.dat 

Running ldtrim -in sample.ldr -out trimmed.ldr will save the following as trimmed.ldr:

1 0 20 0 20 0 -1 0 1 0 0 0 0 1 4085c.dat 1 1 28 7 27 0 -1 0 0.5 0 -0.866025 0.866025 0 0.5 3023.dat 1 25 36 -5 11 0 -1 0 0.707106 0 -0.707106 0.707106 0 0.707106 2412b.dat 

The default behavior is to condense the code as much as possible without modifying the model. Alternatively, you can use LDTrim to reformat code. For instance, ldtrim -precision 2 -width 5 -1 1 -2 3 -in trimmed.ldr -out aligned.ldr outputs the following as aligned.ldr:

1 0 20.00 0.00 20.00 0.00 -1.00 0.00 1.00 0.00 0.00 0.00 0.00 1.00 4085c.dat 1 1 28.00 7.00 27.00 0.00 -1.00 0.00 0.50 0.00 -0.87 0.87 0.00 0.50 3023.dat 1 25 36.00 -5.00 11.00 0.00 -1.00 0.00 0.71 0.00 -0.71 0.71 0.00 0.71 2412b.dat 

Giving a minimum field -width argument implies -justify right. Similarly, decimal -precision implies -trim none, leaving trailing zeros intact. The -1 and -2 options override the minimum width for the first two columns.

Batch Mode

If LDTrim is given multiple input files, it will process them all, saving the results to files of the same name in the directory given by -out or overwriting the input files if no output folder is given.

ldtrim -in $LDRAWDIR/parts/*.dat -out /trimmed/parts/ 

Note that with a single -in file, -out is interpreted as a single output file, but with multiple -in files, -out is interpreted as a directory to contain the results.

Web Interface

LDTrim has a rudimentary web interface built in. If the GATEWAY_INTERFACE environment variable is detected, LDTrim will behave like a CGI script. Specifically, it will print an HTML form with controls that roughly correspond to its command-line options. LDraw code posted via this form (to itself, as the action ldtrim) is processed according to the selected options. The results are returned in the same form.

Download

LDTrim is also available as a platform-independent Starkit (50 KB) which requires an 8.5 Tclkit.

The current version of LDTrim is 1.1; it fixes a bug that caused malformed line endings to be output on Windows.

Posted on Saturday, May 10th, 2008.

Candid Sketches

Drawing people in public is a fun challenge because you’ve only got a few seconds to nail their form before they walk past or shift position. I think the figures that result are more convincing than many I’ve drawn from photographs because they’re based on natural poses rather than those affected for the camera or the studio.

It’s refreshing to leave faces blank for a change.

Colorized Benchwarmers

I colored this picture on the computer. Give it a click to look at a few other recent sketches.

Posted on Wednesday, May 7th, 2008.

Hobbies

I’ve often said that I have many hobbies. I draw, I write little computer programs, I play with Legos. I work on my truck and in summer I kayak. I’ve run a hundred miles in the past month, and sometimes I even try to play the piano.

Am I an expert at any of these things? Decidedly not. But my expertise develops in step with my entertainment, and perhaps some aspect of these endeavors will someday assist or inspire someone else. (Hell, maybe someday it’ll even earn me an income.)

So it was with great interest and optimism that I watched Clay Shirky’s recent “Gin, Television, and Social Surplus” speech (via Gus Mueller, who also linked to a transcript).

The gist of Clay’s talk is that television has been an entertaining but unproductive use of the relatively plentiful spare time enjoyed by members of modern society. More importantly, he argues that ambitious projects like Wikipedia represent a total investment of personal time that is negligible in comparison to the time people spend watching TV. He calls this recreational time our “cognitive surplus”, and regards it—rightly, in my opinion—as an incredible resource that has only begun to be tapped.

I am enthusiastic about what can be accomplished as more slivers of spare time are spent on pet projects and the mischievous misadventures that beckon from beyond the sofa. Serendipity, meet spontaneity! Curiosity and collaboration are already here.

Anyway, I admit television is a popular scapegoat. It’s not all bad, but there should be more to life than a daily cycle of drudgery and reruns. We improve each other’s lives by pursuing the interests that enrich our personalities and abilities, be at it work, in the back yard, or even on the tube. I am pleased to say that this holds true for every person I know; everyone has some hobby or calling or quirk that contributes to what I know and appreciate about the world. Thank you!

Posted on Wednesday, April 30th, 2008.