Macro cannot export colour surface as .obj file

Hi, everyone! As a newer to the macro script, I want to export the 3D color surface as .obj file. Although the script can give the 3D view as manual operation step-by-step, no file is saved. And there is no error in the console. The code is listed as follows:

open("./Additional file 1/T010_segmentation.tif");
call("ij3d.ImageJ3DViewer.setCoordinateSystem", "false");
run("Show Color Surfaces", "use=[Create New 3D Viewer] resampling=1 index=0 radius=1");
call("ij3d.ImageJ3DViewer.exportContent", "WaveFront", "./untitled.obj"); //|--> no file is saved
call("ij3d.ImageJ3DViewer.close");
run("Close All");

I am not sure whether the problem is caused by which window is actived. Thanks for you great help in advance.

Hi and welcome to the forum!

I’m not familiar with the “3D color surface” plugin but I can comment on saving as .obj:

There is another simple way to save a binary image as .obj mesh: Activate the image, then choose: File > Save As > Wavefront .OBJ.
You can select the downscampling factor, and a threshold for binarization (relevant if your image is not binary, if it is a label image, choose a number smaller than your smallest label id, e.g. 0.5). This plugin is also macro-recordable.

Note that different labelled objects get merged into one .obj file. So if you want the meshes of different regions separately you would have to export each label-region separately. I don’t whether the .obj exporter in the 3D viewer handles this differently.