I’m making a tool for the optimization for scenes with large numbers of objects - I’m using Python in 3ds Max 2016, and MaxPlus specifically. Now there’s a problem i’ve run into that has me running into a wall: I would like to avoid going between Python and MaxScript all the time to execute a mesh combine operation ( never mind the difficulty in passing object references between the two ), and so I am trying to perform the merge operation in Python.
Now, for this purpose, the only available method I’ve found whose name seems to describe it doing what I need, is Mesh.CombineMeshes, as documented here: http://docs.autodesk.com/3DSMAX/16/ENU/3ds-Max-Python-API-Documentation/index.html?url=files/GUID-1AC35645-91D7-4DBE-9714-681C8CC8700F.htm,topicNumber=d30e920
Based on the extremely limited documentation, I think this method needs at minimum three arguments, all three of the Mesh Class. My approach so far is the following:
Make an empty geometry object: ( code lifted directly from the API documentation )
geom = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.TriMeshGeometry) tri = MaxPlus.TriObject._CastFrom(geom) mesh = tri.GetMesh()
get meshes from the objects I want to merge: ( note: the two lines with mesh1 and mesh2 are being executed in a for loop that loops over the array “self.objects[1:]” - meaning all objects should be merged with the first object in that array.
def getObjectMesh(self,obj): geom = obj.GetObject().AsTriObject() mesh = geom.GetMesh() return mesh mesh1 = self.getObjectMesh(self.objects) mesh2 = self.getObjectMesh(obj)
And lastly, perform the merge: ( or try to )
When executing this code, max gives me the following error:
File "C:\Program Files\Autodesk\3ds Max 2016\MaxPlus.py", line 15115, in CombineMeshes return _MaxPlus.Mesh_CombineMeshes(*args) RuntimeError: Unknown MaxPlus Exception
Sadly, when you go look in the given file at that line, the line is just: ( this is literally the entire function )
Does anyone know what I’m doing wrong / how to use the method? Would be much appreciated