Welding Points
-
On 10/08/2017 at 08:41, xxxxxxxx wrote:
`I import a mesh of triangles (from an OBJ file). The overall object is a deformed plain. When I throw it under a subdivision surface, it suddenly got holes. Obviously, not all triangles in the mesh are actually welded together.
What I now need to do, is to "weld" all points that are at identical locations into ONE point.
I found a way to do that by executing an "Optimize Mesh", either through the menu or CallCommand, however, this will completely break if the user has changed the setting of "Optimize Mesh".
Is there a programmatic way of doing that? It might be doable through c4d.utils.SendModelingCommand (but that documentation is kind of minimal) or by iterating through all points and doing some magic (but that raises the question on how to efficiently find all "identical" points and how to merge them without breaking any polys and/or UV setups).
Any inputs welcome
-
On 10/08/2017 at 10:31, xxxxxxxx wrote:
Throught SendModelingCommand you can fill a BaseContainer with option so I guess it will do everything you want.
import c4d def optimize(obj, tolerance) : doc = c4d.documents.GetActiveDocument() doc.AddUndo(c4d.UNDOTYPE_CHANGE, obj) settings = c4d.BaseContainer() settings[c4d.MDATA_OPTIMIZE_TOLERANCE] = tolerance settings[c4d.MDATA_OPTIMIZE_POINTS] = True settings[c4d.MDATA_OPTIMIZE_POLYGONS] = True settings[c4d.MDATA_OPTIMIZE_UNUSEDPOINTS] = True c4d.utils.SendModelingCommand(command=c4d.MCOMMAND_OPTIMIZE, list=[obj], mode=c4d.MODELINGCOMMANDMODE_ALL, bc=settings, doc=doc) def main() : doc.StartUndo() optimize(op, 0.001) doc.EndUndo() c4d.EventAdd() if __name__=='__main__': main()
It's look like you already read the document but in case you didn't https://developers.maxon.net/docs/py/2023_2/modules/c4d.utils/index.html?highlight=sendmodelingcommand#c4d.utils.SendModelingCommand
-
On 10/08/2017 at 13:14, xxxxxxxx wrote:
Thx! Works like a charm
PS: I removed the duplicate line