Reset Object-Material link using Python.

I recently had my laptop stolen and, although I was backed up to an extent, one piece of data which I lost was a script which I lifted off the Blender Artists forum and modified.

The script merely reset the Object link to material from “OB” to “ME”.

When I import a DXF file the materials are inevitably imported as “OB”

My modification just looped through the open blend file, read the name of the current material, reset the link to “ME” and then linked to the material name.

If anyone knows the script to which I refer, won’t you please please point me to it?

Alternatively how do I clear the link to the material? ie, to simulate pressing the “ME” toggle button on the name block on the Shading button panel (F5)?

Using 2.49b here because of legacy issues.

Just to clarify, the meshes are imported DXF 3DFACES, which the dxf_importer imports as meshes which are object-linked to a material. ie, in the ‘Shading (F5)’ Panel, showing the ‘Material’ buttons, on the ‘Links and Pipeline’ section, the ‘OB’ button is depressed.

I want the ‘ME’ button to to be pressed instead.

Note, that this is on the 2.49b version of Blender.

On v2.6, there’s a dropdown which has the tooltip ‘Link to material or the object’s data’ which also provides the python method ‘Materialslot.link’, which I don’t think works in 2.49. The dropdown provides two options: ‘Object’ (currently enabled) and ‘Data’. I believe I want ‘Data’ to be enabled.

Hm.

Nobody has any ideas?