Get undefined value type from known channel?
Moderators: Víctor Paredes, Belgarath, slowtiger
Get undefined value type from known channel?
I want to get a value from a key at a given channel at a specific frame. The value (and channel) can be of any type. Can I get that value found without having to specify which type of value I'm looking for?
- synthsin75
- Posts: 10253
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Get undefined value type from known channel?
Lua variables don't have declared types, so you can give them anything. But if you need to populate an LM value (the kind you need to declare as new_local), you will need to know which type of LM value the channels is looking to populate. I assume using ChannelType() would tell you.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Get undefined value type from known channel?
Thank you.
To get a value with GetValue() I need to know which AnimVal I'm after (value1 = bone.fAnimPos:GetValue(frame). I also need to know (in this case) which bone I'm trying to get a value from.
I'm going through all channels and subchannels for a layer, trying to get values. (Using the lm_listchannels script for that part). Subchannels contains one value for one bone per frame; a Skeleton with 4 bones has 4 subchannels for bone rotation.
I can't figure out how to tell which bone a given subchannel belongs to. ChannelType() returns an integer; 1 for bone angle, 2 for bone Translation, 6 for Layer Translation etc.
- Do I need to have a lot of ifs here? (if ChannelType = 1 then property = fAngle etc.) and how do i tell which bone or other sublayer thing the given subchannel belongs to?
To get a value with GetValue() I need to know which AnimVal I'm after (value1 = bone.fAnimPos:GetValue(frame). I also need to know (in this case) which bone I'm trying to get a value from.
I'm going through all channels and subchannels for a layer, trying to get values. (Using the lm_listchannels script for that part). Subchannels contains one value for one bone per frame; a Skeleton with 4 bones has 4 subchannels for bone rotation.
I can't figure out how to tell which bone a given subchannel belongs to. ChannelType() returns an integer; 1 for bone angle, 2 for bone Translation, 6 for Layer Translation etc.
- Do I need to have a lot of ifs here? (if ChannelType = 1 then property = fAngle etc.) and how do i tell which bone or other sublayer thing the given subchannel belongs to?
- synthsin75
- Posts: 10253
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Get undefined value type from known channel?
I would assume the sub-channels are by bone ID?
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Get undefined value type from known channel?
Probably, but I can't figure how to get that information from the channel.
Also I really would like to get the values disregarding what type they are, I just need to compare two values, not going to populate anything from them. (Apart from a generic valueX variable, which doesn't need to know what kind of value it is).
I'm going to work on all the channel types, which there is 72 of... It will be a lot of code just to select the right kind of value for any of them...
Also I really would like to get the values disregarding what type they are, I just need to compare two values, not going to populate anything from them. (Apart from a generic valueX variable, which doesn't need to know what kind of value it is).
I'm going to work on all the channel types, which there is 72 of... It will be a lot of code just to select the right kind of value for any of them...
- synthsin75
- Posts: 10253
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Get undefined value type from known channel?
I'm afraid I'd have to see some code snippets to fully appreciate the problem. Do you have an example of where you're at?
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Get undefined value type from known channel?
Lua tables are very flexible. Instead of
You can write
So you don't really need to repeat the same code again and again for the different channels, you can use the channel name as a parameter in your loops. There are animated channels in the document, in the layers, and in some contents of the layers too (points, curves, bones...). Maybe you need to parse all of these to find the channels you need.
You may take a look into my csv export code (viewtopic.php?f=12&t=29429 fa_export_csv.lua: the FA_export_csv:IsAnimated() function). It's also an ugly code though, repeating the same "if"s several times.
Code: Select all
channel= bone.fAnimPos
Code: Select all
ch_name= "fAnimPos"
...
channel=bone[ch_name]
You may take a look into my csv export code (viewtopic.php?f=12&t=29429 fa_export_csv.lua: the FA_export_csv:IsAnimated() function). It's also an ugly code though, repeating the same "if"s several times.
- - - Fazek