Okay, I haven’t followed this section of the forum. I don’t know if this is the place to post a WIP thread, but I do know that 98.2% of the public don’t believe that rigging done in Python code belongs aside artwork. And, I also know that I am a beginner.
What I’m working on is an add-on to create a character body rig given a Genesis or Genesis2 model, imported by .dae file, from DAZ Studio. It doesn’t yet create “my rig”, but it does clean out unused bones, set proper bone rolls, and rename bones with DEF- prefix and proper .L/.R suffix. I don’t know how badly it will choke on a Genesis3 armature, since I don’t have one to experiment with. It is still a WIP, but I thought I’d post the code, since it is already quite useful for cleaning up a Genesis1/2 dae import.
It works as an add-on. Just drop it into your addons folder and it shows up in the armature property panel. I would really like feedback on that portion of the code(Gen2_Rig). It is barebones, and I don’t really understand everything involved in getting that button into the properties panel. I’ve taken code from Rigify’s ui.py file, and stripped it to fit what I’m doing. That portion seems to operate correctly, but I’m curious if it’s missing anything.
At this point, the only real caveat is, it expects the object and it’s armature to both be named “RootNode”(That’s the default for a DAZ dae.)
The guts of the code(Gen2_Generate) is nothing elegant. It’s just top-down, brute force, step by step.
My biggest question at this point is about my selection routine. Send it a list of bone names, it selects them and sets the first one active. Searching in my google says to switch to pose mode to set the active bone, and try as I might, I can’t make it work without switching modes. Is there some way around that? So far, the program isn’t doing anything really intensive, yet it’s getting slower and slower as I add to it. I think that mode switch is sucking on it’s mojo. Any thoughts? Advice?
def select(lst):
# lst is list of bone names
bpy.ops.armature.select_all(action = "DESELECT")
# if lst is empty, deselect all and return
if lst == []:
return
for name in lst:
# test if it's a valid bone name
if arm.edit_bones.get(name):
# select it
arm.edit_bones[name].select = True
# set the first name in the list as active
bpy.ops.object.mode_set(mode='POSE')
arm.bones.active = arm.bones[lst[0]]
bpy.ops.object.mode_set(mode='EDIT')
Wow, the attachment option say my .py file is invalid. I assume that’s a forum setting??? But I don’t know why it would be. I’ll look into that, but I’m on my phone so I slow, and stupider than IRL. I’ll get it sorted.
EDIT: Oop, it’s gotta be zipped up.
Attachments
Gen2_Rig.zip (3.45 KB)