Hi everyone,
I’m 100% new to maxscript (literally started yesterday, and this forum is the best learning resource so far).
I’m currently trying to write a script that:
Having a mesh with Edit Poly, and some faces selected; it creates dummies on the center of each selected face and adds an Attachment Constraint to it (so when I later move a face, it moves the dummy with it).
I’m so far very happy with what I managed to do:
- I get the selection
- run thru it
- create a dummy
- place at the center of the face
Now, I’m struggling to add an Attachment Constraint:
The farthest I got was to add an Attachment Controller to the Position, but then the dummies get all misplaced and it indeed replaces the Position XYZ with an Attachment within the Controllers (probably not good).
-----------Make sure it has Edit Poly modifier---------------
-------------------------------------------------------------
obj = (selection as array)[1]
--only for Editable Poly:
--selFaces = GetFaceSelection obj
modifierCurrent = modpanel.getCurrentObject()
selFaces = modifierCurrent.getSelection #Face node:obj
if not selFaces.isEmpty do
(
for face in selFaces do
(
center = polyop.getFaceCenter obj face
dummyBox = Dummy pos:[center.x,center.y,center.z]
dummyBox.boxsize = [1,1,1]
attachController = Attachment()
attachController.node = obj
attachController.align = true
dummyBox.pos.controller = attachController
keyNew = AttachCtrl.addNewKey attachController 0
keyNew.face = face
keyNew.coord = center
)
)
What I need is what you can get by:
-selecting dummy
-Animation -> Constraints -> Attachment Constraint
by doing so, it adds an Attachment Constraint and don’t mess with the controllers. Then one needs to manually pick the object to link to and the position of the constraint.
Can anyone please help me with this? Please keep in mind I’m an experienced programmer, but a total zero, newbie, loser in Maxscript (and I’m struggling a lot with its syntax, classes, properties, etc.)
Thank you very much!!!