noobs needs help with a simple problem

noobs needs help with a simple problem

Anonymous
Not applicable
272 Views
7 Replies
Message 1 of 8

noobs needs help with a simple problem

Anonymous
Not applicable
Hi guys,

I haven't written a single script yet, I just came across a tedious task of breaking up a poly model into separate pieces, I'm sure there is a simpler way to do it other than the obvious: manually click-select poly object > click-sub_object face> click-select face> click "detach" button .... move on to the next face and 'rinse and repeat'... There is gotta be a better way can anyone help???

thanks again.
0 Likes
273 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
EDIT: My bad, I thought you were using Maya too...
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thanks for the quick response, but the result is the same --- after extruding by 0 , inverting selection and deleting the original faces I am still left with a single object and detached faces, my goal is to break apart one object's faces into separate objects,

I can do it manually on a lowpoly model, but I have a 5k face polymodel and to do it by hand is gonna give me major pain.

Theoretically I need a script that would calculate all faces on the polymodel and then select each one and detach it to a new object, and preferably changes the name of new objects and transfers the count.
0 Likes
Message 4 of 8

rvignone
Enthusiast
Enthusiast
never mind me, thought you were using Maya 😛
Good luck!

-R
Robert Vignone
http://www.robertvignone.com
Win 7 | I7 @ 3.6ghz | 24GB DDR3| GTX580 |
0 Likes
Message 5 of 8

Anonymous
Not applicable
Here is a possible implementation:

macroScript Explode2Poly category:"Forum Help"
(
on isEnabled return selection.count == 1 and superclassof $ == GeometryClass and classof $ != TargetObject
on execute do
(
convertTo $ Editable_Poly
for f = polyOp.getNumFaces $ to 1 by -1 do
polyOp.detachFaces $ #{f} asNode:true name:(uniquename ($.name+"_Face"))
delete $
)
)


Copy to a MAXScript Editor tab, press Ctrl+E to evaluate and Customize User Interface from "Forum Help" category to create a toolbar button.
Select a single geometry object and hit the button. The object will be converted to Editable Poly first, then each polygon will be detached to a separate scene object with the same name as the original but with suffix _FaceXX where XX is a number.
Finally, the original now empty object will be deleted.

Keep in mind that exploding 5K faces to 5K objects will cause a large undo record and lots of viewport caching. You might want to disable undo creation by adding 'with undo off ()' around the content of the 'on execute do()' handler.

Also note that the pivot point of each new object will remain where the original object's pivot was. If this is not desired (usually it is), you could add CenterPivot() / ResetXForm() / CollapseStack() calls for all resulting objects, or just select them all and center/reset XForm/Collapse manually.

Also note that 90% of this script were already in the MAXScript Help in the description of the polyOp.detachFaces function, just without the single object option. So you could have figured it out yourself. Believe me, it is a better feeling to do it yourself 😉
0 Likes
Message 6 of 8

Anonymous
Not applicable
Here is a script that will take all currently selected objects and break all the faces into nodes with unique names. Note that this script will only work on editable polys. I wrote this very fast and only did a few tests but it seems to work just fine.


for currentObj in selection do
(
if classOf currentObj == Editable_Poly do
(
currentName = currentObj.name
counter = 1

for currentFace = polyop.getNumFaces currentObj to 2 by -1 do
(
polyOp.detachFaces currentObj #{currentFace} asNode:true name:(currentName + "_Face" + (counter as string))
counter += 1
)

currentObj.name = (currentName + "_Face" + (counter as string))
)
)

0 Likes
Message 7 of 8

Anonymous
Not applicable
Thanks guys 🙂

worked like a charm, the more I think up effects and experiment with MAX the more I realize that any stunning visual effects require knowledge of MAXSCRIPT, I can only do so much with regular commands. I must admit that math and programming doesn't come easy for me.

Borislav can you suggest good reading material to get me started in MAXSCRIPT some practical examples perhaps? l will put in my time reading standard MAX files, but if you know of another route, I would appreciate it --- will keep me from asking stupid questions 🙂

Thanks again.
0 Likes
Message 8 of 8

Anonymous
Not applicable
Shameless Plug: I would suggest my CG-Academy DVD "MAXScript For The Masses" which was created specifically for people who don't want to become programmers but want to use MAXScript practically. It teaches the basics of what anyone using Max must know about MAXScript. There is also an introduction from the same source which explains the principles of programming, recorded by my Frantic Films TD colleague Laszlo Sebo. The two DVDs come in a bundle, too.

John Wainwright, the original programmer of MAXScript, recorded a MAXScript 101 DVD which might still be available. It was a great overview of all areas of the language.

Autodesk is publishing a set of Podcast I recorded that a free for Subscription members. They show how to write simple scripted plugins. They were supposed to be released once a month, but are a bit behind the schedule.

For people who don't want to know math but have to use it (like me, I hate math!), there is the DVD "The Matrix:Explained", but it is a lot more advanced. For VFX artists, I have also recorded two DVDs on scripting Particle Flow.

And then there is the MAXScript Reference. It is not a read. It is a Reference and you should consult it all the time (I do). But it has a couple of How To tutorials that might give you some ideas and which provide line-by-line explanations WHAT is going on in the script and HOW it works. I would recommend reading at least those.
0 Likes