The imageobject attribute specifies a path to a file that should be loaded when 3D media is loaded.
When you modify the value using the UI, it calls autoloadallmedia(object) to load any specified media files for that object into the loaded media list, including the specified texture file path on the imageobject attribute.
If you want to programmatically set the texture and load it, then you can set that attribute and call autoloadallmedia(object) in your code.
The texture that is drawn in the 3D view is based on the imageindexobject attribute. Each 3D shape, texture, or sound in the media list has an index that is used to reference it. This index changes depending on the order that the media is loaded. Use the following code to set the imageindexobject attribute to the texture index for the file specified on the imageobject attribute.
myObj.attrs.imageindexobject.value = gettextureindex(myObj.attrs.imageobject.value);
If you want to dynamically change a texture while the model is running, you should load that texture into the media list first, and then just change the imageindexobject attribute to point at the texture you want to draw at any given time. You don't want to call autoloadmedia() while the model is running.
You can load the media into the media list using the Preloaded Shapes and Images window from main menu option View > Media Files.
You can then change to one of those loaded media files using similar code as above. For example:
myObj.attrs.imageindexobject.value = gettextureindex("path\\to\\mytexture.png");For the gettextureindex() command, use the path shown in the Preloaded Shapes and Images window.
Here's an example of these commands:
Object myplane = Model.find("Plane7");
myplane.attrs.imageobject.value = "modules\\ProcessFlow\\bitmaps\\image.png";
//autoloadallmedia(myplane);
myplane.attrs.imageindexobject.value = gettextureindex(myplane.attrs.imageobject.value);