Notifications
Clear all

[Closed] Script for sorting out splines

… and now the attachment:p

Wow RH thats what I call a rewrite!
I fixed the problem with the second structure statement and its lack of commas.

There seems to be a problem with it trying to restore sel and not finding it…I’ll search back through previous versions and try and work out where we lost it.

Also seem to be missing a select Objects button…I thought it would be more intuitive to do the selection from the dialogue, and just filter shapes at that point. Although I can see what the filter function does and how it works with the current selection set.

Can you explain a bit more about instancing structures. I think I get what you did, but not why ;)) I’m a bit confused on how the values for the threshold and steps are passed back to the function from the spinners.

Just a thought…

How would you implement a progress bar to show, say, the % of objects passed by the script.

And as part of this…echoing the fixed object name in the interface rather than in the listener.

Oh and another question…
Do I need a separate struct to hold the functions and variables for each rollout if there is more than one, or can these be done once for a utility with several rollouts?

Was just trying to apply it to another script I was working on :))

You don’t actually need a struct for it, I was just trying to be illustrative of Baldrick’s idea. You could just put a suite of local variables in each rollout and get the same effect.

Feel free to add back the selection button. It shouldn’t affect the operation of the execute button handler one way or the other, so it’s your call. You might even devise a way of writing a similar filter function, but that fits the requirements for use with selectByName().

For the progress bar, just add a progressBar control to your UI, then update its .value property from within the main loop. This will mean modifying sortsplines() to take the rollout as a parameter, or to make the rollout explicitly global so that the function can refer to it. It will also mean normalizing the number of objects in the splines array to a 0-100 range.

Echoing the fixed object names to the dialog sounds possible, but I’d need to do some testing on my own to tell you how it would be done.

I’ve used structs in the rewrite in two different ways. One is just a warehouse for functions, that does not get instanced. I do this commonly so that I can use function names with reckless abandon, not worrying about whether they will conflict with built-in ones or those of other scripts. For instance, you could include a copy() function in a struct and it won’t conflict with Maxscript’s copy() function. The other type of struct I used is different in that it requires an instance to work. Any struct that uses member variables will need to be instanced in order to access them. This is because a structure definition is really just an abstraction. You can say that struct foo() has a variable width, but foo() itself doesn’t actually have a width – only an instance of a foo can have a width. Structs in Maxscript are really quite similar to structs in the C language, if that helps at all.

RH

Page 3 / 3