Blender Underground

Away from the watchful eye of The Man
It is currently Wed Jun 19, 2013 11:02 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 50 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Creating libraries for reuse of objects
PostPosted: Sat Apr 19, 2008 3:13 pm 
Offline
Director
User avatar

Joined: Thu Sep 06, 2007 8:17 am
Posts: 5144
Location: West Virginia, USA
We here at BU have had to answer this question more than once so I decided to post a tutorial on how to reuse objects such as material and meshes in Blender. Also covered will be the advantages and drawbacks of linking vs appending. So without further ado, here we go... 8)

In order to understand the concepts I am going to present in this tutorial, it is necessary to cover some preliminary topics first namely append, link, relative paths, static paths, groups and the structure of a blend file.

DEFINITIONS:
APPEND - The act of copying an object from one blend file to another. Edits to the original do NOT reflect in the copy.

LINK - The act of a link from one object to another within blend files. Edits to the original DO reflect in the linked object.

RELATIVE PATHS - A file path that is relative to the location of the currently opened blend file. Relative paths are expressed as "dotted notation". (../../) Relative paths require an initial saved state to determine the start off location.

STATIC PATHS - The full path name to the blend represented like such "C:\Blend Files\..." Static paths do not require an initial saved state (although it is recommended as a "good practice").

GROUPS - The act of combining multiple objects into named groups treated as a single object. Groups include animation IPOs, meshes, materials, and any associated coding of the group such as modifiers.

The theory behind libraries (and reuse in general) is to make objects from one blend available in another. Consider how hard it would be to have everything from a large production like Elephant's Dream in one blend file. Everything from the meshes to the textures to the animations all in one blend. Confusion would quickly set in. Also in collaborative efforts like Elephant's Dream it is impossible to keep up with edits to individual objects when you have 20 or more people trying to work on one blend file. Enter append and link. They are related but different concepts.

Append will bring in a copy of the object. An appended object is a stand alone object that can be edited without effecting the original object. What this means is that if you append a red cube and change the material color to blue in the original blend, the appended cube will remain red (until you change it in the appended file). The advantage of an appended file is portability. You can safely give out the appended blend and the recipient will be able to open it unfettered. Append is the default mode for Blender.

Linking files require both files to exist in a specified location and that the linked object name be the same across edits. A linked object maintains a link to the original object allowing edits to the original to be reflected to all the blend files that are linked to it. This is where the need to specify the path type comes in.

A static path will link in such a way that the entire path to the linked file is given. Static paths are not transportable to other users unless they share the same directory structure (example, networked environment).

Relative paths are paths that are based on the location of the target blend file. It uses dotted notation to show the relative location. To use relative paths you must first save the target blend file so Blender knows where to start.

In both cases, append and link, grouping objects together is the preferred method to use because it allows for easy appending and linking. Planning needs to be implemented so that groups can be defined during creation of the original. Then it is just a matter of appending or linking the group instead of the potentially thousands of objects the group could represent. Groups also retain animations and deformations to meshes making importation of rigged characters a breeze. ManCandy is a perfect example of grouping.

To begin the process we are going to do a simple static append of a material since this is the most common question asked here. You first need a blend file that has the material you want to reuse. Here is one I found on the net and use on a frequent basis:

http://blenderunderground.com/files/use ... rary.blend

The first thing you should notice once you download and open that blend is that it is simply a group of spheres each with different materials. The materials all have a meaningful name to make the append easier. Since this is simply a material library, it is unlikely you will append all the materials so no groups were created (although you could group according to type and then append a whole category such as METAL which would bring in all the metals). Below is what you should see when you open it:

Image

Let's note that I didn't create this library but downloaded it instead. Credit doesn't go to me for it. It goes to Andrew Kator & Jennifer Legaz and their wonderful Blender site:

http://www.katorlegaz.com/3d_models/index.php

We are now going to open a new session of Blender giving us the default cube. We will assume at this point that the default cube is a mesh that you have been working on for weeks and is a gorgeous representation of an object that a human can come up with. The only problem with it is it is all gray... :P

Time to append: Click "File" then choose "Append or Link" from the resulting menu. Alternatively you could simply press "Shift-F1" to get the append or link file browser window:

Image

Let's pause here and look at this dialog for a moment. The first button will make this window full screen. This can be handy if realestate is at a premium on your monitor. The next set of four buttons are the sort order for files and directories. The next buttons are to toggle long info, hide dotted files (those are hidden files by default), append or link. Long info will show a single list that scrolls and gives extra info about the files such as creation times / dates, size, etc. The toggle of that just gives the file name. Hiding dotted files will show or hide normally hidden files. On linux machines dotted files litter the home filesystem that this list can be huge if not hidden. .blender is an example of a dotted file (folder in this case). Lastly, append and link buttons will choose between append an object or link to it.

At this point I'm going to note a difference between Blender 2.45 and Blender 2.46 (aka 2.45.16 or SVN). Blender 2.45 doesn't allow choosing between relative or static paths in the append dialog as shown above unless you save the file first. SVN adds this functionality with the "relative paths" button without saving first but that isn't a good idea.

Image

Next, browse to the newly downloaded KL_materials-library.blend file you just downloaded and open it. You are then presented with a new type of tree:

Image

As you can see, we now have every object that is available for appending. We want to append a material so click the Material folder. It then shows the available materials all ready to append. Notice that this material library has quite descriptive labels for the materials. This is why most tutorials stress giving objects good names upon creation. Many a Blender user has been bit by this omission and quickly learn their lesson when they are condemned to finding a desired material out of a list that reads "Material, Matarial.001, Material.002, etc...". The same can be said of meshes, armatures, the works! Don't fall for this trap. Name your objects upon creation so you don't have to live this nightmare.

The material I want for this cube is a nice gold polished look. I switched the listing by clicking off the "long info" toggle. Scroll down until you locate "METAL Gold Polished". When you click it, Blender will fill in the filename in the box at the top. Clicking "Load Library" will load the material into our target blend and close the file dialog box.

Image

At this point, it doesn't look like anything happend but it did. Go to the shadings buttons (F-5) and select "METAL Gold Polished" from the material selection dropdown box. Viola! A gold cube we all can be proud of!

Image

Because we appended this, changes to the gold material won't affect the library or changes to the library gold material won't affect this material. So what about an object that we want to change and have the changes reflected across all the blends that use that object? More, what about grouped objects? That is where we want to link instead of append. For this part of the tutorial we will use the ManCandy 2.0 blend file.

http://blenderunderground.com/files/use ... _2.0.blend

ManCandy is a fully rigged character that you can use freely. It is covered under the Creative Commons license. More info on ManCandy can be found here:

http://orange.blender.org/blog/mancandy-updated/

Because ManCandy is a constant and complex work in progress, it would behoove us to link to it so that updates can be handled easily without having to update our animation blends the hard way. Start by downloading the blend above. Save it to a convenient place (in my case, since I have the ManCnady FAQ DVD in my home directory, I will use it as the root path {meaning "/home/penix1/The Mancandy FAQ/"}). Just like append, we will be using a new blend file this time deleting the default cube. We will be using relative paths for the link so when you open the append or link dialog (Shift-F2) select "relative paths" and "Link". Before we do this though, we have to save the blank blend file so that Blender knows where to start. I saved it as "ManCandy_Animated" in my "/blends/working" directory. Now we can link to the ManCandy blend. Follow the directions for Append above except select the "Relative paths" button and "Link" instead of "Append". Also, since it is a group we want to link to instead of browsing to materials we go to group and select the mancandy group.

Image

Image

Again, it looks like nothing happened when we clicked the "Load Library" button but in fact it did. If you look at the outliner window you will see that it is now full with objects all having the "Li" icon indicating they are linked.

Image

Since we are in the outliner, now is a good time to show you how to change the location of the linked file if an update comes along or you move the linked file somewhere else. Selecting "Libraries" from the view dropdown next to the "Search" menu item will show the location of the path and file name of the linked file. To change it simply CTRL-Left-Click the file name and using dotted notation type in the new location. Dotted notation is relative to the location of the blend file you have open. ../ (or ..\) indicated moving up one directory level. It takes some getting used to but is really worth the effort in this case.

Image

To get ManCandy in the 3D window we need to add it just like we add a mesh (spacebar) except we select "Group" then "Mancandy_2.0" then "ManCandy". At this point we have the mesh in but we can't animate it without having the armature to do it with associated.

Image

To do this we need to add a proxy. CTRL-ALT-P brings up the add proxy menu. The ManCandy rig was purposely setup to list the CandySkel as the first item in the long list. This is where planning comes in during creation. Select "CandySkel" and you see the armature come in.

Image

Lastly is the association of the armature to the mesh. Select the mesh then Shift-select the rig and press CTRL-P Parent Object. The last thing to do is select the armature and switch to Object buttons (F-7) turn on wire mode and xray. As a bonus turn off "Relationship Lines" in the view properties. We now are ready to animate.

To review...

Append copies objects from one blend to another. Link joins objects from one blend to another. Appended objects don't translate edits across blend files while linked does. That is really all there is to it. Happy Blending...:P

_________________
Life is an illusion....It's the magician you have to worry about!


Last edited by penix1 on Thu Jan 15, 2009 4:12 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 19, 2008 10:35 pm 
Offline
Director
User avatar

Joined: Sun Sep 02, 2007 6:56 pm
Posts: 3356
Location: Sacramento, Ca
This looks great! I'll go through it tomorrow when I have more time. 8)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 20, 2008 1:55 am 
Offline
Agent
User avatar

Joined: Sat Sep 29, 2007 1:41 am
Posts: 254
Location: Denmark
This is good stuff :D

I've just managed a quick run through but i'm comming back for more.

Thanks and well done Penix1

BTW to my knowledge you can only have one ManCandy in the scene if you use the Link method.
Is this true?

-Gnuren


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 20, 2008 2:12 am 
Offline
Director
User avatar

Joined: Thu Sep 06, 2007 8:17 am
Posts: 5144
Location: West Virginia, USA
Well, I see one glaring omission. I didn't go into how to create groups but I guess that can be for another tutorial. Aside from that and some minor grammatical errors I corrected, I think it is OK. If anyone has changes, now is the time to pipe up.... :P

_________________
Life is an illusion....It's the magician you have to worry about!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 20, 2008 2:21 am 
Offline
Director
User avatar

Joined: Thu Sep 06, 2007 8:17 am
Posts: 5144
Location: West Virginia, USA
Gnuren wrote:
This is good stuff :D

I've just managed a quick run through but i'm comming back for more.

Thanks and well done Penix1

BTW to my knowledge you can only have one ManCandy in the scene if you use the Link method.
Is this true?

-Gnuren


I'm glad someone liked it... :P

The answer to your question is no it isn't true. You can have thousands of them.

Image

The only caveat is duplicate (Shift-D) doesn't work which means you have to follow the procedure of adding (Spacebar) onwards in this tutorial. Would be handy if you could get Shift-D to work. :?

[EDIT]

I take that back Shift-D does work! I have no clue why it didn't for me the first time I tried but it did when I was trying to find a way to make it work. I guess I beat it into submission... :P

_________________
Life is an illusion....It's the magician you have to worry about!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 4:24 am 
Offline
Agent
User avatar

Joined: Sat Sep 29, 2007 1:41 am
Posts: 254
Location: Denmark
Great, thanks!
I'll have to try this out.

-Gnuren


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 04, 2008 9:38 am 
Offline
Director
User avatar

Joined: Thu Sep 06, 2007 8:17 am
Posts: 5144
Location: West Virginia, USA
I just went back and revisited the FAQ and it has this to say about proxies:

Mancandy FAQ wrote:
Blender allows you to create a library file and make as many links from it as you want; you can also link a group, make a proxy armature for it, and use that proxy to animate in your scene files. There is a catch: If you do this, you cannot create another instance of the character and animate it with a different proxy in the same scene. I ran into this problem in the ending animation for the Mancandy FAQ where I wanted to animate two identical sperm.

The solution is not very hard. If you're on MacOSX or Linux (or any Posix compliant OS) the solution is simple. Just make a symlink from your library file to a new file - for instance:

ln -s blends/lib/sperm blends/lib/shperm

You can now link the same group from the original file sperm.blend, and from the symlink, shperm.blend, and make proxies for both. Furthermore, if you edit sperm.blend, the symlink will update automatically, and both sperm will change.

If you're on Windows, you can still do this somewhat, with a bit more work. Just make a copy of the file sperm.blend and name it shperm.blend (this is how it is in your lib files on the DVD) It will work exactly the same why- you just have to remember to re-copy every time you update the library file.


I am checking to see if SVN suffers this issue. You would think by now they would have it solved.

_________________
Life is an illusion....It's the magician you have to worry about!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 08, 2008 12:08 am 
Offline
Asset

Joined: Thu Jun 05, 2008 5:26 am
Posts: 43
lovely tutorial! thx!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 08, 2008 10:00 am 
Offline
Asset

Joined: Thu Jun 05, 2008 5:26 am
Posts: 43
Darn, I didn't manage it. Did everything, but the material didn't apply to the cube. Why am I having problems all the time, like omg :S


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 08, 2008 6:21 pm 
Offline
Director
User avatar

Joined: Thu Sep 06, 2007 8:17 am
Posts: 5144
Location: West Virginia, USA
Check to make sure you are appending and not linking. Materials are appended not linked. Once in, simply go to the materials panel and select the material you just imported. If your Blender is working, it should be listed if you followed the material append part of this tutorial.

_________________
Life is an illusion....It's the magician you have to worry about!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 08, 2008 8:01 pm 
Offline
Asset

Joined: Thu Jun 05, 2008 5:26 am
Posts: 43
But how do i select the imported material?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 08, 2008 8:01 pm 
Hey penix1,

Did I thank you for this thread already? If not, here's a great big Thank You. Not only did you supply me with an incredibly useful start to a Material Library, you pointed the way to a prodigious amount of power in this program. If I take the time to model the perfect fly, why, I can use him somewhere in all of my work... a sort of running gag, if I choose to.

I haven't really even started to make use of the append/link command, so I'm really ignorant of all it can do, but I have to say it really made modeling faster, more enjoyable and much more creative. So, thanks again.

Mike


Top
  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 3:03 am 
Offline
Director
User avatar

Joined: Thu Sep 06, 2007 8:17 am
Posts: 5144
Location: West Virginia, USA
@ doodlebug,

After you append the selected material it looks like Blender didn't do a thing but it did. The next step is to go to the shaders tab (F5) and select the material from the materials drop-down menu.

@ illegible,

Yes, this is the power at your fingertips that Blender gives. The choice to append or link is one you will have to make and plan for. Many new Blender artists just want to sit down and model often recreating the wheel when models exist already for what they want. Ever create that just so-so model and thing to yourself, "gee, I sure could use model Z right about now". Well, here is the solution.

Anyway, thanks for the kudos and happy Blending... 8)

_________________
Life is an illusion....It's the magician you have to worry about!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 5:21 am 
Offline
Asset

Joined: Thu Jun 05, 2008 5:26 am
Posts: 43
i don't find the place where to select the material, could you post a picture? Please.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 7:34 am 
Offline
Director
User avatar

Joined: Thu Sep 06, 2007 8:17 am
Posts: 5144
Location: West Virginia, USA
The steps are as follows:

1. Click "File" then choose "Append or Link" from the resulting menu. Alternatively you could simply press "Shift-F1" to get the append or link file browser window

2. Browse to the newly downloaded KL_materials-library.blend file you just got and open it. You are then presented with a new type of tree

3. Select "Material" in the resulting menu and browse to the material you want to use.

4. Click "Load Library" to load it into the target blend.

5. Assign to object the new material in the Materials panel of the buttons window (F5).


That's it.

_________________
Life is an illusion....It's the magician you have to worry about!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 50 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Translated by Xaphos © 2007, 2008, 2009 phpBB.fr