Category Archives: Solutions

Recovering lost animation on referenced characterSets in Maya 2011

A friend recently lost all of his animation on a referenced character rig. The file still opens without Maya complaining, but the keys just went missing. A quick check of the .ma in a text editor confirmed that the animCurve nodes were still present.

Feeling adventurous, I fired up notepad++ and did a text comparison of a working file containing the same referenced rig and the problematic file. Sure enough, the animCurve nodes seem to be connected to the wrong .phl (placeHolderList) of the reference file, or were not Continue reading

Creating nodes programmatically in Drupal (including cck and location fields)

Creating a new node in drupal is trivial, but when the node includes custom cck fields, then a few things can trip you up. To save time and energy, here’s a quick guide and some tips to make your drupal life easier.

Creating a basic node:

global $user; //get current logged in user
$new_node = new stdClass();
$new_node->type = 'YOUR_NODE_TYPE_HERE';
$new_node->uid = $user->uid; //you can specify some other userID here if you want
$new_node->name = $user->name;
$new_node->title = $YOUR_NODE_TITLE;
$new_node->body = $YOUR_NODE_BODY;
$new_node->status = 1; // published

The function node_save() does a few things behind the scene. It checks if the nid property is empty to determine if this is a new insert or an update, then calls the appropriate functions so that you would not have duplicates. Put simply, if you want to do an update, populate the nid, and leave it out otherwise.

Creatnig a node with CCK fields involves this additional line (for each field):

$new_node->field_your_field[0]['value'] = $YOUR_FIELD_DATA;

Point to note is the [0][‘value’], because CCK treats each field as multiple-value fields even if you specified otherwise in the field settings. If you see the error Fatal error: Cannot unset string offsets in …/modules/cck/content.module on line 1248, you’re probably missing the [0][‘value’] and setting the value directly into $new_node->field_your_field.

To create a node with location, we need to save the location first to get a location ID before saving it along with our node:

$location = array(
'street' => $address,
'postal_code' => $postal,
$locationID = location_save($location);
$new_node = new stdClass();
// ... the usual stuff ...
$new_node->locations[0]['lid'] = $newLocationId;

There you go. Another method is to manually craft an array to simulate a $_POST from a drupal form. To do that you basically have to know the form structure, populate the require fields and pass the array on to the drupal_execute() call. Refer to the example here for more details.

Drupal references:
Node_save: drupal documentation

Size mismatch when getting BitmapData from Camera

Recently while trying to capture a frame from my webcam in Adobe Air, I realize the captured image is always smaller than the height or videoHeight from the Video object. The BitmapData documentation revealed that the BitmapData.draw() operation does not respect any matrix transformation applied on the Camera or Video object, so we need to do the scaling ourselves. A quick and dirty way would be:


//var video:Video; and a Camera object is already attached
var matrix:Matrix = new Matrix();
matrix.scale(video.width / 320, video.height / 240);



Font Recognizer

Not everyone can recognize a font by their distinct cross bar or descender. For the less enlightened – me included – this tool that helps you recognize fonts. Submit an image and it will try to match it to their database of fonts.

If you’re in the mood for a little more on typeface anatomy, check out and

Drupal Tip #6 – Missing Groups When Altering Node Forms

In customizing your node forms, hook_form_alter is a great way to restructure your forms before it is displayed. If you are using views2 and use groupings to organize your forms, its necessary to use hook_form_alter to bring certain form elements into groups because you’re not allowed to do so from the UI. Fields such as the title and body cannot be dragged under any groups in the manage fields page of the content type.

When a field is not in any groups, it will appear as a direct child key of the form, e.g.


When it is under a group, it will be nested in a key with the group’s name, e.g.


To move the field, simply assign its value into the appropriate group key, and unset the original key:

$form['group_example']['field_example'] = $form['field_example'];

One common problem though, is that the group keys are not appearing in the $form array passed into your_module_form_alter. You double checked the content type in the admin page (/admin/content/node-type/[your-node-type]/fields) but they are still not showing. Do not panic, they simply have not been created yet. The reason for this is that the CCK module’s hooks responsible for creating these keys are fired later than your form_alter hook, and this is a simple problem to solve.

Making sure your hooks are called after CCK

Drupal determines which modules are called when using their weight in the system table. To reorder your module to after CCK, you can manually set it’s weight:

db_query("UPDATE {system} SET weight = 50 WHERE name = 'your_node_type'");

One common place to do this is in the your_module.install file, so that its set only once during installation. My choice of weight (50) is purely arbitrary, you may need to inspect your own system table to determine the most appropriate weight.

Now your group keys should be appearing in the $form array.

Drupal Tip #5 – Custom Theme Function for Forms

Defining a custom theme function for forms involves writing the actual theme function and registering it with your own hook_theme function.

Custom Theme Function

The name of the function would be your form ID (replacing dashes with underscores) prepended by ‘theme_’:

function theme_your_form_id($form){
$output = 'Any html you need here';
$output .= drupal_render($form['subject']);
$output = ' and here';
$output .= drupal_render($form['submit']);
$output .= drupal_render($form);
$output .= '';
return $output;

Registering the theme function

In your hook_theme implementation, add a key to the returned array. The key should be your form id, do not include the ‘theme_’ prefix.

function deepgreen_theme() {
$themes = array(
. . . other theme functions here . . .
'your_form_id' => array (
'arguments' => array('form' => NULL),
'type' => 'module',
return $themes;

Drupal Tip #4 – Normal buttons with Drupal Form API

Drupal 6’s form API does not support input elements of type “button”. If you define one with ‘#type’=>’button’, it will be converted to a ‘#type’=>’submit’ automatically. So, how do you do it other than placing the button in a template file or function? You can use the ‘markup’ type, which is the default if no ‘#type’ key is defined. Example:

$form['submit'] = array(
'#value' => '<input type="button" onclick="return submitForm();" />',

Drupal 6 Form API Reference

Running your app in the BlackBerry Simulator

The BlackBerry OS SDK currently only supports Flash Builder 4.0.1, not Flash Builder 4.0. When following steps described in BlackBerry’s own Getting Started Guide to launch your app in the simulator, users of Flash Builder 4.0 will get an internal error:

An internal error occurred during: "Launching [your project name]".

To overcome this, either download the 261MB patch from adobe, or use the command line packager which comes included with the BlackBerry OS SDK.

Using the command line packager

In essence, there is only one command that you’ll need, the syntax is:

blackberry-airpackager -package output_bar_file_name -installApp -launchApp
project_name-app.xml project_name.swf any_other_project_files
-device IP_address

What you’ll need: your project name, your BlackBerry simulator’s IP address, the .swf of your project which is compiled by Flash Builder using the normal tools (Project->Build Project or export release build). And remember the output_bar_file_name must end with the extension .bar. If you forget this, however, the error describes it quite plainly to you. For me, a working command looks like (where “AirTest” is my project name):

blackberry-airpackager -package -installApp -launchApp AirTest-app.xml AirTest.swf -device

(If you are not familiar with running commands in windows, you need to add the path to blackberry-airpackager.bat in your system’s “path” environment variable.)

Do I have to run that manually everytime?

Fortunately, you don’t. The command can be configured as a builder in Flash Builder 4.

  1. Go to Project->properties, and under Builders, click on the “New” button to add a new builder. Select type Program, give a name to the builder (any will do, I named mine “BBLauncher”).
  2. Enter the path to your blackberry-airpackager.bat in the location field. Mine was:

    D:Program FilesAdobeAdobe Flash Builder 4sdksblackberry-tablet-sdk-0.9.0binblackberry-airpackager.bat

  3. Enter the path of your project in the working directory (the folder where you find your main .as file, likely your current “src” directory).
  4. And Lastly, in Arguments, enter the options of the command:

    -package -installApp -launchApp AirTest-app.xml AirTest.swf -device

Move this builder to after “Flex” and “AIR application.xml Builder”, and you are done. From now on you can launch the app in the simulator by doing a Project->Build project.

Posts that helped me:

Installing BlackBerry Tablet OS SDK for Adobe AIR

Users of 64bit windows might get frustrated installing the new BlackBerry Tablet OS SDK if you are not using the 32bit Java Development Kit (JDK). When you run the .exe from BlackBerry, an error claims that “Win64 not supported. The author of the package you are installing did not include support for this platform.” The solution is trivial:

Unzip “BlackBerryTabletSDK-Air-Installer-0.9.0-Win.exe” and you should see 2 folders, “InstallerData” and “Windows”. Go into the Windows folder and find the .lax file.

Open the file in a text editor and change this line

to[your path to java.exe]

If you are not sure where is your JDK installation, check your C:/Program Files (x86)/Java folder for a folder named like jdkx.x.x_xx. Open it and look for the bin folder inside, your java.exe should be inside. For example, my path would be: Files (x86)/Java/jdk1.6.0_22/bin/java.exe

Save the file and run the .exe in the same folder (BlackBerryTabletSDK-Air-Installer- to start the installation.

If you do not have your JDK yet, get it at