Monday, September 04, 2006

Custom Icons for Custom NXT-G Bricks

Using the NXT-G My Block feature, you can make your own bricks (equivalent to “functions” or “procedures” in traditional programming languages). You can learn how to do that here.

Part of the process is to select an icon for your My Block. To do this, you can select from a set of predefined icons, and you can combine those icons. But if you are like me, you’ll want to create your own icons for your blocks. And although not documented or supported, LEGO has put everything in place to do just that.

Suppose you want to create a My Block like this one:

Sample brick


The first thing you will need is to create an icon. The icon must be a transparent PNG file of dimensions 32x32 pixels. Amongst others, you can use the free software Paint.NET to create this kind of images. Make sure to use a transparent background, so that you can combine the icons with other icons you create.

For this particular sensor, I made two icons: one that just reads bNXT, and another with a compass rose. Then, I placed the two icons in the directory “C:\Program Files\LEGO Software\LEGO MINDSTORMS NXT\engine\Icons\MyBlock”, as seen in the next image:

My Block Directory contents


The next step is rather traditional. When I now start the NXT-G software, and I create a My Block, I see my two icons in the list of icons to be used:

My Block Builder


I simply superimposed the bNXT icon over the compass rose icon, and that was it. As you might have noticed, the My Block Builder shows the content of the “C:\Program Files\LEGO Software\LEGO MINDSTORMS NXT\engine\Icons\MyBlock” directory in alphabetical order, but it only shows the first 72 icons in the directory. That’s why LEGO uses their own naming/numbering system for the icon filenames that allows them to alphabetically sort the blocks. My blocks just sort of fell in between those, bumping out the last two blocks. So make sure that when you add your own blocks, your filename is within the first 72 files, alphabetically speaking.

Lucky for us, LEGO has decided to store the icon inside the .rbt file that stores your My Block. The icon travels with the My Block, and you can freely pass along your .rbt file. While the .rbt file is on your own computer, you can still edit the icon at any time. After copying the My Block to another machine, the original PNG files are no longer available on this new machine, and the icon can no longer be edited (but the program inside the Block can be opened and changed).

PS. The movie on the Compass correcting slippage post has finally been published by YouTube. Click here to see it.

6 Comments:

At September 04, 2006 8:45 PM , Blogger Brian Davis said...

Thanks for calling out that ability! For anyone else who wants to experiment, there is a lot buried in the directory structures of the Mindstorms software... not all of it is dynamic, but a good bit is,and fun to play with.

--
Brian Davis

 
At September 04, 2006 8:49 PM , Blogger Jim Kelly said...

Yes, Filip... very cool! The only problem I found, though, is you keep saying "My Brick" instead of "MyBlock" :)

Thanks for posting this...

Jim

 
At September 04, 2006 11:17 PM , Blogger cmsnxt said...

very cool , I will try it out .

 
At September 05, 2006 1:12 AM , Anonymous Filip said...

Jim,

Strange how the mind works: I didn't even notice that! I've changed the post now to read My Block nearly everywhere.

Filip.

 
At September 05, 2006 1:57 AM , Blogger Jim Kelly said...

My Brick, My Block... we all knew what you meant :)

Still a good tutorial...

Jim

 
At April 27, 2007 1:59 AM , Anonymous spencer said...

I did it but when I went to the editor the icon did not show up. what is the problem?

 

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home