Hi!
Trying to figure out how to find a control rig based on the current selected control in the viewport, with Python. I’d like to, ultimately, get around the problem that the Pose Tool has of selecting controls on every control rig in the sequencer. It’d be ideal to filter the selection to the selected Control Rig vs all Control Rigs in the Sequencer…
Any help would be appreciated!
Thank you!!!
Actually, just figured something out
import unreal
#Get current level sequence
lvl_seq = unreal.LevelSequenceEditorBlueprintLibrary.get_current_level_sequence()
print(lvl_seq)
#Get all rigs in level sequence
rig_prxs = unreal.ControlRigSequencerLibrary.get_control_rigs(lvl_seq)
active_rig = []
#Iterate through control selection to find the rig the selection belongs to...
for i in range(len(rig_prxs)):
rig = rig_prxs[i].control_rig
#Query selected control in Sequencer
sel_ctrl = rig.current_control_selection()
try:
if len(sel_ctrl):
active_rig.append(rig_prxs[i])
except:
print('No rig found')
rig.clear_control_selection()
#Current rig
rig = active_rig[0].control_rig
rig.select_control("upperarm_r_fk_ctrl")
rig_ctrls = rig.current_control_selection()
print(rig_ctrls)
1 Like
I’ve been doing the same thing the last little while with blueprints too using a very similar method to what you’re doing in python. Just note that this requires a channel (or in the context of the viewport a handle) to be selected. If you select just the Control Rig track in sequencer (without selecting a control channel), this won’t yield any selections. I’ve been trying to figure out if there is a way to figure out context without selecting a control/channel and just the Control Rig track.
This is helpful in buiding better UX for editor utility widgets in scoping the currently worked on control rig. It’s also helpful to determine which layer is being currently the active index when using additive layers. With selected a selected control/channel, it’s easy to extrapolate this, but just selecting the control rig track or getting the active control rig track without that context seems not possible at the moment with my digging. I’ll loop back to this thread if I can find a way to do it.