okay so... first things first.
I looked around on the internet how to make something happen in max based on a specific button being held and it led me to some dotnet stuff. Works great. However I was wondering if anyone knew how to set it up to use mutliple keys.
I looked around a bit but it is difficult to find something when I don't really know what I am looking for.
Here is a example of what I have in the script.
wincon = dotnetclass "system.windows.forms.control"
obj = $
if wincon.modifierKeys == wincon.modifierkeys.control do
if $ == undefined
then
for i in geometry do
if isproperty i #turbosmooth == true do
i.modifiers[#turbosmooth].enabled = on
else
for i in obj do
if isproperty i #turbosmooth == true do
i.modifiers[#turbosmooth].enabled = on
Also if there is an easier way to go about doing this like without dotnet... I am all ears.
Replies
lol okay. I had been checking the maxscript help but I don't know why I didn't think to check the reference on that one.
Really appreciate it perna. When I posted this I was actually thinking of you because I had seen you talk about smart scripts before.
Bryan - I checked it out and I have to say awesome! Really good stuff. I had to go and look up case statements to understand what is going on... but it is definitely what I am looking for. I pretty much have a good understanding of it.
Maybe you guys can help answer a few questions of mine that came up when I started playing with the code.
First...
What is the point of saying for example (keyboard.shiftpressed and not keyboard.controlpressed)? Is that not the same as just saying keyboard.shiftpressed?
Why a function? I guess it is obvious when I think about it... because you can create this one function that you use throughout all of your scripts. But how would it really help me if I am making single scripts? I would want my scripts to standalone so that I can share them individually with people at work.
I guess I am just not sure about how to implement that into a workflow yet because as of now my workflow just consists of typing on a keyboard.
I guess on the function I noticed you guys seem to have a very specific convention for your keyboard modifiers. What I meant was are you typing this specific modifier function at the beginning of every one of your scripts that need to use modifiers?
I assumed you might have had a library of functions that are specific to you that load into max every time.
Thanks for the help btw. I actually just finished my first script implementing the case expressions I learned from the scripts you guys were making. Link
Jeremiah: I would experiment with creating a library of useful functions later on down the line, once you get more experienced. Right now just play around and figure out what you want to get working. All I did when I started out was simple standalone macroscripts and then I began to share them with coworkers. Since we all worked a little differently I would have to fix bugs and modify their behavior if I felt the artist had a valid suggestion. This improved my logic handling and error checking. Im just now getting into consolidating all my scripts (I have about 100 different scripts) and re writing them with a library of functions to use throughout them, though I wish I had investigated it sooner (This is a few years down the line). It also requires a bit more work if you want to share your scripts that use a shared library, but if there is a bug in your code you only need to fix it once and not several times.
Fantastic, I hadn't known there were global system variables for keyboard modifiers. I'd toyed with them a bit with some of the dialog/rollout controls, but I wasn't aware of the globally-available system variables, thanks!
Jeremiah:
Building (or using/co-opting) a library of useful functions can be a super time saver (and hair saver!). Whether that's large functions that you'll need from time to time, or super small functions that simplify little tasks or provide alternatives to built-in methods, they can be extemely handy. For example, I wrote a small global function that I can use anywhere in my scripts/tools at work:
Now, since the built-in array search method (FindItem()) only does case-sensitive search, I wrote a small function that does case-insensitive searches within arrays, to save me a fair bit of hassle.
Or something like:
Maxscript doesn't provide a method to subtract all the items in an array from a second array, which is something I find myself doing from time to time, so again, I wrote a little function to do just that.
I get the not pressed thing now... Even after I read your beer and milk thing I still didn't understand what you were saying. So I was like I guess I will just make a quick script with 2 different alt commands... and before I could even get done typing up the keyboard modifier function it hit me.
I kept telling myself...
keyboard.shiftpressed
is the same as
keyboard.shiftpressed and not keyboard.controlpressed
and it isn't!
The case statement would stop at keyboard.shiftpressed even if I was holding control because it found Shift to be true. Could you not just order the case statement in a very specific order to counter that problem? You would just order the case statement backwards... like this...
This should work just fine right?
Now... I will admit I had to look up the answer. I think the reason I had so much trouble with it... is because you still can never know. It is brilliant deduction but it is still an assumption There is a 50% chance it is wrong because who is to say that it wasn't completely random?
My question about the function is in here.
The function for the modifier keys was never defined in this script. So how are you guys using them? This is why I assumed you had a library somewhere that was being called.
As for all the script crits... I will have to pick up sometime during the week. If not then it will be over the weekend. Been trying to hit a hard deadline for Wednesday... so I haven't had much time for middle of the week scripting. Regardless of when I get to them I greatly appreciate it Perna. I won't let the crits go to waste.
Bryan: Guess it is standalone scripts then for now
I really appreciate the time everyone is putting in to me. Really awesome of you guys to help because self teaching myself was going really slow.
Cheers
Seeing the AO puzzle written down helps. It now makes complete sense and I clearly had no idea what I was talking about. While I could agree with you that someone who struggles with logics would struggle with programming. But I also believe that logics could be taught to someone... it is just whether or not they can grasp the concept in the end.
I am glad we settled the "and not" thing. I was just trying to get out of you guys if this was the only way to go and then I remembered that case statements are order specific. It is good to know both methods as I was taught that the only absolute is that there are no absolutes.
I really appreciate the information Perna. Just with the bit of information you have supplied you have greatly accelerated the process of me learning scripting.
I will definitely start learning more through the help. Just got side tracked with the turbosmooth script and trying to keep up with this thread. :P
Okay that makes sense. So if you were making standalone scripts you would have to put it in the script. And if you were making a ton of scripts to be distributed among coworkers or to be downloaded as a package you could create and installer that would put those scripts in the startup folder?
While it might be faster I don't know that I am at a level of scripting that I need to do that extensively. The only reason it got brought up is because I could see myself using this same modifier key function over and over among all my scripts.
Thanks for the information LoTekK.