Maya Namespace and Prefix tips and tricks

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi Stephen Rozelle technical specialist with our desk and I'm going to talk about a couple of related tools today one is a tool that was added in 2011 and then updated in 2012 called the namespace editor and another is a related tool that is part of the bonus tool package under windows is called pattern rename now both of these tools actually are very similar and used for similar purposes but they actually deal with two kind of different problems two related but different problems so first off we'll talk about the namespace editor so for those of you that don't know what namespaces are they're basically groups or categories of objects that allow you to have multiple objects with the same name so oftentimes they are associated with referencing or importing of objects so you can create them yourself but oftentimes they get created for you so for instance if I were to go in and create a sphere and we'll just keep this really simple I'll save this out as its own file and we'll just call it my sphere now if I were to go to import so I'll just create a new scene I'll go over here and I'll import that bring it into my scene what you'll notice is that as it imports it automatically applies the name of the file to the beginning of the object so I have my sphere colon spirit out our sphere one so this is this is what's known as a namespace so if I were to import this same file again say I import it more than once now the sudden I'm going to get the same object but I'm going to have two different namespaces so you'll see that it's still called sphere one in both cases right there peace fair one but you'll notice that each namespace is different so I have my sphere and my sphere one so this can get really kind of cumbersome if you're not intending to use these namespaces so for instance an example would be let's say I have a bunch of so here so I'll just create a bunch of copies there and I'll just create a bunch of copies this way and now if you look in my outliner then I just have a bunch of spheres so I have sphere one all the way through sphere 42 now if I save this file out and we'll just overwrite that last file in my sphere so when I import the same file the one that just saved into my scene what you'll notice is that now I have a whole bunch of objects that all have a name space using the name of the file so I have my sphere colon sphere 29 my spherical and sphere 30 so this get really cumbersome so if you're importing a bunch of files in order to assemble a scene before you know it you have all these files with all these really long names now it even gets worse if I were to save the scene at one more time so let's just overwrite that file again so now I've actually saved it out twice over itself so now let's go in and create this again I'll just go in and do a file import now I've got my sphere so I've just imported it twice basically so now all of a sudden I've got a double name space so now instead of just having sphere one I have my sphere colon my sphere colon sphere one so this gets very kind of tedious and cumbersome the more you do this this gets amplified as you as you continue to import objects modify them re-- important and so on so most people that have used Maya have come across this at one point or another and so the simplest way of handling this is it's just part of the name even though it's a namespace it's actually just part of the name I can actually just go in here and I can select everything before that colon or rather the colon included and now I can rename that object to just fear one and I can go in here and I can do the same thing with the next object but obviously if I've got a hundred objects I don't really want to do that with every object the other thing to point out is that all of my textures all of my lights all of my nodes in general will all have this the same situation so you'll look here you'll see that in the channel box I have the transform that is my spherical in my sphere colon and then you have the shape node which is my spherical in my sphere colon anything that's added to this object will have that same that same namespace so long story short is there needs to be an easy way to go in and address this and to clean this out and now there is so that's where the namespace editor comes in so in the past in order to deal this you deal with this you that had to do it manually or you had to go in and you had to use Mel basically write scripts or manually use Mel to get rid of your namespaces so if you go into the general editors here under namespace editor it will list all the namespaces in your scene so you'll notice that I have my root namespace which is the highest level and then I have my sphere and then another one parented under that called my sphere so what I can do is go in and I can take everything within this namespace and I can list the contents of that namespace and that will show me everything it exists within the namespace or I can go in and I can do things like selecting all the objects within that namespace so you can see that everything within my sphere has been selected but what I really want to do in this case is just do something really simple like basically take everything in this namespace select it and then say move it to a new namespace so I'll just take it to that new namespace and I'll just say add selected and now you'll notice look in the channel box everything that had those namespaces has been moved up to the higher level so now I basically have these empty namespaces these are actually doing nothing now they're still in my scene technically but they're not actually doing anything so one other thing I can do is I could say select all empty namespaces and then I can just delete those namespaces and there we go now I'm back to where I started where I have a single namespace so now all these objects have their original names back so here's another example where I've just created a bunch of objects and imported them into my scene you can see I have my cubes which in the cube namespace my spheres which are in the sphere namespace and my cylinders which are in a syllable name space and then torus which is in the root namespace which basically means there it's not in a namespace so you can also shift things around within namespaces so for instance I can come in here under my name space editor and it'll list everything in my namespaces I can grab my sphere name space and I can select the contents of that that'll select all the spheres and then I can actually move those to the cube namespace so I'll grab cubes and I'll just say set the current and then I'll say add selected and now you'll see that all the spheres are now within the cube namespace so the cubes names we can do the same thing with the cylinders come in here select the contents and move those add rather and now cylinders are all within the cubes namespace so if you have lunch namespaces that you're actually using for organizational purposes then you can easily shift things around with its namespaces now another thing that we can do is we can create namespaces just for just for your own reference here let's actually just start over here and I'll just go into the new place editor and right now you can see if I create an object to create a sphere and I go into the channel box it names it sphere if I create another object another sphere that is now it names its fear and just changes the number at the end so again the advantage of namespaces is you can have objects with the same name in different namespaces so what I could do here it's I could go in here and create a new namespace and I'll just call this I'll just call this my namespace for lack of a better word so now that becomes the current namespace in time you see that green light it means it's the current namespace so if it actually let's just go ahead and create another one here let's create a new one and we'll just call this second namespace there we go so now whatever one has the green light is the active one so I could set that to be current or I can set that to be current once you create an interface and it becomes the current namespace now anytime I create an object it will be created into that namespace so now when I created that sphere it get created into the second namespace if I were to go in and make this one active woops set that to the current and I'll just create a cube that cube as it gets created gets added into my namespace same thing with a light any node that I create so if I create something like a light that light gets added into my namespace so that's true with any node in my whether it's a texture whether it's a camera or a light or whatever it may be so that pretty much wraps up the namespace part of the discussion let's talk about prefixes now so as an alternative to namespaces you can also create something that's called a prefix so if I were to go in and actually let's just create a sphere here and we'll just leave it with the default name and I'll just save this out as that original file that I created so I'll just save as my sphere and now I'll create a new scene and this time I'm going to import that file and when I import the file instead of using namespaces this is the import options here you can see that by default it's going to import using namespace and it's going to use the file name for the namespace now if I had an existing namespace I could use that I don't but you can check this off and if I turn off use namespaces then what it will do is it will basically use prefixes so now it will resolve all nodes with the file name as a prefix so if I import that file and now I take a look in the outliner what you'll see here is that instead of a colon separating my two names now I have an underscore so I have my sphere underscore peace fear 1 so if I were to do the same kind of an import twice same idea bring in that sphere now I have my sphere underscore P script - so now it's using prefixes instead of namespaces if I were to do the cube example if I import this cube it's going to take the name of the file my cube and the name of the object and basically splice them together so this also gets very complicated and this can happen in different scenarios so oftentimes when you're dealing with different data translators like certain CAD translation tools will actually append a whole bunch of these prefixes onto your objects and in and the same way that namespace is going to get cluttered these can as well so if I take this file right here and I were to save this out let's actually just save the scene as just call it my objects create a new file once again all using that option I'll just import my objects and now the sudden I get additional prefixes added on so now let's actually go in and create some copies of these let's just create maybe some copies here and some copies there and all of a sudden I've got all these objects with a bunch of prefixes on them and then it can even get worse so save this file out overwrite my objects so we'll just overwrite that same file called my objects so now I've got a bunch of extra objects in there so when I do the import same idea as before it's importing all this files and concatenating or rather adding on a new prefix so again it's a similar concept to namespaces however the problem is it's not a namespace so if I go under general editors here and I open up my namespace editor I don't have any namespaces so I cannot use this editor in order to clean this up so I could manually go in and clean this up but that gets to be very tedious so what I can do instead is use this handy little bonus tool under windows called pattern rename and pattern rename allows us to essentially go in and create some search patterns and replace patterns for the objects in our scene so for instance I noticed that my objects is repeated here several times so what I can do is I can go in here and I can say my objects I want to every time I find my objects I want to replace that with nothing so I'll add that as an option here actually first of all I need to load all the objects into this so I can actually see it so there we go I just first of all had to go in and load all the objects into this list right here so these are the objects I'm going to be working on so let's try that once again so I'll do my objects I'm going to replace that with nothing so I'll add that and now I'll do another one actually that should have been my objects let's do it one more time third time's the charm my objects replace that with nothing I'll add there we go so now I've found it so now this is what it's going to end up looking like so now I can also go in it hasn't actually done it yet it's just giving me a preview of what it's going to look like so now I can go in and I can say my sphere I want to replace that with nothing now you'll notice it's getting rid of all the my spheres and I can go in here and I can say I want to replace my cube with nothing and now let's end I've got a bunch of objects with underscores so now I have to figure out what I want to do with those underscores so instead underscores its one-two-three underscores now what I want to do is replace that with maybe a specific prefix so I'll just call this test with an extra underscore so I'll add that so now this is what's going to happen to all those objects so I'm going to go from this that you see on the left see this very simplified version over here that you see on the right so I'll just say rename and now it applies all this so I'll put a later date I just had well I really don't want the test prefix on any of these I can just go in here and just remove all this stuff and I'll just say I want to take tests and I want to replace it with nothing it's actually refresh that and actually I forgot the underscore - I can just create a separate one for that and now I'll rename and now I have all the base names from my object so again it's a very similar problem to the namespace issue but it's it's a different way of approaching it and kind of complementary tools so at any rate I'm going to also post another video that was done by roland ryr who's the guy that wrote this tool that goes into a little bit more detail about how this works but that should give you a general idea of how you can use it
Info
Channel: My Oh Maya
Views: 55,084
Rating: undefined out of 5
Keywords: Autodesk, Maya, 3d, demo, M&E, modeling, animation, texturing, rendering, effects
Id: 4DbWh1Rgs6s
Channel Id: undefined
Length: 14min 35sec (875 seconds)
Published: Tue Dec 13 2011
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.