I'm not sure what you're expecting out of the venerable .obj format? It's forty years old.
However, here is a link to a post-frame script that will write a usemtl token for every g token into the OBJ format. This can allow some importers to pick up on the fact that certain face/primitives should have separate materials.
This means you'll need to convert any materials (i.e. unique s@shop_materialpath values) into groups before you export.
thanks jsmack for advice was reading about - and yes propbably gltf would be preferrable one, with some great help even managed to upload it to site (as well as obj though too)! great that you don't need separate file and loader for mtl, just only one for gltf (glb actually) ^^ thanks a lot by idea the final result cube will be near logo and logo is made with glassmorphism css effect
Greetings. I am also trying to export .obj files from Houdini. I work with a software called Virtual Crash that works with 3d model imports, and it seems materials and textures apply to the models the best after import when using .obj.
Has anyone found a solution to this at this time? The python scripted suggested does not seem to export the .mtl file still. I tested every iteration of the script in the Post-Write Script section of the ROP Geometry Output SOP.
Try this file. The old code was written for Python 2.7. I've updated the script to work with Python 3. I'm attaching a working use case HIP file. Be warned, however, that the .MTL file doesn't offer much. You might be able to transfer color, but it certainly is not a full-fledged material transport system.
Thank you for the file @Enivob! It seems your script by default exports 2 objs as well as a mtl file. Is that supposed to happen? I just need 1.
Also, it seems to break when applying uvs and a material for each primitive group. It only outputs 1 obj. I put the file I was working on before. Is it possible to edit the python script to accommodate for this?