Sync Channel to Original

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
A.Evseeva
Posts: 61
Joined: Wed Apr 08, 2015 8:43 am
Contact:

Sync Channel to Original

Post by A.Evseeva »

Is it possible to execute the subj. command with LUA?
(It is about the right mouse button option, clicking on reference layer's timeline channel)
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Sync Channel to Original

Post by synthsin75 »

There is no access to right-click with Lua in AS.
User avatar
A.Evseeva
Posts: 61
Joined: Wed Apr 08, 2015 8:43 am
Contact:

Re: Sync Channel to Original

Post by A.Evseeva »

Does it mean no way to sync channel with original? No place this data stored in?
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Sync Channel to Original

Post by synthsin75 »

There is "bool UpdateReferencedLayer(MohoLayerRefSyncOptions *syncOptions = NULL)" to update reference layer. I don't *think* there's a command for syncing individual channels though.
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

Just found this thread. I'm still learning Moho scripting basics but this is related to something I want to do.
synthsin75 wrote:There is "bool UpdateReferencedLayer(MohoLayerRefSyncOptions *syncOptions = NULL)" to update reference layer. I don't *think* there's a command for syncing individual channels though.
Does this mean invoking this command will sync all channels for a selected reference layer? I think that's what I'm going to need.

I was thinking about making a script to crawl through a selected hierarchy and syncing individual channels, but if I can do it all at once with this command, that's probably simpler/better for my needs. (Plus, if I understand the above, I'm not going to be able to do what I intended anyway.)

Thanks for any info.
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

Ugh...I just looked it up. This is for the Update Layer Reference command isn't it, and it's not the same as the Sync Channels command is it? Rats.

What I want to do is sync all the channels for a selected layer (or a selected hierarchy) as a workaround to that random 'not referenced' issue I keep seeing. Right now I'm having to sync these channels individually as I run into them while trying to update rigs, and sometimes there are dozens of these channel errors in many layers. Some of these channels errors will block updating so I just want a quick way to sync all the channels in a selection so the layer update can go through properly.

(Actually, I just want these errors to not happen but I haven't been able to figure out what triggers them yet.)
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Sync Channel to Original

Post by synthsin75 »

Greenlaw wrote:Just found this thread. I'm still learning Moho scripting basics but this is related to something I want to do.
synthsin75 wrote:There is "bool UpdateReferencedLayer(MohoLayerRefSyncOptions *syncOptions = NULL)" to update reference layer. I don't *think* there's a command for syncing individual channels though.
Does this mean invoking this command will sync all channels for a selected reference layer? I think that's what I'm going to need.

I was thinking about making a script to crawl through a selected hierarchy and syncing individual channels, but if I can do it all at once with this command, that's probably simpler/better for my needs. (Plus, if I understand the above, I'm not going to be able to do what I intended anyway.)

Thanks for any info.
Yes, this should sync all channels, but at the expense of wiping out any intentionally unsynced stuff.
And yes, I haven't found a way to sync individual channels by script.

Just tested, and the one addendum to the above is that UpdateReferencedLayer will only sync things that differ from the syncOptions:
  • fAddNewLayers
  • fRemoveMissingLayers
  • fReplaceMismatchedBones
  • fReplaceMismatchedVectors
So for example, if you're needing to sync the point motion of a layer, the script will need to add a point to this layer so the command knows to sync it due to fReplaceMismatchedVectors (and this will sync point motion, number of points, fills colors, etc...should be pretty much everything vector related). And since this command doesn't check things like layer transforms, it cannot sync them.

So it's limited to syncing bones, vectors, and missing/additional layers (for referenced groups), and like vectors, you'd have to add a bone to sync bone stuff.

Here's what you would use for a single, selected layer:

Code: Select all

	local layerRefSyncOpts = MOHO.MohoLayerRefSyncOptions:new_local()
	layerRefSyncOpts.fAddNewLayers = true
	layerRefSyncOpts.fRemoveMissingLayers = true
	layerRefSyncOpts.fReplaceMismatchedBones = true
	layerRefSyncOpts.fReplaceMismatchedVectors = true
	moho.layer:UpdateReferencedLayer(layerRefSyncOpts)
Changing the layerRefSyncOpts to false keeps it from checking whether that option needs syncing.


EDIT: If layer transforms don't get unsynced, this may work for your purposes. And even if they do, it may save you quite a bit of manual syncing.
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

Thanks, Wes! It will take me a little time to process all of the above but I'm encouraged. :)

The main thing I want to do is clear any 'not referenced' channels that may appear immediately after the character is imported. I'm still not sure why the channels become active (it seems to happen randomly) but if they can be cleared before any animation is done in the scene, that would solve some of the problem.

I'm not sure yet if the 'not referenced' channels appear after the animator has started working in the scene yet (I mean other than how they're normally supposed to appear.) But it would probably be good to be able to run it on selected channels if they do appear after animation has started.

Losing existing animation for a channel after syncing is a concern but I thought I could have the script copy the existing keys and repaste them after syncing. At the moment, that's what I've been doing manually when I run into this situation.

But, TBH, I'm not anywhere near working on the script yet. I'm still playing around with really simple stuff and dissecting other scripts until I think I know what I'm doing. :D
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

I think I just figured out a workaround that doesn't require scripting. If I consolidate the timeline for a group (right-click Consolidate Layer Channels), and sync the single 'not referenced' channel, that seems to sync all the channels for that group and its sub-layers.

I'm still testing that but it might solve part of the problem here, especially for channels that appear after importing a referenced rig and for referenced groups that shouldn't have any animations. FYI, this does remove any intentionally unreferenced keyframes on references, so you may want to be sure to store any important keys to an Action first for later recovery. In my case, I lost some different visibility keyframes for a couple of referenced groups in a SBD Action...no biggie really, and fixing this was much easier than syncing dozens of channels individually.

Still going to learn how to script for Moho though. :)
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

Lucky me, I just had a scene with many dozens of 'not referenced' channels...and the above trick worked! All sub-layers in the selected group cleared too. After that, Updating the layer references worked as expected. :)

Still testing but I think I'm going to send a note to the other animators to do this trick immediately after importing a referenced rig just to be safe.
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Sync Channel to Original

Post by synthsin75 »

That would seem to imply that the randomly unsynced channels are more of a display glitch, since that trick doesn't seem to work for intentionally unsynced channels (which may mean your solution won't remove intentional keyframes).
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

Hmm...maybe. It's more than a display glitch though because the presence of an unintended 'not unreferenced' channel actually prevents updating that channel when I need to (which is the real problem.)

BTW, I found that the trick doesn't necessarily sync all sub-layers. Maybe it only goes down one level? Not sure yet. Will pay more attention to this when I have time. The trick is still useful, though...a lot less maddening way to sync/fix some of these layers.

Hmm...still a lot of work though. Right now I have 24 layers that have almost all of the channels as unintentionally 'not referenced'. If I was doing this manually, I'd be repeating the Consolidate-Sync-Unconsolidate steps hundreds of times. With the trick, I'm repeating the steps 24 times, which is much better but that's still a lot of repetitive clicking.

(At least we can display them all at once now.) :)

Ugh...just found another 24 reference layers that will need channel syncing.
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

Just counted 41 'not referenced' channels for each of these layers. I think that's pretty much all the channels isn't it?

BTW, these were not imported references, just regular referenced layers within the rig master project. Not sure if this happened when the references were created or if something happened along the way to 'activate' these channels--there are not. I really only need about three channels 'synced' because I'm still adjusting the curves in the original layers but I may as well sync all the channels--it's actually quicker than to do that just the three channels individually for each layer, and I may need some of the other channels 'unblocked' eventually.

Man, I wish I knew what triggers this because I'd love to avoid doing that.

(Sorry, it's late Friday afternoon and getting a little grouchy. Looking forward to the weekend.)
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Sync Channel to Original

Post by synthsin75 »

Well, I was going to say that Animation>Consolidate Layer Channels might help, since it works for the whole document, but syncing a group or sublayer shows the other synced, even when it isn't. You have to unconsolidate and consolidate again to get the right-click sync option again.

So my only idea is just a button script to speed up consolidating/unconsolidating of each layer, individually, throughout the document. If that works then maybe all you'll have to do is hit the script button to consolidate all, select all layers so they show in the timeline, right-click and sync each one, and then hit the script button again to unconsolidate all.

My only other idea to help would only work on Windows. I could write a AutoHotkey script that would make a mouse click do the right-click and sync, so possibly only have to click on each layer's consolidated channel once. I'm not sure how universal I could make that, since it may rely on the screen resolution of the computer using it. I'll see how feasible that may be.
User avatar
Greenlaw
Posts: 9257
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Sync Channel to Original

Post by Greenlaw »

Yes, that sounds like a good approach...it would reduce the number of steps quite a bit. I'll look into that.

Autohotkey did cross my mind yesterday but we don't have that installed at work.

I'm still not sure if this is really a random error, so I'm going to spend a little time today to see if I can trigger the error intentionally.
Post Reply