[Closed] align vertex
Hi guys!
I’ll make it fast.
I have 2 objects with the same number of vertices:
- one is named $target. it’s an editable mesh
- the other is $source. it has some modifiers and on top there is an edit poly modifier.
What I need to do is to align all the vertices of $source with those of $target (vertex number 1 of $source must be at the same position than vertex number 1 of $target …)
unfortunatly the morpher modifier is of no use in this case.
Can anybody help please.
Never tried it but you can get the position of your target vert and asign it to your source vert. The only problem I see is on how to get the verts in same order for both objects …
That seems very easy
objSource=$source
objDest=$target
theVerts=#{1..objSource.numVerts}
for v in theVerts do (
coord=polyOp.getVert objSource v
meshOp.setVert objDest v coord
)
Keep me informed if that do the trick
Sorry prettyPixel, may be I didn’t explain well.
In fact coord must be the coordinates of objDest’s vertices. So I reverted the lines in the loop in your script:
for v in theVerts do (
coord=meshop.getVert objDest v
polyOp.setVert objSource v coord
)
But I get an error in he listener:
–Runtime error: EPoly operation on non-Editable Poly:–
So I used the macrorecrorder an after some editing I made this script:
objSource=$source
objDest=$target
theVerts=#{1..objSource.numVerts}
select objsource
subobjectLevel = 1
for v in theVerts do (
coord=meshop.getVert objdest v
$.modifiers[#Edit_Poly].SetSelection #Vertex #{}
$.modifiers[#Edit_Poly].Select #Vertex #{v}
$.modifiers[#Edit_Poly].SetOperation #Transform
$.modifiers[#Edit_Poly].MoveSelection coord
$.modifiers[#Edit_Poly].Commit ()
)
subobjectLevel = 0
clearSelection()
With this one I don’t get errors but the only vertex that moves is the last one I moved manually !
I attached a file that contains a source and a target objects. this situation is similar to the file I’m working on.
Indeed moveSelection does not seem to work.
objSource=$target
objDest=$source
theVerts=#{1..objSource.numVerts}
theVertsPos=for v in theVerts collect (meshop.getVert objSource v)
max modify mode
select objDest
edPolyMod=objDest.modifiers[#Edit_Poly]
--edPolyMod=Edit_Poly()
--addmodifier objDest edPolyMod
modPanel.setCurrentObject edPolyMod
edPolyMod.SetEPolySelLevel #Vertex
for v in theVerts do (
edPolyMod.SetSelection #Vertex #{v}
edPolyMod.SetOperation #Transform
edPolyMod.MoveSelection theVertsPos[v]
-- edPolyMod.MoveSelection [100,100,100]
edPolyMod.Commit ()
)
edPolyMod.SetSelection #Vertex #{}
edPolyMod.SetEPolySelLevel #Object
max views redraw
I do not have any solution. Sorry