PDA

View Full Version : smooth changin script needed


Raptor235
08-18-2002, 06:13 PM
Could someone write a small script that will take whatever smooth nodes are on a selected object (polygons) and change it's polysmooth to whatever devision you can specify so that when you press one it can goto divisions 0 2 divisions 1 ect ect...just like in nurbs but I want something like that for polys...

-wT-
08-18-2002, 07:35 PM
Hey, that's actually quite cool script-idea :)
Too bad I don't have the time to do it, but sounds nice (And possible to do, I'd say)

Raptor235
08-18-2002, 07:37 PM
Ya I'm allways coming up with great additions for maya but I don't know mel to write them I wanna take a course or get a book to start to learn mel more...this guy at Siggraph 2002 mentioned a new book that's coming up on how to learn Mel I don't know the title right now but I hope I find it .

-wT-
08-18-2002, 07:46 PM
I'd say the best way to learn MEL is to write it.
Just a couple months ago or so, I didn't know anytihng about MEL either (Well, can't say I would know everything yet though), but I just decided to write this simple edge-connect script, and that helped me ALOT!
The problem with learning MEL is exactly that there isn't any info out there, the Maya manual helped me to understand why I couldn't do something, but there weren't any info anywhere of how to do something.

But write it! You will learn it, MEL's very easy compared to C, but it's similiar to C, so because of that it's easy... :)

Raptor235
08-18-2002, 07:51 PM
Did you have any C experience from before? Do you think if I tried to write some stuff maybe you could look at it if I'm having trouble just to point me in the right direction?

-wT-
08-18-2002, 07:59 PM
Actually yes, I did have some previous C experience, but very minimal, like if you've ever had a book about some programming language, you know the basic "Hello World" program? Well that's about what I knew about C :), ok maybe a bit more, but not much. Just how procedures, conditionals and loops work in C.

And sure I could look at your scripts, you can email me, I think the email I have in the profile is correct, so just use that one.

wrend
08-19-2002, 12:13 PM
you dont need any previous experience....fug knows i dont! you'll find the best resources are other peoples scripts, including some nicely annotated ones by AW. umm, Bryan Ewert's mel page is v.nice too! and the docs of course, its all done for you really ...all you need to do is flip the flags and shuffle the command returns about the place. that shuffling could be picked up from books talking about programming structure, eg a C book ..i guess (i never [havent yet] bothered)... i think you generally know nice code when you read it.

i hope you dont mind me having a crack at your request, and hope i havent taken an opportunity for you to learn, but, you say you've got ideas coming out of your ears about extending the app (i know the feeling, and i love being empowerd to do something about it now!), so plenty of other chances fro you to crack at! ... im learning too and would love to give what little i can back to the community! :)

ok, the script:

$ob = `ls -sl -l -dag`;
$smov = `listConnections -t polySmoothFace $ob`;
if (size($smov)==1 && `nodeType $smov` == "polySmoothFace")
setAttr ($smov[0] + ".dv") ($smoothness -1);


now, your going to want to append this into the script maya uses to set smoothness, which is aw\maya4\scripts\others\setDisplaySmoothness.mel ... pop it in after the set subdiv display smoothness bit , but before return, is suggest you put a big fat comment to remind yourself that you've done this (infact its probably a good idea to make a list elsewhere that explicitly documents any changes you've made to the default maya scripts ... im going to start this now as this is my first lasting tinker to an 'iternal' maya script!). either reboot maya or source the script. thats all! oh, to change what smoothness the keys set, change the number after $smoothness above, currently 1 is none, 2 1, 3 2.

yay!

Raptor235
08-19-2002, 01:13 PM
Nice WOrk~!!!! Thansk so much and ya don't worry I got a lot of other stuff I can try to learn mel on hehe...umm do you have a link to Bryan Ewert's page?

playmesumch00ns
08-19-2002, 01:20 PM
There's a couple of scripts on Highend (http://www.highend3d.com) for doing exactly this, but as -wT- says, the best way is to write it yourself. After all you gotta start somewhere.

Raptor235
08-19-2002, 03:39 PM
Thanks wrend it works great hehe but I got one more spin for you I'm not sure if you can do this but can you do multiple objects as well? I tried it and it didn't work is it much more work to add that?

wrend
08-20-2002, 03:09 AM
doh! that was the other thing i was going to set, i forgot. easy to sort tho.. just, ..oh:

$ob = `ls -sl -l -dag`;
for ($o in $ob){
$smov = `listConnections -t polySmoothFace $o`;
if (size($smov)==1 && `nodeType $smov` == "polySmoothFace")
setAttr ($smov[0] + ".dv") ($smoothness - 1);}

.... yay!

playmesumch00ns, yeah, whoops! - i was searching for something else on highend last night just after i'd posted and found all those scripts to do this kind of thing, .. but looking back now none of them bound this to the normal display lod keys, so i guess its worth something, at least here ..i wouldnt cluter up highend w this.

cheers.

-wT-
08-20-2002, 03:53 PM
I don't really care if there's a script already for something what I want and will try to script myself, it's just more fun to do it myself, and make it work better than the other script :) (Though, I haven't actually done any big scripts yet)

Like the Mikkel Jans poly-tools, he started to make 'em about the time I started my first script, and while we all have a great MJPolyTools amongst us, I still think I can make the connect edges/vertex script much better :) (Too bad I haven't done the script for ages, the R2 of it is currently in the works, but with school and my lazyness, I doubt I will ever publish it)


So, to learn MEL, stop using highend3d.com :) (Ok, you can use the forums, but don't ya dare to touch those scripts there boy! :shame: )

Raptor235
08-20-2002, 03:59 PM
heheh I have another script which is a bit more complicated that I need writen it would be a great tool to have...here is a description

I have documented a bit of how it will work but I need a bit of help with the syntax well all the syntax I'll try to do it myself but some help would be great.

Here is the msg from long ago:

Could someone please write a small script to even all selected edges so that when I'm modeling I could select 5 edges and hit the script and it would make a perfect pentagon or 4 would make square ect ect I think Mirai has something like that I seen it used but it shouldn't be too hard to make so if you could


Declare Variables

Variables

Total Edges = Get
Total Lengh = Get
Avg Lenght = ?

Count Edges Selected
Put Into Variable

Add Lenght of Selected Edges
Put Into Variable

Simple Formula
Total Lenght / Total Edges = Avg Lenght

Make all selected edges = avg lenght

I was told that also it might be a bit tricky to have all the vertecies line up on the same plane I dunno maybe you can avg the position as well and use that to line them up

CGTalk Moderation
01-13-2006, 02: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.