Notifications
Clear all

[Closed] How to script Create End bone on a bone chain?

Greetings everyone,
I am learning MaxScript, and I wrote a script that automates bone chain creation.
I’ve found it’s difficult to get the right syntax to “Create End” bone, as in the Bone Tools macro dialogue.
I found code that PiXeL_MoNKeY posted 6 years ago. But I can’t get it to work.

My code creates an end bone “handBoney” at the end of a chain of arm bones, ending with “wristBoney”.

Here’s the code I have:

macros.run "Animation Tools" "BoneAdjustmentTools"
	select wristBoney
	on CreateEnd_btn pressed do
	(
		undo "Create End" on
		(
		--select wristBoney
		if (selection.count == 1) do
			(
				with Animate Off
				( 
				local wristBoneyTrans = wristBoney.transform
				local wristBoneyPos = wristBoneyTrans.translation
				local handBoney

				with redraw off 
					(
					handBoney=BoneSys.createBone wristBoneyPos (wristBoneyPos+6) wristBoney.dir
					handBoney.transform = wristBoneyTrans
					in coordSys Local move handBoney [wristBoney.length,0,0]
					handBoney.name=handPrefName + handName + "_bone"

					handBoney.parent	= wristBoney
					putChildIntoAssembly handBoney

					handBoney.width	= wristBoney.width
					handBoney.height	= wristBoney.height
					handBoney.taper	= 90
					handBoney.length	= (wristBoney.width+wristBoney.height)/2
					handBoney.wirecolor = wristBoney.wirecolor
					)

				redrawViews()

				) 
			)
		)
	)
	while false
	
	--parent the bones in the arm joint chain
	forearmBoney.parent = shouldBoney
	wristBoney.parent = forearmBoney
	handBoney.parent = wristBoney

When it gets to the parenting portion at the end, it throws an error. Something about the command that presses the button for the Create End button…
Thanks for the help!

1 Reply

Ok, I solved this. It’s much easier to just create an ending joint with bonesys instead of trying to access the Bone Tools window, so I will just stick with that.
Thanks!