Bone not getting added to skin


#1

This is not 100% reproable…
I am making a bone via script and liking it to another object, then later I am adding that bone to a skin modifier, I do test to verify that the bone is there, and print the name before and after adding the bone to the skin mod. BUT sometimes the bone does not get added but instead inserts the bone’s parent. No error just goes to parent object. Then when I go to fix the issue in the skin mod the bone is not available in the pick bone menu??? What is going on, and what can I do to get the bone to always get added to the skin modifier, and not its parent? Why would the bone not show up in the skin selection menu?

--  In house tools stripped out. But still creates error. 
dum = dummy()
b = bone()
b.name = "Root"
maxOps.CollapseNode b on
b.parent = dum
----
-- Here user does some stuff, and comes back before exporting. 
bb = box()
macros.run "Modifier Stack" "Convert_to_Poly"
select bb

----
-- Bone selected goe.
Sel = Selection as array
-- Gets the first one with this name.
theBone = getNodeByName "Root"

 if theBone == undefined then
 (
	 messagebox "Could not find bone with supplied name, check again or import or create an new rig."
 )
 else
 (
	if selection.count == 0 then
	(
		messagebox "Nothing is selected.  Select something and try again."
	)
	else
	(
		print ("-------")
		print (theBone.name )
		
		max modify mode
		For k in Sel do
		(
			if superclassof k == GeometryClass then 
			(
				theGeo = k
				convertToMesh theGeo
				theSkin = Skin()
				addModifier theGeo theSkin
				max modify mode
				modPanel.setCurrentObject theSkin
				--add a bone
				skinOps.addBone theSkin theBone -1
				print ("##--")
				print (theGeo.name)
				print (theBone.name )
			)
		)
		select Sel
	)
)	


#2

I was unable to repro this bug when I switch from a bone to a geo bone.