Blender 2.8 Exporter Error

So I ended up with a situation where I needed to add a few more bones to my rig in blender.

I subdivided the armatures that were needed deleted the old modifiers and vertex groups then re-skinned the mesh weights.

I have done this in the past no problem, but now its acting up on export. I have verified that the bone exists…

========= An error was encountered =========
  File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\json_exporter.py", line 94, in execute
    self.skeletons.append(Skeleton(object, context, skeletonId, self.settings.ignoreIKBones))
  File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\armature.py", line 84, in __init__
    self.bones.append(Bone(bone, bpySkeleton, self.bones))
  File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\armature.py", line 23, in __init__
    self.parentBoneIndex = Skeleton.get_bone(bpyBone.parent.name, bonesSoFar).index if bpyBone.parent else -1
  File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\armature.py", line 162, in get_bone
    raise Exception('bone name "' + boneName + '" not found in skeleton')
ERROR:  bone name "Lower.Thigh.L" not found in skeleton
========= end of processing =========

UPDATE
so I have narrowed it down to the fact that I subdivided the bone… let me see if I can recreate!

UPDATE2
maybe I spoke too soon… hmmm… I was not able to recreate in a simple setup.
In the exporter I see

# should not happen, but if it does clearly a bug, so terminate

o_O…

UPDATE3

So I added to the line right before the Error Drop:

for bone in bones:
            Logger.log("Bone:"+bone.name)

Which made the log output be:

Python World class constructor completed
	processing begun of skeleton:  Root, id:  0
		processing begun of bone:  Crotch, index:  0
		processing begun of bone:  Upper.Thigh.L, index:  1
		processing begun of bone:  Upper.Calf.L, index:  2
	Bone:Crotch
	Bone:Upper.Thigh.L
========= An error was encountered =========
...

I think its interesting that it says its trying to process the calf at index 2. Is there a way to verify the index of the each of the bones? I would imagine that is just done through hierarchy.

1 Like

For something like this, a Blend file is definitely going to be required. It could be an un-forseen bug, but if I put a comment that says this should not happen, probably better to address the skeleton than screw with the program. There could then be other assumptions you run a foul of. I would not be able to look at it for maybe a week. Do not know if @gryff is interested, or could look at it earlier than that.

FYI, the index thing has nothing to do with Blender. It is for the export. This is the values which get placed in the matrix indices for each vertex of each mesh. means nothing to Blender. Bones are processed however Blender gives them to me. Program does not care.

1 Like

@JCPalmer : if @Pryme8 wants to post the .blend file, I will take a look at it Jeff. But if it is a code issue, then I might not find anything as I can’t compete with you guys in that area :upside_down_face:

cheers, gryff :slight_smile:

Thanks, but maybe his surgery resulted in some odd thing like multiple root bones. Though that should still work, any triage you can do would be helpful.

Ill send it over Gryff thanks! I have a suspicion I found a bug.

Looked at code. Processing getting the parent index of bones in a separate Loop. Should probably be ok now.

@Pryme8 and @JCPalmer : So has the issue been fixed, as I see no link to a file? You can always PM me the link, if you are worried about ppl stealing your character.

cheers gryff :slight_smile:

I will pm you the stuff, taking the day off. Ill get at you tomorrow for sure though.

I fixed it without the file. @Pryme8 get latest exporter.

1 Like

So it twas a bug?

I have no idea. After looking at the code, I just recoded for the only thing it could possibly be.

1 Like

Cool Ill take a look on git to see what code has changed, and then make sure I incorporate my mesh.py changes in.

I was really disappointed with what github did. It deleted every line and then added them all back. Here are the changes to Bone & Skeleton from Netbeans (old on left). Basically, I pulled finding the index of the parent out of the Bone constructor. This relied on Blender ordering the bones of a parent before children.

That makes total sense. Thank you for the fix!

Also I have noticed git does that a lot, I wish I knew how to not make it do that as well sometimes. About to test it now, but from just reading it seems on point. @JCPalmer Thank you a lot for your help my friend.

UPDATE
Looks like it worked!
dope, I should push my vertex group changes here at some point too to the exporters. As it is it does not add anything to the file (for file size reason), but if you told told the exporter in a menu item to export specific groups on the mesh it will have them listed in json format in the log, which are useful for lots of reason.

Figured there would be others that might need this.

UPDATE

Everything seems to work, except now if I scale a skeleton from the root bone and let all the “children” be scaled

bone = scene.getBoneByName('Crotch')					
bone.scale(d,d,d,true)

Basically what happens now is all the bones but the ones that were added through subdivision do not get scaled now, I don’t even know where to start debugging this. @JCPalmer I know you are a busy man but any ideas where I can look?

I am able to manipulate them with

bone.scale(weight.x,weight.y,weight.z,false)

Directly, but anytime I add the children flag the later added bones freak out.

Start with the obvious check that every bone has a parent. What if it is expected in a. Babylon file that parents are listed first?

They are coming back with parent as null and _parent as the correct value, once in the scene.

In the .babylon file all the parent indexes are correct.

I really don’t want to have to do a re-rig but at this point it sounds like I need to, if we cant figure out this hierarchy problem. (at some point it should be figured out though cause Im pretty sure its a bug)

I just got what you were saying, so maybe I need to reorder the skeleton list in the .babylon file?

And now looking at the files I think you are 100% right… in a working one the bones are parents are listed before the children on the bones list and in the unworking one I have like bone ID 3 referencing bone ID 43 are its parent.

So I am guessing what I would need to do is a pass where I increment through the bones and order them correctly by referencing their parent?

	bone.index:0   bone.parentBoneIndex:-1
	bone.index:1   bone.parentBoneIndex:0
	bone.index:2   bone.parentBoneIndex:42
	bone.index:3   bone.parentBoneIndex:44
	bone.index:4   bone.parentBoneIndex:3
	bone.index:5   bone.parentBoneIndex:3
	bone.index:6   bone.parentBoneIndex:44
	bone.index:7   bone.parentBoneIndex:0
	bone.index:8   bone.parentBoneIndex:7
	bone.index:9   bone.parentBoneIndex:8
	bone.index:10   bone.parentBoneIndex:9
	bone.index:11   bone.parentBoneIndex:10
	bone.index:12   bone.parentBoneIndex:11
	bone.index:13   bone.parentBoneIndex:12
	bone.index:14   bone.parentBoneIndex:11
	bone.index:15   bone.parentBoneIndex:14
	bone.index:16   bone.parentBoneIndex:46
	bone.index:17   bone.parentBoneIndex:47
	bone.index:18   bone.parentBoneIndex:17
	bone.index:19   bone.parentBoneIndex:18
	bone.index:20   bone.parentBoneIndex:17
	bone.index:21   bone.parentBoneIndex:20
	bone.index:22   bone.parentBoneIndex:17
	bone.index:23   bone.parentBoneIndex:22
	bone.index:24   bone.parentBoneIndex:11
	bone.index:25   bone.parentBoneIndex:24
	bone.index:26   bone.parentBoneIndex:48
	bone.index:27   bone.parentBoneIndex:49
	bone.index:28   bone.parentBoneIndex:27
	bone.index:29   bone.parentBoneIndex:28
	bone.index:30   bone.parentBoneIndex:27
	bone.index:31   bone.parentBoneIndex:30
	bone.index:32   bone.parentBoneIndex:27
	bone.index:33   bone.parentBoneIndex:32
	bone.index:34   bone.parentBoneIndex:10
	bone.index:35   bone.parentBoneIndex:10
	bone.index:36   bone.parentBoneIndex:0
	bone.index:37   bone.parentBoneIndex:43
	bone.index:38   bone.parentBoneIndex:45
	bone.index:39   bone.parentBoneIndex:38
	bone.index:40   bone.parentBoneIndex:38
	bone.index:41   bone.parentBoneIndex:45
	bone.index:42   bone.parentBoneIndex:1
	bone.index:43   bone.parentBoneIndex:36
	bone.index:44   bone.parentBoneIndex:2
	bone.index:45   bone.parentBoneIndex:37
	bone.index:46   bone.parentBoneIndex:15
	bone.index:47   bone.parentBoneIndex:16
	bone.index:48   bone.parentBoneIndex:25
	bone.index:49   bone.parentBoneIndex:26

above is the output of the order and parent indexes as is.

Actually as I am doing more testing its looking like these last changes broke the skeleton stuff… I mean it works but it does not now when you start working with them.

I did a whole rerig, and am having troubles with some of the same issues but in a different way now.

Ill do one more re-rig, but I’m pretty sure anytime you get into an complex parenting things go haywire.