Add transcription for: frames_zips/CGCircuit_RiggingCartoonRealistic_DownloadPirate.com.part5_week08 05 reset ctrls script_frames.zip
Browse files
transcriptions/frames_zips/CGCircuit_RiggingCartoonRealistic_DownloadPirate.com.part5_week08 05 reset ctrls script_frames_transcription.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"text": " In this video I want to write a script with you to reset all of the controls. I think this is very very useful because... Let's set this to reference here. Because if you're like, often times you know you're playing with the rig, you're testing out stuff and then it's very easy to forget to reset certain things, especially if you have like very very small values on it, like something like that. But now if you're doing parenting or un-parenting or so on and so forth, you can get into trouble really easily if your rig is not reset to the default controls, everything's erred out. Because it can mean that if you're deleting history or you're freezing certain things or you're un-parenting, then you're getting false information here. So you should always, when you rig, have everything back at zero. And as I said, now that I've moved a couple of things, it might be OK. This is obvious. I have to reset this one. But the other things that I made, the other changes, they are not so obvious. Like there are small, small values in here and small, small values in this one. And also, I think some values on here. So they might not be easy to spot to reset them. Therefore, it is good to have a script that can do that for us. I want to show you a way how we can try to write or try to go about writing such a script. First of all, what we want to do is, and it also illustrates actually a little bit the need for consistent naming. So first of all, what we want to do is we want to get all of our controls here in our scene. And since we're hopefully consistent with our names, we can just say star CTL in my case. That's what we also had before I select my name star CTL. that should select all the controls here. We can also put that into a variable. So with Mel, I don't know how many of you guys are familiar with Mel. I think most of you are familiar with scripting. And you can do the same thing in Python too. But for those of you who don't, this is really meant for you guys. So first what we want to do is we want to list, so LAS, everything that ends with star, star CTL. And we had to put it into these speech marks or quotes here. What this will give us if we run it, and we can run this in case there are some of you who have never scripted before, the script editor, you bring it up from here. And you go into a melt tab here. And then you just run this command LS. I can make this move a little bit bigger. LS, and then quote star underscore CTL quote. And then see me colon. And if we're running this, it will list all the controls in our scenes. It's very similar to what we just did here. Only that here it selects them. But now with this command, we can do certain things. For example, if we do select minus r, for replace whatever is currently selected, and we put that into the single quote lines here, which is, it is on my keyboard, it's right under the escape. It's right where the tilde key is also, right above tap on my MacBook Pro for you. It might be somewhere else. If we're running that now, this means select anything that is returned from this command. So this command, you can see it returns certain things. It lists all the commands. And we can say, select all the controls, select all the results of that. So this would be this command. Now what we can do is we can put it into a variable. So we can, for example, say a string $controlList. And then we have to write these curly brackets equals. And if we're running that, now this will be, all of our controls will now be in that variable, in the control list, in a control array. If we now go down here and we say print, control list, then we can see it prints all of the controls that are in our scene here. Everything is in that variable. Now what we can do is we can say for each control, for example, control in control list, we can do something. So we need the curly brackets here. These are regular brackets for the for loop. And then we can do something inside these curly brackets. For example, we can do the same thing, but we just said we can say print control $control that variable. By doing so, it will print all the controls at the moment. It will print them one after the other. But if we want to have to min a new line, then we can use this backslash n. So now we'll print a control, and then we'll print a new line afterwards, or put a new line. So if we clear this out and we run it, you can see now it's printing all the controls. And we can say, for example, we can print something else. We can print control, colon, and then the control name, and then a new line. So now we have control and then control that name. Obviously here we don't want to print it. What we want to do is we want to find all the attributes that on each of these controls. So to do that, there is a command called, I think it's called, I have to remember. I think it's called channel box, cable, I believe. And if we try one of those controls to see if it works. User defined. I thought it was ChannelBox. Maybe it's List Attributes. We go into the Maya help. Let's try to find. Actually, you know what? I usually use Google for it. I usually type in my ML channel box to just find a command for a channel box command auto desk. And then here we have what we can use. And some examples down there. So main list connection. I think that might have been what it was. I mean, now... I think I was thinking of something else. I've used that one here before too, but I think I've used it for something else. So let's try list attributes instead. That's, I think, the right command we need here. So list attribute, for example, on this control of the eyes. So this lists all the attributes that we can possibly have. So if you're using the connection editor, for example, or you're looking at it in a node editor, you will see all these different attributes that this object can have. This is not what we want. We don't want to reset all these attributes. We only want to reset the attributes that the animators could potentially key frame. So let's try list attributes-key. That should give us a shorter list. Actually, it only gives us the attributes that are in the channel box if we try something else. And let's try without that specific name here. Let's just list the attributes on what we have selected on the body control. If we run that, we can see it's translateX, translateY, translateZ, rotateX, yZ. Then the underscore here, that's separator attribute. And volume preservation, our custom attributes are in here as well. So you can see this lists all the attributes that are inside the channel box, list attributes dash k. And if we give it a name here in the end, a control name, then it lists the attributes for that specific control. So what we can do is list attributes and then control. And we can put that also into a variable. So we can say, for example, string attribute $attribute list with the square brackets here, and we give it that result. And then we can do something for each of these attributes. For $attribute in attribute list, do something. Put that into color brackets also. Now, for example, print all the attributes. We can, for example, print the control that we got from here earlier, then plus a dot plus the attribute. $attribute. And then what we probably also want to do is we want to print a new line, so plus and then a backslash n. Now if we clear this all out and we run this, now we'll print for each control, you will list all the attributes and then we'll print a control name plus a dot plus the attribute and then a new line, and then we'll go on and print the next that same control, that attribute, and so on and so forth. OK. Now let's try to, now we want to reset all of them, right? For resetting, or resetting them to zero, essentially, zero. If we enter zero, we can see this is the command for setting an attribute to zero. So if we just copy that in here, instead of printing it, we can maybe keep the printing. Let's comment it out for now, in case we might want to print it later on for debugging. So set the attribute and instead of hard coding it here, we're going to replace this with the control plus a dot plus the attribute name. Attribute. Like so. This means now we're setting all the attributes to zero. If we try to run it like this, we will probably get an error somewhere. We get an error here. Set attribute, the attribute L foot control, underscores is locked or connected and cannot be modified. So that is because we have this locked. So what we should do is we should build in a check here. should check if the attribute is locked first. And we can do that with if get attribute. Actually, is that the right one? Let's see. Let's test it out down here, get attribute. It's been a while since I've wrote that. Get attribute minus L. Let's see what we get from that. we get one, so that means it is locked. And we can try another one. We can, for example, try rotate x, and that should be zero, because that shouldn't be locked. Zero. OK, so this is the right one. So we want to say, if get attribute is locked, so minus l, if it's one, or if it's zero, that means it is unlocked. If it's one, then it will be locked. So that means we can write it like this if it's zero. What we can also say is, without even that equal equal zero, we can just say, if this is, then it will only do it for locked attributes. We can say print is locked or something like that. Print is locked. Else, otherwise, if it's not true, if it's false, then it should set that to zero. So now if we run that, let's see if we get an arrow here. we get another error here because it is locked or connected. In this case, we have the thumb control visibility connected. We connected it to something else. In this case, it is not locked. But the visibility here is connected. Actually, this is probably something that we should lock and hide anyway. I think I forgot that here on all these finger controls, we haven't even locked all the scaling and all that stuff. And translation, not sure if we want to keep all of that. But the visibility is probably something that we could lock for sure. And then we would eliminate that arrow here as well. So maybe we should lock. And it seems to be only on a thumb. I think I did it on the other ones. But let's also look at how we can catch that arrow here as well. There are also a couple of different methods. And you know what? This is actually too long for me. I don't want it to write as locked. I don't care. I just want it to ignore it. So instead, what I want to do is, if is not true, so we can write it with an exclamation mark. And then we can set that here. And we don't need the else statement. So now this means if this is 0, so this with the exclamation mark in front means it's false. This would be the same as writing equal equal 0. It's false. It's not true. This means if it's one, if the result here is one, then do that. But we want if the result is zero, if it's not true. So then we write it with an exclamation mark in front. And this will be the same thing. So we will probably get the same error here. Thumb, root, control visibility is locked or connected. Here the key is that it is not actually locked. Otherwise it wouldn't do it, because then it would be locked. So if we're locking this now, or just lock it, and we run it, then it probably doesn't trip over the same arrow anymore. Now the thumb on the other side is locked, but not the one on the right. Maybe this was the same one. And we have another problem here, too. Let me undo a couple of times. We have another problem here, because it's also going to put the scaling here to 0 as well, which is why the thumb disappeared. It's putting all the attributes to 0. So that's probably also not good. So what we should also do is we should build in a check. If, so let's put another collie brackets in here. We should probably also build in a check and say, if it's scale, or if there is scale in the name, then set it to 1, otherwise set it to 0. So we can say if, we can use a G match for that. gmatch $attribute has star scale in the name. Then set it to 1, otherwise else, if it doesn't have scale in the name, set it to 0. see what happens if we run this, we will probably still get this connected error here. So as I said before, if we were to lock this, lock, probably shouldn't see that error anymore. Here we have another error now. We can see cannot set the attribute mbody control position below its minimum value of one. So for position here, this is also an interesting one, because these custom attributes, let's undo here one more time, Ctrl Z, go under the body control. Here we have, for example, volume preservation is 0.5 by default. Position is, for example, 4 by default, let's say. Actually, I don't know if that was the correct default here. But those attributes, our custom attributes, we probably don't want a set to 0. We only want a set translation or rotation to 0. So we can build in more checks here. We can say else if. And we can build in a gmatch again and say if it has translation in the name, star translate star, set it to 0. And we can also say or. So we can probably write a new line. We can say else if. We can write it in the same line by doing this, or is two lines, vertical lines that those should be on my keyboard anyways. They are above the backslash. We take the same one again and write rotate here, rotate. And then we could put our curly brackets around it and we run it. And now we see, okay, we're not getting these errors anymore. And now this one will be reset. So if we put this somewhere else, and we put this one here somewhere else, and we put maybe the scaling. Actually, let's leave this for now and run our script here. Now you can see it reset these two controls, right? If we have scaling somewhere, so for example, let's scale this one up. And here I haven't fixed all these things that I should have fixed. But if we run our script again, it should reset the scaling here as well. And it does. Sets the scaling to 1. Sets the rotations and translations to 0. So far, so good. And we're not seeing any errors anymore, because it doesn't even... It's only going to do something if there is scale in the word or in the attribute or translate or rotate. Visibility is going to ignore anyway now. Even if those thumb controls were still unlocked, the visibility, if we forgot to lock them and hide them, which we should do anyway. But even if we have them unlocked, it will not throw this arrow anymore. Here it is still unlocked. What we can also do is just so that we know that it didn't fail anywhere. anywhere. I mean, didn't give them an error, so it went through, but we can probably print a success statement at the end. Reset, resetting controls was successful, and a new line afterwards. Now if we run the whole script, we can see, okay, it did it, right? Let's put an error here. And we can see resetting controls were successful. Great. Perfect. Not quite because we're still missing our custom attributes. So for example here, we might want to reset those as well. So for example, if we have bent on, there is not scale, there is not rotate and not scale, not scale, not translate, not rotate in the name. So if we're running this, we can see it doesn't reset the bent. So for custom attributes, what I would do is I would say, I would run a new check. So we can do something like put a comment here, we can say this resets translations, rotations and scale. We can remove that one. And here we can put a new line. So for each control we can iterate over the custom attributes. So we can do this, well reset custom attributes and we can put a list attribute and it was I think UD for user defined, that's custom attributes. So for example, if we run this down here, the tests, list user defined on this control here, the body control, it should list us all these custom attributes down here. Try that. And it does, right? The underscores, volume preservation, band up, and so on and so forth. So these are our custom attributes. So let's put them into a variable list as well, attribute list, called square brackets, and then those small ticks, you know, they're going from upper left to lower right. Okay. Then what we can also do is, let's bring those in here. That's the first step. We have to list all these attributes, the custom ones. Then what we can do is we can say for each attribute again, same thing what we did up here, we run through all the attributes in that attribute list, in a custom attribute list now, in attribute list, and do something that whatever is in this curly brackets. And here what we want to do is we want to check is it locked or not, because this one here probably can't reset because it will be locked. And also what we probably can do is we cannot just do set attribute. We can actually use the same one from up here. Just copy down there. Set attribute control plus dot plus attribute. We cannot just set it to zero because the volume preservation might not be zero. It might want to keep it at 0.5. Also the same thing for the position. You can see that I cannot even set the position to zero, the minimum is one here, for example. So instead of setting it to zero, what we should rather do is we should rather set it to whatever the default is for that attribute. And we can query the defaults with get attribute dash, I think it is get attribute, or it might be set attribute, or add attribute. It was something really weird. Add attribute dash q dash dv for default. And then we tried out on this position attribute to see what the default is, or was. Position. And here you can see the default was 1. And that default is essentially what you are entering here if you are adding a new attribute, and for example, tests. And remember when you put 0 and then 10, and then I told you here we can add a default attribute, Minimum, maximum, and default for the third line. So this is the default attribute that you can then later query or change or whatever you want to do with that. But you have to use Mell. I don't think that there is a way to do that through the menu here, Mell or Python scripting. Also, if we're adding a minimum of one, then the default cannot be zero, because the minimum can't go below one. And that's exactly what we had here for that position. So you can see now the test attribute will probably be your default value 0 is less than minimum and will probably set it to the minimum value. So that's exactly the same thing that would happen for position. So let's delete that attribute here again. So here we have the default of 1 for position but maybe we don't want default position to be 1, maybe we want default position to be 5, right, or 3.5. So you can change these defaults after the fact with the similar command here, we can just say add attribute dash E for added default and then give it a new value. So for example, it could be 5.0. And now if you run that, now this will be the new default. So if you're setting it to something else and then you're querying the default, add attribute dash Q for query default and body control dot position. Now the default will be 5. So that's why it's also important to set these default values properly, whatever you want the defaults to be. So let's put the default here for position back to 1. So let's say add attribute dash e dash dv for default, 1.0 on embody control position. And it doesn't mean what the current position is, it just means what the default will be. So then later on we can query that and we can set it to that default. So this is querying the default positions. So what we can do is we can just say set attribute, control attribute, control dot attribute, to whatever the default is. So we copy that in here into this command that should be executed and then the result will be set. So we query and here we can replace that also again, putting the normal brackets around it, speech marks around it, the double quotes, and then put in control name here instead of body control. We'll replace that with body or control plus, and then we'll replace the attribute here with the variable attribute. So this should set, it should query the attribute, the default attribute, and whatever the value is that we're getting out of that result, will set that attribute to that default value, okay, for each of the attributes, each of the custom attributes. Now this will probably still throw an error because it will also try to set the default on this locked attribute here. So we have probably have to add an if statement here first, but let's try and see what happens if we run it. An error. Oh, because I forgot to add the plus here. So let's try this one more time. Here we can see no object matches larmfkmadecontrol underscore. So we can see that we are getting this underscore issue here, underscore problem. It's an interesting thing here, no object matches name. That's weird. Should exist. But anyway, what we can try to do is now what I said. say if it's locked or only if it's not locked only if the lock query is zero. So let's try get attribute dash L what we tried earlier for lock is a locked and then we try this attribute here. It says no attribute, no object matches name. Strange. Let's try it on this body control here instead. So mbody control. Here we can see yes, it is locked. So then we say if it's not true, so if getAttribute, printUnlocked. unlocked. So here it prints, actually here it says if this is one then it's locked, right? It's like this. And now we can say if it's not true, if it's unlocked then print it's unlocked. And here you can see it doesn't print unlocked because it is in fact locked, right, this attribute. Let's put the speech marks in here as well. And let's put that whole thing here in here instead and say only if it's unlocked and we have to obviously replace this again with our variables, control plus and then here these underscores we have to replace with attribute, dollar attribute. So only if it is not locked, then set the attribute after control to whatever its default is. So let's try running the whole thing, see what we get. We still get an error here for whatever reason. Let's see why. I think I made a mistake somewhere. Let's try to run it one more time. object measures name. Right, I know why. Because here we're listing user defined attribute, but we're listing the user defined attributes on not on the control. Okay, we have to put in the control here also. For each of these controls we want to list the user defined attributes, otherwise it keeps the old ones around. So we want to be specific and say where on which control do So we want to list these attributes. So let's try this one more time. Now I think it should work. And now we can see resetting controls was successful. And we can also see that it set these to its defaults. Volume Preservation default is apparently one. And position is also one. If we try to change that to something else, so we tried to change the position here to five, what we did earlier, that it was add attribute dash e dash dv 5.5, let's say, and we do it for embody control position. Now essentially we changed this default, it's no longer one. If we now run our script here to reset all the attributes to, you know, scales one, translation and rotation to zero here, zero. And then all the custom attributes to its defaults, then we should see, if everything went well, we should see that now position will become 5.5, because we just set the default to that. So now if we run that, you can see now position is actually 5.5. So it did work. So let's change the position back to one what we had earlier. And if we run it again, you can see now position becomes one. So now this actually works. And now this is our script that we can use for resetting all of our attributes on all of our controls, all the attributes on all the controls. Just to reiterate one more time, we're first querying all the controls. And then for each control in the control list that we just got, we are going to first reset the translations, rotations, and scales just by listing all the keyable controls. And we're saying for all keyable controls, if for that attribute or all keyable attributes, we're getting those here and putting them into the attribute list for each control. And then for each attribute in that attribute list, we're saying if it is not locked, if attribute is not locked, then if the attribute is scale, then set it to one. Otherwise, if the attribute is translate or rotate, set it to zero. And then we're doing another query of all the custom attributes here. And we're setting those in a separate step here because we're using a different type, only the custom attributes. And for the custom attributes, we're saying for each attribute in that attribute list, are saying if the control or that attribute is unlocked, if it's not locked, if it's not true, that statement not locked, then set the control and that attribute to whatever their default is, which we're occurring here. Okay, and then if everything went successful, if it looped through all these loops here, then at the end, it should print resetting all the controls were successful. And that is it. Okay, that's all you need. And obviously here you can make your adjustments so you can say, hey, maybe I have CTL or CTRL, maybe I have control as my naming convention or whatever your naming convention might be. But if you're running this first line, whatever your controls are named, they should show up here if you're just running this one line CTL. Okay, for me it's CTL. So for me it's easy. You might have to change it to something else. But that is it. So now we We can take this whole script and put it somewhere else. So for example, we could put it onto a shelf here. So we can just take this middle mouse button, drag, and put it onto a shelf and say, okay, this is my shelf editor. We can say this is my reset script. Okay, reset controls, something like that. Now if I post this anyway, I like... Maybe this is a little bit over, maybe a little bit of bend, maybe the head a little bit rotated, maybe I have stretch set to zero. And now if we're clicking that, it should in theory reset all of our controls. Let's try and resets all of our controls back to the default. That also works for if we have hand controls here on. Okay. What else can we try to do? like that, we run our script and it resets everything, including the hand and so on and forth, all these fingers. So very, very easy, not too complicated to do. I'll show it to you one more time. What we did, here it is. And I think this is very, very useful because, again, you can use it whenever you want to reset all of your controls when you're doing testing or something like that. And the great thing about that is it's very dynamic. Because now if you're adding new attributes, new custom attributes, they will already be picked up with this. Because nothing is hard coded here. If you're adding new controls, as long as they follow the same naming convention that you have with all your other controls, we'll also pick those up. So if we're now adding bendylim controls or something like that, as long as they're control CTL, it will follow that same rule. So your script will still work. OK. So yeah, that's it.",
|
| 3 |
+
"segments": [
|
| 4 |
+
{
|
| 5 |
+
"text": " In this video I want to write a script with you to reset all of the controls. I think this is very very useful because... Let's set this to reference here. Because if you're like, often times you know you're playing with the rig, you're testing out stuff and then it's very easy to forget to reset certain things, especially if you have like very very small values on it, like something like that. But now if you're doing parenting or un-parenting or so on and so forth, you can get into trouble really easily if your rig is not reset to the default controls, everything's erred out. Because it can mean that if you're deleting history or you're freezing certain things or you're un-parenting, then you're getting false information here. So you should always, when you rig, have everything back at zero. And as I said, now that I've moved a couple of things, it might be OK. This is obvious. I have to reset this one. But the other things that I made, the other changes, they are not so obvious. Like there are small, small values in here and small, small values in this one. And also, I think some values on here. So they might not be easy to spot to reset them. Therefore, it is good to have a script that can do that for us. I want to show you a way how we can try to write or try to go about writing such a script. First of all, what we want to do is, and it also illustrates actually a little bit the need for consistent naming. So first of all, what we want to do is we want to get all of our controls here in our scene. And since we're hopefully consistent with our names, we can just say star CTL in my case. That's what we also had before I select my name star CTL. that should select all the controls here. We can also put that into a variable. So with Mel, I don't know how many of you guys are familiar with Mel. I think most of you are familiar with scripting. And you can do the same thing in Python too. But for those of you who don't, this is really meant for you guys. So first what we want to do is we want to list, so LAS, everything that ends with star, star CTL. And we had to put it into these speech marks or quotes here. What this will give us if we run it, and we can run this in case there are some of you who have never scripted before, the script editor, you bring it up from here. And you go into a melt tab here. And then you just run this command LS. I can make this move a little bit bigger. LS, and then quote star underscore CTL quote. And then see me colon. And if we're running this, it will list all the controls in our scenes. It's very similar to what we just did here. Only that here it selects them. But now with this command, we can do certain things. For example, if we do select minus r, for replace whatever is currently selected, and we put that into the single quote lines here, which is, it is on my keyboard, it's right under the escape. It's right where the tilde key is also, right above tap on my MacBook Pro for you. It might be somewhere else. If we're running that now, this means select anything that is returned from this command. So this command, you can see it returns certain things. It lists all the commands. And we can say, select all the controls, select all the results of that. So this would be this command. Now what we can do is we can put it into a variable. So we can, for example, say a string $controlList. And then we have to write these curly brackets equals. And if we're running that, now this will be, all of our controls will now be in that variable, in the control list, in a control array. If we now go down here and we say print, control list, then we can see it prints all of the controls that are in our scene here. Everything is in that variable. Now what we can do is we can say for each control, for example, control in control list, we can do something. So we need the curly brackets here. These are regular brackets for the for loop. And then we can do something inside these curly brackets. For example, we can do the same thing, but we just said we can say print control $control that variable. By doing so, it will print all the controls at the moment. It will print them one after the other. But if we want to have to min a new line, then we can use this backslash n. So now we'll print a control, and then we'll print a new line afterwards, or put a new line. So if we clear this out and we run it, you can see now it's printing all the controls. And we can say, for example, we can print something else. We can print control, colon, and then the control name, and then a new line. So now we have control and then control that name. Obviously here we don't want to print it. What we want to do is we want to find all the attributes that on each of these controls. So to do that, there is a command called, I think it's called, I have to remember. I think it's called channel box, cable, I believe. And if we try one of those controls to see if it works. User defined. I thought it was ChannelBox. Maybe it's List Attributes. We go into the Maya help. Let's try to find. Actually, you know what? I usually use Google for it. I usually type in my ML channel box to just find a command for a channel box command auto desk. And then here we have what we can use. And some examples down there. So main list connection. I think that might have been what it was. I mean, now... I think I was thinking of something else. I've used that one here before too, but I think I've used it for something else. So let's try list attributes instead. That's, I think, the right command we need here. So list attribute, for example, on this control of the eyes. So this lists all the attributes that we can possibly have. So if you're using the connection editor, for example, or you're looking at it in a node editor, you will see all these different attributes that this object can have. This is not what we want. We don't want to reset all these attributes. We only want to reset the attributes that the animators could potentially key frame. So let's try list attributes-key. That should give us a shorter list. Actually, it only gives us the attributes that are in the channel box if we try something else. And let's try without that specific name here. Let's just list the attributes on what we have selected on the body control. If we run that, we can see it's translateX, translateY, translateZ, rotateX, yZ. Then the underscore here, that's separator attribute. And volume preservation, our custom attributes are in here as well. So you can see this lists all the attributes that are inside the channel box, list attributes dash k. And if we give it a name here in the end, a control name, then it lists the attributes for that specific control. So what we can do is list attributes and then control. And we can put that also into a variable. So we can say, for example, string attribute $attribute list with the square brackets here, and we give it that result. And then we can do something for each of these attributes. For $attribute in attribute list, do something. Put that into color brackets also. Now, for example, print all the attributes. We can, for example, print the control that we got from here earlier, then plus a dot plus the attribute. $attribute. And then what we probably also want to do is we want to print a new line, so plus and then a backslash n. Now if we clear this all out and we run this, now we'll print for each control, you will list all the attributes and then we'll print a control name plus a dot plus the attribute and then a new line, and then we'll go on and print the next that same control, that attribute, and so on and so forth. OK. Now let's try to, now we want to reset all of them, right? For resetting, or resetting them to zero, essentially, zero. If we enter zero, we can see this is the command for setting an attribute to zero. So if we just copy that in here, instead of printing it, we can maybe keep the printing. Let's comment it out for now, in case we might want to print it later on for debugging. So set the attribute and instead of hard coding it here, we're going to replace this with the control plus a dot plus the attribute name. Attribute. Like so. This means now we're setting all the attributes to zero. If we try to run it like this, we will probably get an error somewhere. We get an error here. Set attribute, the attribute L foot control, underscores is locked or connected and cannot be modified. So that is because we have this locked. So what we should do is we should build in a check here. should check if the attribute is locked first. And we can do that with if get attribute. Actually, is that the right one? Let's see. Let's test it out down here, get attribute. It's been a while since I've wrote that. Get attribute minus L. Let's see what we get from that. we get one, so that means it is locked. And we can try another one. We can, for example, try rotate x, and that should be zero, because that shouldn't be locked. Zero. OK, so this is the right one. So we want to say, if get attribute is locked, so minus l, if it's one, or if it's zero, that means it is unlocked. If it's one, then it will be locked. So that means we can write it like this if it's zero. What we can also say is, without even that equal equal zero, we can just say, if this is, then it will only do it for locked attributes. We can say print is locked or something like that. Print is locked. Else, otherwise, if it's not true, if it's false, then it should set that to zero. So now if we run that, let's see if we get an arrow here. we get another error here because it is locked or connected. In this case, we have the thumb control visibility connected. We connected it to something else. In this case, it is not locked. But the visibility here is connected. Actually, this is probably something that we should lock and hide anyway. I think I forgot that here on all these finger controls, we haven't even locked all the scaling and all that stuff. And translation, not sure if we want to keep all of that. But the visibility is probably something that we could lock for sure. And then we would eliminate that arrow here as well. So maybe we should lock. And it seems to be only on a thumb. I think I did it on the other ones. But let's also look at how we can catch that arrow here as well. There are also a couple of different methods. And you know what? This is actually too long for me. I don't want it to write as locked. I don't care. I just want it to ignore it. So instead, what I want to do is, if is not true, so we can write it with an exclamation mark. And then we can set that here. And we don't need the else statement. So now this means if this is 0, so this with the exclamation mark in front means it's false. This would be the same as writing equal equal 0. It's false. It's not true. This means if it's one, if the result here is one, then do that. But we want if the result is zero, if it's not true. So then we write it with an exclamation mark in front. And this will be the same thing. So we will probably get the same error here. Thumb, root, control visibility is locked or connected. Here the key is that it is not actually locked. Otherwise it wouldn't do it, because then it would be locked. So if we're locking this now, or just lock it, and we run it, then it probably doesn't trip over the same arrow anymore. Now the thumb on the other side is locked, but not the one on the right. Maybe this was the same one. And we have another problem here, too. Let me undo a couple of times. We have another problem here, because it's also going to put the scaling here to 0 as well, which is why the thumb disappeared. It's putting all the attributes to 0. So that's probably also not good. So what we should also do is we should build in a check. If, so let's put another collie brackets in here. We should probably also build in a check and say, if it's scale, or if there is scale in the name, then set it to 1, otherwise set it to 0. So we can say if, we can use a G match for that. gmatch $attribute has star scale in the name. Then set it to 1, otherwise else, if it doesn't have scale in the name, set it to 0. see what happens if we run this, we will probably still get this connected error here. So as I said before, if we were to lock this, lock, probably shouldn't see that error anymore. Here we have another error now. We can see cannot set the attribute mbody control position below its minimum value of one. So for position here, this is also an interesting one, because these custom attributes, let's undo here one more time, Ctrl Z, go under the body control. Here we have, for example, volume preservation is 0.5 by default. Position is, for example, 4 by default, let's say. Actually, I don't know if that was the correct default here. But those attributes, our custom attributes, we probably don't want a set to 0. We only want a set translation or rotation to 0. So we can build in more checks here. We can say else if. And we can build in a gmatch again and say if it has translation in the name, star translate star, set it to 0. And we can also say or. So we can probably write a new line. We can say else if. We can write it in the same line by doing this, or is two lines, vertical lines that those should be on my keyboard anyways. They are above the backslash. We take the same one again and write rotate here, rotate. And then we could put our curly brackets around it and we run it. And now we see, okay, we're not getting these errors anymore. And now this one will be reset. So if we put this somewhere else, and we put this one here somewhere else, and we put maybe the scaling. Actually, let's leave this for now and run our script here. Now you can see it reset these two controls, right? If we have scaling somewhere, so for example, let's scale this one up. And here I haven't fixed all these things that I should have fixed. But if we run our script again, it should reset the scaling here as well. And it does. Sets the scaling to 1. Sets the rotations and translations to 0. So far, so good. And we're not seeing any errors anymore, because it doesn't even... It's only going to do something if there is scale in the word or in the attribute or translate or rotate. Visibility is going to ignore anyway now. Even if those thumb controls were still unlocked, the visibility, if we forgot to lock them and hide them, which we should do anyway. But even if we have them unlocked, it will not throw this arrow anymore. Here it is still unlocked. What we can also do is just so that we know that it didn't fail anywhere. anywhere. I mean, didn't give them an error, so it went through, but we can probably print a success statement at the end. Reset, resetting controls was successful, and a new line afterwards. Now if we run the whole script, we can see, okay, it did it, right? Let's put an error here. And we can see resetting controls were successful. Great. Perfect. Not quite because we're still missing our custom attributes. So for example here, we might want to reset those as well. So for example, if we have bent on, there is not scale, there is not rotate and not scale, not scale, not translate, not rotate in the name. So if we're running this, we can see it doesn't reset the bent. So for custom attributes, what I would do is I would say, I would run a new check. So we can do something like put a comment here, we can say this resets translations, rotations and scale. We can remove that one. And here we can put a new line. So for each control we can iterate over the custom attributes. So we can do this, well reset custom attributes and we can put a list attribute and it was I think UD for user defined, that's custom attributes. So for example, if we run this down here, the tests, list user defined on this control here, the body control, it should list us all these custom attributes down here. Try that. And it does, right? The underscores, volume preservation, band up, and so on and so forth. So these are our custom attributes. So let's put them into a variable list as well, attribute list, called square brackets, and then those small ticks, you know, they're going from upper left to lower right. Okay. Then what we can also do is, let's bring those in here. That's the first step. We have to list all these attributes, the custom ones. Then what we can do is we can say for each attribute again, same thing what we did up here, we run through all the attributes in that attribute list, in a custom attribute list now, in attribute list, and do something that whatever is in this curly brackets. And here what we want to do is we want to check is it locked or not, because this one here probably can't reset because it will be locked. And also what we probably can do is we cannot just do set attribute. We can actually use the same one from up here. Just copy down there. Set attribute control plus dot plus attribute. We cannot just set it to zero because the volume preservation might not be zero. It might want to keep it at 0.5. Also the same thing for the position. You can see that I cannot even set the position to zero, the minimum is one here, for example. So instead of setting it to zero, what we should rather do is we should rather set it to whatever the default is for that attribute. And we can query the defaults with get attribute dash, I think it is get attribute, or it might be set attribute, or add attribute. It was something really weird. Add attribute dash q dash dv for default. And then we tried out on this position attribute to see what the default is, or was. Position. And here you can see the default was 1. And that default is essentially what you are entering here if you are adding a new attribute, and for example, tests. And remember when you put 0 and then 10, and then I told you here we can add a default attribute, Minimum, maximum, and default for the third line. So this is the default attribute that you can then later query or change or whatever you want to do with that. But you have to use Mell. I don't think that there is a way to do that through the menu here, Mell or Python scripting. Also, if we're adding a minimum of one, then the default cannot be zero, because the minimum can't go below one. And that's exactly what we had here for that position. So you can see now the test attribute will probably be your default value 0 is less than minimum and will probably set it to the minimum value. So that's exactly the same thing that would happen for position. So let's delete that attribute here again. So here we have the default of 1 for position but maybe we don't want default position to be 1, maybe we want default position to be 5, right, or 3.5. So you can change these defaults after the fact with the similar command here, we can just say add attribute dash E for added default and then give it a new value. So for example, it could be 5.0. And now if you run that, now this will be the new default. So if you're setting it to something else and then you're querying the default, add attribute dash Q for query default and body control dot position. Now the default will be 5. So that's why it's also important to set these default values properly, whatever you want the defaults to be. So let's put the default here for position back to 1. So let's say add attribute dash e dash dv for default, 1.0 on embody control position. And it doesn't mean what the current position is, it just means what the default will be. So then later on we can query that and we can set it to that default. So this is querying the default positions. So what we can do is we can just say set attribute, control attribute, control dot attribute, to whatever the default is. So we copy that in here into this command that should be executed and then the result will be set. So we query and here we can replace that also again, putting the normal brackets around it, speech marks around it, the double quotes, and then put in control name here instead of body control. We'll replace that with body or control plus, and then we'll replace the attribute here with the variable attribute. So this should set, it should query the attribute, the default attribute, and whatever the value is that we're getting out of that result, will set that attribute to that default value, okay, for each of the attributes, each of the custom attributes. Now this will probably still throw an error because it will also try to set the default on this locked attribute here. So we have probably have to add an if statement here first, but let's try and see what happens if we run it. An error. Oh, because I forgot to add the plus here. So let's try this one more time. Here we can see no object matches larmfkmadecontrol underscore. So we can see that we are getting this underscore issue here, underscore problem. It's an interesting thing here, no object matches name. That's weird. Should exist. But anyway, what we can try to do is now what I said. say if it's locked or only if it's not locked only if the lock query is zero. So let's try get attribute dash L what we tried earlier for lock is a locked and then we try this attribute here. It says no attribute, no object matches name. Strange. Let's try it on this body control here instead. So mbody control. Here we can see yes, it is locked. So then we say if it's not true, so if getAttribute, printUnlocked. unlocked. So here it prints, actually here it says if this is one then it's locked, right? It's like this. And now we can say if it's not true, if it's unlocked then print it's unlocked. And here you can see it doesn't print unlocked because it is in fact locked, right, this attribute. Let's put the speech marks in here as well. And let's put that whole thing here in here instead and say only if it's unlocked and we have to obviously replace this again with our variables, control plus and then here these underscores we have to replace with attribute, dollar attribute. So only if it is not locked, then set the attribute after control to whatever its default is. So let's try running the whole thing, see what we get. We still get an error here for whatever reason. Let's see why. I think I made a mistake somewhere. Let's try to run it one more time. object measures name. Right, I know why. Because here we're listing user defined attribute, but we're listing the user defined attributes on not on the control. Okay, we have to put in the control here also. For each of these controls we want to list the user defined attributes, otherwise it keeps the old ones around. So we want to be specific and say where on which control do So we want to list these attributes. So let's try this one more time. Now I think it should work. And now we can see resetting controls was successful. And we can also see that it set these to its defaults. Volume Preservation default is apparently one. And position is also one. If we try to change that to something else, so we tried to change the position here to five, what we did earlier, that it was add attribute dash e dash dv 5.5, let's say, and we do it for embody control position. Now essentially we changed this default, it's no longer one. If we now run our script here to reset all the attributes to, you know, scales one, translation and rotation to zero here, zero. And then all the custom attributes to its defaults, then we should see, if everything went well, we should see that now position will become 5.5, because we just set the default to that. So now if we run that, you can see now position is actually 5.5. So it did work. So let's change the position back to one what we had earlier. And if we run it again, you can see now position becomes one. So now this actually works. And now this is our script that we can use for resetting all of our attributes on all of our controls, all the attributes on all the controls. Just to reiterate one more time, we're first querying all the controls. And then for each control in the control list that we just got, we are going to first reset the translations, rotations, and scales just by listing all the keyable controls. And we're saying for all keyable controls, if for that attribute or all keyable attributes, we're getting those here and putting them into the attribute list for each control. And then for each attribute in that attribute list, we're saying if it is not locked, if attribute is not locked, then if the attribute is scale, then set it to one. Otherwise, if the attribute is translate or rotate, set it to zero. And then we're doing another query of all the custom attributes here. And we're setting those in a separate step here because we're using a different type, only the custom attributes. And for the custom attributes, we're saying for each attribute in that attribute list, are saying if the control or that attribute is unlocked, if it's not locked, if it's not true, that statement not locked, then set the control and that attribute to whatever their default is, which we're occurring here. Okay, and then if everything went successful, if it looped through all these loops here, then at the end, it should print resetting all the controls were successful. And that is it. Okay, that's all you need. And obviously here you can make your adjustments so you can say, hey, maybe I have CTL or CTRL, maybe I have control as my naming convention or whatever your naming convention might be. But if you're running this first line, whatever your controls are named, they should show up here if you're just running this one line CTL. Okay, for me it's CTL. So for me it's easy. You might have to change it to something else. But that is it. So now we We can take this whole script and put it somewhere else. So for example, we could put it onto a shelf here. So we can just take this middle mouse button, drag, and put it onto a shelf and say, okay, this is my shelf editor. We can say this is my reset script. Okay, reset controls, something like that. Now if I post this anyway, I like... Maybe this is a little bit over, maybe a little bit of bend, maybe the head a little bit rotated, maybe I have stretch set to zero. And now if we're clicking that, it should in theory reset all of our controls. Let's try and resets all of our controls back to the default. That also works for if we have hand controls here on. Okay. What else can we try to do? like that, we run our script and it resets everything, including the hand and so on and forth, all these fingers. So very, very easy, not too complicated to do. I'll show it to you one more time. What we did, here it is. And I think this is very, very useful because, again, you can use it whenever you want to reset all of your controls when you're doing testing or something like that. And the great thing about that is it's very dynamic. Because now if you're adding new attributes, new custom attributes, they will already be picked up with this. Because nothing is hard coded here. If you're adding new controls, as long as they follow the same naming convention that you have with all your other controls, we'll also pick those up. So if we're now adding bendylim controls or something like that, as long as they're control CTL, it will follow that same rule. So your script will still work. OK. So yeah, that's it."
|
| 6 |
+
}
|
| 7 |
+
]
|
| 8 |
+
}
|