Quantcast
Channel: mel wiki
Viewing all articles
Browse latest Browse all 610

How can I snap mesh together by 3 points?

$
0
0
Maya's tool for this is a bunch of mel wrapper code. If you want to proceduralize it, you can use this hacky way below:
It will snap all mesh to the last picked, based on the same 3 verts that exist on all mesh. It does this by selecting the 3 verts in order, on pairs of mesh, then running the mel that expects the selection.
# Snap mesh by 3 verts!

import pymel.core as pm
# All mesh must have the same vert count.
# Define 3 verts here that are the same on all mesh.  This will snap all mesh
# selected to the last mesh picked.
snapVerts = [94,95,114]

sel = pm.ls(selection=True)
mesh = pm.listRelatives(pm.ls(selection=True), shapes=True, type='mesh', noIntermediate=True)
targMesh = mesh.pop(-1)

for m in mesh:
    pm.select([m.vtx[i] for i in snapVerts])
    pm.select([targMesh.vtx[i] for i in snapVerts], add=True)
    pm.mel.eval("snap3PointsTo3Points(0)")
pm.select(sel)

Viewing all articles
Browse latest Browse all 610

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>