AutoSmooth on selected objects
Hello I'm beginner in MaxScript and I writed a little script to automatically apply an auto-smooth on only one selected object.
But I would like to make it working on a selection of several objects.
Maybe it's also possible to improve the syntax because I'm not sure is the best way to write this script.
Thanks for your help !
(
bob=selection
sel=bob as array
if sel.count !=1 then
(
messageBox "select only one object"
)
else
(
if classof $.modifiers[1] != Edit_Poly then
(
modPanel.addModToSelection (smooth autosmooth:true threshold: 10) ui:on
)
else
(
numFaces = polyop.getNumfaces $
subobjectLevel = 4
$.modifiers[#Edit_Poly].autoSmoothThreshold = 10
$.modifiers[#Edit_Poly].SetSelection #Face #{1..numFaces}
$.modifiers[#Edit_Poly].ButtonOp #Autosmooth
$.modifiers[#Edit_Poly].SetSelection #Face #{}
subobjectLevel = 0
)
)
)
Comments
Thanks
Hello
Thanks for your replies !
Your tips and examples help me a lot to better understand how to script.
I will re-write my script based on your advices.
Cheers!
some tips from me
We cannot supply all the good tips just with few words, but here is and some from me.
modPanel methods required Modify panel to be active!
-- Sets Modify command mode active max modify mode
Using Modify panel is slow, so when you have alternative just use it instead. For adding modifier you can use
addModifier
function (without need to switch to mod-panel).There also an useful function
validModifier
that verify if you can apply concrete modifier class to your object.And here is how I imagine your task...
Cheers!
my recent MAXScripts RSS (archive here)
Hi Anubis,I always try to
Hi Anubis,
I always try to learn from the best, but is difficult to explain some stuff using Google Translate :) like me.
My solution is not for learning example because is to short.
I try to explaine just some basic rules for optimizatons.
bga
:)
I think that Henrard ask for tips as he say: "also possible to improve the syntax".
Anyway, as I have a bad habit to trust to my memory and post untested code, I presume that I made a syntax typo in my example code. I used:
obj.modifiers.smooth
but the correct might was:obj.smooth
, rigth?my recent MAXScripts RSS (archive here)
:)
Yep. I post the code 75% never tested, some works and some not.
But it would be pointless if we just post the correct codes.
Then we would not have something to talk about.
:)
bga
indeed :)
Meanwhile, as I copy/paste some line of code from your example, now I see that you use "o" variable, while I use "obj" and need to edit my example code :) but EDIT option here available only for my last post :( so I attach edited code on this post.
my recent MAXScripts RSS (archive here)
If you have a time i'm
If you have a time i'm posting new thread about Resize Modifier (XForm+CustAttributes).I need some advice about xform transform and center (modifier) position
bga
one tip for you:
Look in the MaxScript help to find out more about meshOp and polyOp operations.
Theses are interface functions and try to store them in some variable before you put them inside for-loop. It is much fester.
Also try to switch from modify to create panel when use theses types
of operations using this line:
Using "undo off (...)" and "with redraw off (...)" you can speed-up the things a lot.
Aniway . . . you deside what you need
;)
bga
try this one
I write a simple function
bga