0
$\begingroup$

I saw this question and learned it's very tricky to export material from Cycles for other applications' use. So let me clarify: I only work with Blender.


Previously while I was working with BI, I can export a plane as a .obj file specifying the geometry and an accompanying .mtl specifying the material, such as specular and diffuse colors, etc. If I import this .obj file back to BI, I get every setting back.

Now I switch to Cycles. I create a glossy material for my cube and export it as usual. Now if I re-import this .obj file back to Cycles, my material settings are all gone.

Before exporting

enter image description here

After re-importing

enter image description here

What is the proper way of exporting a Cycles material?

P.S.: It would be wonderful if the answer could be given from the Python API perspective. :-)

$\endgroup$
  • 3
    $\begingroup$ If you only work with blender, why not simply save as blend file? $\endgroup$ – lbalazscs Dec 27 '16 at 2:05
  • $\begingroup$ I don't want other things in the blend file (such as lighting, rendering settings, etc.) to carry over. Basically, I only want use the final blend file to collect all the objects and their material. Maybe even in this case, saving as blend file is still the best solution? Could you elaborate? Should I just build the objects in a newly opened blend file, just save it, and then append this blend file to the final blend file? Thanks! $\endgroup$ – Sibbs Gambling Dec 27 '16 at 2:09
  • $\begingroup$ If you export to other formats (like .obj and mtl) you need to bake your cycles materials/textures. Note that by doing so when you re-import them into cycles they will no longer retain the original shaders that you had created. $\endgroup$ – cegaton Dec 27 '16 at 3:20
4
$\begingroup$

Save your materials into a normal blend file.

A blend file is a database and you can use only selected parts (data-blocks) from it. This is done using linking and appending. See this: What is the differance between Linking and Appending an external blend?

This is also possible in python: How to Link/Append a data-block using the Python API?

$\endgroup$
2
$\begingroup$

As already mentioned, if you only use blender then materials can just be imported directly from another blend file.

As you are interested in a python approach, there is an old addon that may be of interest to you. The Online Material Library addon was in the contrib addons for some time but has been removed, it gave the ability to export/import cycles materials to an xml file. I still keep a copy of the addon in my git repo if you are interested in taking a look.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.