View Full Version : beginner maxscript question
punnw01 04-09-2003, 02:45 AM first, i'm retarded when it comes to maxscript or when it comes to a lot of other things also.
second, i need a pretty simple script that anyone that know scripting can whip up for me in 30 seconds. so if anyone want to hook me up, here it is.
i need a script that will do the following to the selected object.
a. make a copy of the object
b. rename that object with the prefix MCDCX_
c. apply the MultiRes modifier on it.
d. "generate"
e. change the percentage down to 10%
f. deselect
done. easy as pie.
thanks in advance, I'll learn this whole maxscripting thing as soon as i learn how to read.
|
|
punnw01
04-09-2003, 06:33 PM
no love from the maxscript gurus out there?
i've tried to use the maxscript listener with the macro recorder enabled but there are a lot of things that don't get recorded. so now i'm clueless.
EricChadwick
04-09-2003, 06:37 PM
Scripting gurus have told me the listener/macro recorder does not output good maxscript. Mostly useless for coding, other than to error-check any code you write.
I saw a script recently for applying Multires to multiple objects. I'll look for it...
Signal2Noise
04-09-2003, 06:38 PM
Suggestion: Are you aware of this extremely helpful site (http://www.scriptspot.com)?
I'm no maxscript guru either but maybe you'll have luck there.
Good luck!
EricChadwick
04-09-2003, 06:41 PM
Here it is. Not sure if it only works in max3 though.
http://tdp.nu/cgi-bin/plugsearch_r4.pl?search=multires
Scriptspot and tdp.nu are indispensible.
punnw01
04-09-2003, 07:19 PM
thanks for the responses, i do know about scriptspot and i use scripts from there all the time. it's just that this is such a specific script that i knew i wasn't going to find there.
Signal2Noise
04-09-2003, 07:27 PM
OK, cool.
EricChadwick
04-09-2003, 07:28 PM
Bobo is a really cool guy. If asked, he might modify his script for you.
http://www.scriptspot.com/bobo/
Originally posted by posm
Bobo is a really cool guy. If asked, he might modify his script for you.
http://www.scriptspot.com/bobo/
LOL, thanks! :)
Probably a premature announcement, but I am working on something that might make such questions obsolete in the future!
Here is the requested code in raw form.
It works even in Max R3 (I know it came with Max 4, but I have MultiRes for R3 from Digimation/Intel and it worked there!)
It does exactly what was described in "Natural Language".
Btw, I must congratulate the original poster for the great outline of the script - you will become a great scripter if you learn the right syntax...
obj = pickobject()
new_obj = copy obj
new_obj.name = "MCDCX_" +obj.name
max modify mode
addmodifier new_obj (multiRes())
new_obj.multiRes.generate = true
new_obj.multiRes.Vertex_Percentage = 10.0
max select none
And this is the advanced version with validity checks etc. as MacroScript...
macroScript AddMultiRes category:"CGTalk Help"
(
--Create an instance of MultiRes modifier
local mres = multiRes()
--Define a function to see if object can accept MultiRes as modifier
fn filter_fn obj = ValidModifier obj mres
--Pick an object, allow only objects that can accept MultiRes
obj = pickobject filter:filter_fn
--If the user picked a valid object and did not cancel picking...
if obj != undefined then
(
--Copy the object:
new_obj = copy obj
--Change the name
new_obj.name = "MCDCX_" +obj.name
--Go to Modify panel
max modify mode
--Select the new object - MutliRes has to be in the Modify panel
--for .Generate = true to be called correctly!
select new_obj
--Add the MultiRes to the object
addmodifier new_obj mres
--Generate the data...
new_obj.multiRes.Generate = true
--And set the vertex percentage
new_obj.multiRes.Vertex_Percentage = 10.0
--Deselect the object
max select none
)
)
Signal2Noise
04-09-2003, 11:21 PM
And once again I must bow to the presence of Bobo, The Scripted God!:bowdown:
punnw01
04-10-2003, 12:39 AM
very cool, thanks bobo. you just make it look so easy when you laid it all out like that.
a question for you, why have the macrorecorder when it's only echoing commands about half the time?
and another thing bobo, a few of your scripts have save me headaches several times. thanks again. i'll know where to turn to next time i'm stumped.
Originally posted by punnw01
very cool, thanks bobo. you just make it look so easy when you laid it all out like that.
a question for you, why have the macrorecorder when it's only echoing commands about half the time?
and another thing bobo, a few of your scripts have save me headaches several times. thanks again. i'll know where to turn to next time i'm stumped.
Ok, here are my subjective answers:
1. It IS easy. You actually did the harder part - you described in a natural language step by step what you want to do. The next step is very easy as long as you know the syntax and have some experience - you just find the right commands to make it work.
Compare this to writing a book - it is not about finding the words in a dictionary, but about telling a good story the right way. I read the MAXScript Help all the time (even though I am now writing it most of the time) since I cannot keep every function and property in my head...
Take a look at the "How To" tutorials in the MAXScript 5 Help. They all start with a Natural Language description just the way you did it.
2. The MacroRecorder isn't a bad idea per se. Unfortunately, in order to get correct output, every element should be rewritten to support the ParamBlock2 which was introduced to the Max core with R3. There are some older parts of Max written by the original coders (Tom Hudson, Dan Silva etc.) that are still implemented in the old ParamBlock. It would be a bad idea to touch a working code just to get it output Macro code and I am happy Discreet is not destabilizing Max any further by doing so...
Sometimes the MacroRecorder can help you find some things you would hardly find in the docs, especially some special actions that require criptic calls...
3. Please use my email when you need scripting help.
As I mentioned, I am working on something to make life of non-scripters easier, you would be a good Beta tester when I am ready...
punnw01
04-10-2003, 06:38 PM
thanks bobo, just let me know whenever that thing you're working on is done.
I have been meaning to really throw myself into the whole scripting thing but there are just so many things to learn and only so many hours in a day. But if the thing that you're building will help out us people that want to script something but just don't have the first clue then I'm ready for it.
CGTalk Moderation
01-14-2006, 08:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.