[Closed] attaching mesh based name selection
Hi all, i have just writen a script that creates a mesh where a point helper is and then puts and attachment constaint on a new point helper and then links the original point helper to the new one. the point of this is so i can used skin morph to control these points. the problem i am haveing is trying to get all the new meshes to attach and then make all the points attach to the correct face. unfortunaly when i use the attach function it dosnt seem to work in the right order. what should be hapening is the face# should corispond with the point object in the newpoint helper array.
anyway i seem to be missing somthing so if anyone can see anything obvious or if there is a better way of doing this please let me know.
cheers
john
heres the code- make afew point helpers and run the script on the selection.
myFaces=#()--array of face box objects made
myPointArrays=#()
fn makeMesh myHelp =
(
--creates the box and recentres it
myboxsize = myHelp.size/2
print myboxsize
mynewbox = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:myboxsize width:myboxsize height:myboxsize
CenterPivot mynewbox
mynewbox.transform = myHelp.transform
convertto mynewbox editable_mesh
--creates the box newface and deletes old
myverts = #(2,6,7)
mydelFaces = #{1..12}
meshop.createPolygon mynewbox myverts
meshop.deleteFaces mynewbox mydelFaces
append myPointArrays mynewPoint
append myFaces mynewbox --adds new object to the array for later use
)
for myHelp in selection do
(
makeMesh myHelp
if myFaces.count > 1 then --attaches all the newly created boxmeshes to the first mesh
(
newobj = myFaces.count
attach myFaces[1] myFaces[newobj]
)
--adds the position constain to the object and connects it all up
myboxsize = myhelp.size/2
myNewPoint = point size:myboxsize centermarker:off axistripod:off cross:off box:on
myNewPoint.wirecolor = color 0 0 0
myAttach = Attachment()
myNewPoint.position.controller = myAttach
theface = myFaces[1]
myAttach.node = theface
addNewKey myAttach 0f
theAKey = AttachCtrl.getKey myAttach 1
theAKey.face = theface.mesh.numfaces
theAKey.coord = [0.5,0.0]
addNewKey myAttach 0f
myhelp.parent = myNewPoint
)