Request: Material save/load feature

The interface, modeling, 3d editing tools, import/export, feature requests, etc

Moderators: jesterKing, stiv

bannerboy
Posts: 0
Joined: Sun Sep 05, 2004 1:18 am

Request: Material save/load feature

Post by bannerboy »

Ok, mabe this idea has already been thought of, but I think it would be nice if there was a way to save a material to a seperate file, so that it can be used in another model, without having to use append, and find the material.

gabio
Posts: 0
Joined: Thu Jan 15, 2004 6:41 am
Location: Canada - Québec - Sherbrooke
Contact:

Re: Request: Material save/load feature

Post by gabio »

bannerboy wrote:Ok, mabe this idea has already been thought of, but I think it would be nice if there was a way to save a material to a seperate file, so that it can be used in another model, without having to use append, and find the material.
yes. i though about a way to save all the datablock in blender with a python script that would just do a dump of memory in a file and then load it back in. I don't know who to dump binaries. I know how in C though.

A possible projet. But need feedback on the idea first.

z3r0_d
Posts: 289
Joined: Wed Oct 16, 2002 2:38 am
Contact:

Re: Request: Material save/load feature

Post by z3r0_d »

gabio wrote:
bannerboy wrote:Ok, mabe this idea has already been thought of, but I think it would be nice if there was a way to save a material to a seperate file, so that it can be used in another model, without having to use append, and find the material.
yes. i though about a way to save all the datablock in blender with a python script that would just do a dump of memory in a file and then load it back in. I don't know who to dump binaries. I know how in C though.

A possible projet. But need feedback on the idea first.
use the struct module in python to do that kind of stuff

or, probably even better, the pickle module

a blender internal way would be preferred though

bannerboy
Posts: 0
Joined: Sun Sep 05, 2004 1:18 am

Post by bannerboy »

Yeah, I'm one of those people who likes to reuse stuff like good textures in other models, and this would make it a lot easier.

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

It might help if you can state what you find wrong with the current system?

Is it that you have to trow away all the data you don't need and save what's left over? Or do you rather select the parts you want and save that.
I don't see why it should be a different file format then .blend (except for notepad editing).
I can imagine something like selecting datablocks (be it material or object) in something like the outliner and use "export" to save only the selected data to a blender file. Sure you still need to 'browse' truw the data on import, but maybe the import can have a append file option that appends everthing.

levon
Posts: 0
Joined: Thu Jul 31, 2003 6:06 am
Location: adelaide

Post by levon »

i guess this could all be done with python. in the same way that the current load and save themes is done. though im not sure if all the python hooks are in there, mainly for the textures, but it shouldnt be to hard (im not volunteering) :P

bannerboy
Posts: 0
Joined: Sun Sep 05, 2004 1:18 am

Post by bannerboy »

I guess what I was thinking is that you have a button right there in the material buttons to save/load just that material to a seperate file. it doesn't matter if it's .blend, .mat, .tex, or whatever you want to make it. I hope I'm making sense, mabe I just don't know enough about blender.

levon
Posts: 0
Joined: Thu Jul 31, 2003 6:06 am
Location: adelaide

Post by levon »

what you are asking is easily done in python, i just wont be the person doing it

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

I rather not see it in python.
Before you know it we have alot of different file formats that are not backward or forward compatible. Using the blender file system makes sure it's forward compatible. I.e. the material you save today will be loaded by the blender of tomorow.

bannerboy
Posts: 0
Joined: Sun Sep 05, 2004 1:18 am

Post by bannerboy »

Is there a way to choose what is stashed in the .blend file?

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

bannerboy wrote:Is there a way to choose what is stashed in the .blend file?
Not by the user.
You have to save the file. Remove all objects. Fake user the materials. And then save the file with material name, load it, save it, load it, save it (until all input relations are gone). The e-shop texture disc has a view of thoose materials.
In that perspective it's easier to make a python script (as levon says) that saves an xml file ( or fbx :P ). Maybe that's more realistic.

Should not be hard for the writefile function to only save materials and connected inputs, I think.

bannerboy
Posts: 0
Joined: Sun Sep 05, 2004 1:18 am

Post by bannerboy »

I understand how to do it now, but I still think it would be nice to have a more direct way to save a .blend file with just the material information.

theeth
Posts: 500
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Post by theeth »

Actually, regarding doing it in Python, this could still use the blend format by working this way:

Save the current file
Strip everything except materials
Save under a new name
Load old file

Given Blender's snappy load and save, this would be rather instantanuous.

Martin
Life is what happens to you when you're busy making other plans.
- John Lennon

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

theeth wrote: Given Blender's snappy load and save, this would be rather instantanuous.
Martin
You have a lot of scenes with only a few cubes, right? :P

I don't think saving speed is an important issue to this matter.
It's sounds much faster and accurate then doing it by hand.
bannerboy wrote: I understand how to do it now, but I still think it would be nice to have a more direct way to save a .blend file with just the material information.
I agree, it's makes building a library much easier. And it shouldn't stick to materials, it could be objects, lightsets, anything.
Add a menu with cool little icons that import this stuff and you have the bryce that alot of people want blender to be. :)

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

theeth wrote:Strip everything except materials
Any idea how to do that? I can't find any
done = Blender.Object.Delete ('Camera')

=edit=
Ai, wait... unlink and saveloadsaveloadsave() !

Code: Select all

import Blender
from Blender import Scene, Object, Types

Blender.Save("tmp.blend",1)

sce= Scene.getCurrent()

lst= sce.getChildren()
for o in lst:
	data= o.getData()
	if type(data) != Types.MaterialType:
		sce.unlink(o)


Blender.Save("mat.blend",1)

Blender.Load("tmp.blend")
Blender.Redraw()
This would work if blender knew what Blender.Redraw() is after a .Load

Post Reply