Notifications
Clear all

[Closed] 2 MaxScript Tutorial Videos

Hey all,

My last two Monday Movies are looking to get more people introduced to MaxScript! The first video covers the basics of MaxScript, while the second covers how to create a MaxScript rollout and more elaborate functionality!

Enjoy!

11 Replies

Thumbs up from me!

Very nice videos, I’m sure people beginning with maxscript will find them very useful

I know that the code you’re writing is just to show certain functionality in mxs, but I feel I should nonetheless comment it a bit. It can be written quite a bit more efficient:

on GetRandom pressed do
    (
       local selectFrom
       local newSel = #()
       if UseCurrentSelection.checked then 
         selectFrom = getCurrentSelection()
       else
         selectFrom = objects

       for obj in selectFrom do
          if (random 0 1) == 1 do
             append newSel obj

       select newSel
    )

You could use selectMore in this code too, but that can be significantly slower than selecting everything at once.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

I was going to say the same, but I felt it was nitpicking.
But if we are going to talk about efficiency and style, I would have used a COLLECT loop with a WHILE statement…

on GetRandom pressed do
(
	local selectFrom = if UseCurrentSelection.checked then 
		getCurrentSelection()
	else
		objects
	select (for obj in selectFrom where (random 0 1) == 1 collect obj)
)

Looking at that if statement, it’d be so nice if that could be written like

local var = (statement) ? true_result : false_result

rather than the frankly slightly awkward max’s if/do/then.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

I completely disagree.
Anything that reads like English to a newbie is better than a cryptic swearing-like (?@#*!) syntax in my book.

I wouldn’t mind having it as an option, but the way it is right now is not awkward in any way.
IMHO.

 PEN

Nice work, I have taught Max script to many beginners and the simpler the better. Personally Bobo, while loops and collects are harder for a beginner to grasp and I think of them as the intermediate level scripting. When I teach it I basicly keep everything the same and write stuff out in long form. You can do just about every thing with a for i loop and if statements. Might be ugly, might be slower but if it works then the student is very happy and it is still a million times faster then a person could do it.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

This is a valid point and the main reason I did not comment on the content in my initial post.
Having intermediate variables and longer more descriptive expressions can help a new user understand the logic, step by step.

On the other hand though, proposing to use selectMore() can have the negative effect of teaching a new user that it is ok to use it (which it is not for performance reasons).

Also, in the case of ‘do append’ vs. ‘collect’ it makes it necessary to declare a new array and explain what an array is vs. just collecting all objects into a variable and never mentioning the array.

We are all learning how to teach the basics to others every day and I find this thread (and the two videos) incredibly useful to learn how other people approach teaching MAXScript.

This does not diminish the quality of the videos which are very well done and should hopefully encourage more people to try out MAXScript. (it has been 13 years already, come on!)

 PEN

Another thing that I would suggest is to use brackets every where as that helps beginners define what is what. In your examples you don’t use them with the first for loop and once that is all part of a larger body of code it is easier for them to understand what is in the loop and what is not.

my solutions is exactly same as Bobo’s


select (for n in (if UseCurrentSelection.state then selection else objects) where (random 0 1) == 1 collect n)

why? because there are at least two reasons:

  1. using collect with WHERE is slightly faster then using append and if/do expression.
  2. it’s MUCH faster to collect nodes first and select the collection then to call selectmore for every node. (selectmore causes bunch of callbacks per every call + another callbacks caused by clearselection)
 PEN

Videos are excellent, agreed.

I find that teaching what an array is is a very important thing for a new person learning to code. The example might be faster using collect and select but if the goal is to teach how Max script and code in general work then I think that taking a longer but more informative approach works well. Teaching how to make code faster to those that want to move forward with it is easy I have found, teaching short cuts to new people and then trying to explain why it will not work and they have to do it different in other cases is harder.

For instance, when teaching new students how to turn off all turboSmooth modifiers in a scene I teach them nested for loops to loop through all the objects and then all of the modifiers on each and check the class. I could use getClassInstances but that will not give them the understanding of how to do other things that can be done with for loops and classOf.

If I’m just teaching people simple scripted solutions and not really trying to make scripters out of them I will go with short cuts, they might not totally get it but they will have enough understanding to do very simple things quickly.

very good tutorials enjoyed it!

From the point of view of someone relatively new to max script i would like to suggest the usage of the “new rollout” button in the tools menu for creation of rollout as it is more easier to explain and it automatically creates the rollout script as well as the event handlers, at first when i started learning about rollouts i was not aware of this feature and manually coded my rollouts till one day i accidently found it

i prefer the use of the caseof statement when it comes to branching as it gives more elegance to the code and is fairly simple to understand!