check for duplicate render elements and delete
Is it possible to check for duplicate render elements by Element name and ObjectID and delete duplicates. I have done endless Google searches and cant seem to find anything referring to deleting duplicate render elements. I'm also fairly new to maxscript so I am struggling to know where to even start.
Obviously I would tend to name elements uniquely but have recently come across duplications when merging elements in from other scenes. It's not the end of the world, but you end up with multiple renders of the same ObjectID which I guess uses unnecessary RAM at render time.
Example:
Matte (ObjectID = 50) Duplicated because of same name and ID
Matte (ObjectID = 50) Duplicated because of same name and ID
Matte (ObjectID = 30) Not Duplicated as ObjectID is different
(Delete all duplicates, leaving one iteration of the element in the list)
Any help would be much appreciated.
Comments
Anubis, That's brilliant!
Anubis,
That's brilliant! Thanks a lot for that, very much appreciated!!!
u'r welcome ;)
I not tested the code,
so I glad to know that it works
my recent MAXScripts RSS (archive here)
maybe this will do the job?
my recent MAXScripts RSS (archive here)
Can I attempt this on any
Can I attempt this on any other platform? The syntax will be different of course. But code can be the same I hope.
vente appartement marly le roi
Yeah go for it. Not sure
Yeah go for it. Not sure exactly what you mean by other platform, but if it helps get nearer the answer then thanks for the help.
Hi, you can use rem =
Hi, you can use
to get access to the render elements, have a look at
or "Interface: RenderElementMgr" in the MXS documentation for commands are available and how they work.
Cheers
Never get low & slow & out of ideas
br0t, thanks for the reply.
br0t, thanks for the reply. I've looked through the max docs and roughly understand which methods are needed.
In psudo code I would need something like below: (also to note i'm sat on a train at the minute with very little reference, but something along these line, although I know its a million miles away from correct syntax etc)
dupNames = #()
allNames = #()
re = MaxOps.getCurRenderElementMgr()
fileName = re.GetRenderElementFilename
if (fileName == allNames.filename && gBufferID == gBufferID)
then append dupNames fileName
delete dupNames fileName
-- basically if any duplicated element name is found in the array of all element names, hold this in a dupsNames array and then delete all duplicates.
Sorry for the bad example but like I say I have nothing to hand apart from my phone. There maybe a better way to tackle this without the need to store duplicates before deletion. I kind of know what elements I need, I just cant string them together.
It would really appreciate any help to get to a workable script.
Thanks again.