Hello Moho Discussion Scripting members and moderators,
&thanks for your generous expertise and pro scripting products.
I hoped anyone familiar or can discern ColorPoints scripting, could please advise writing a script to simultaneously apply or paste a range of ColorPoints, color properties to multiple selected Keyframes &vector points?
(CHRONOLOGY):
From the timeline, a user selected colorpoints layer Color, would provide the initial, single property color, from which a range of lighter or darker cp's colors would be (iteratively)generated, equal in number to the Multiple, user selected cp's (target)keyframes chosen after the initial single, source keyframe color.
(ALGORITHM): ..in VBA but i'll convert to LUA prog.lang. & C API then repost,.
Dim TargetVectorPt as ActivePoint
Dim SourceCPClr as ActiveKeyframe
Dim TargetCPKeysRange as ActiveKeyFrames
Set KF = ColorpointKeyframe
- MsgBox requests user input selection(s) and indication when complete,
- user selects TARGET Vector Points,
- detect selected TARGET Vector Points: TargetVectorPt, [using Iterative fAnimPos AnimVec2?] OR [ScriptInterface:CountSelectedPoints?]
- MsgBox requests user input selection,
- user selects ColorPoint keyframe with SOURCE color,
- detect selected SOURCE Colorpoint keyframe color property: SourceCPClr, [using GetValue LM_ColorVector?]
- create range of lighter\darker cp's colors interating rgb values from SourceCPClr,
- MsgBox requests user input selection(s) and indication when complete,
- user selects ColorPoint TARGET keyframe(s),
- detect TARGET selected Colorpoint keyframe(s): TargetCPKeysRange, [using Iterative GetValue LM_ColorVector?] OR [ScriptInterface:UpdateSelectedChannels?]
- apply\paste each SOURCE color in cp's range into each TARGET keyframe cp's property,.
For Each KF In TargetCPKeysRange
paste SourceCPClr to KF
Next KF
..hope this makes sense, please let know if any clarifications needed.
Thanks again for any equivalent scripting, welcome corrections and suggestions soon as able,
look forward to talk soon,
Jeff
http://mohoscripting.com/classes/M_Point
fColor AnimColor Added in version 11 11.0
fColored bool Added in version 11 11.0
fColorStrength AnimVal Added in version 11 11.0
fSelected bool true if the point is selected, otherwise false
fPos LM_Vector2 the point's current position < 9.5
http://mohoscripting.com/classes/AnimColor
METHODS:
GetValue LM_ColorVector Return the value of this channel at a given frame < 9.5
GetValueByID LM_ColorVector < 9.5
SetValue void Set the value at a given frame < 9.5
SetValue void Set the value at a given frame < 9.5
SetValueByID void < 9.5
SetValueByID void < 9.5
PROPERTIES:
value rgb_color The current value of the channel. < 9.5
M_Point.fSelected - true if the point is selected, otherwise false
ScriptInterface:CountSelectedPoints - Returns the number of selected points in the current vector layer
ScriptInterface:UpdateSelectedChannels - Updates the display of "selected" channels in the timeline
How to script applying or pasting range of ColorPoints,color properties to selected Keyframes&points?
Moderators: Víctor Paredes, Belgarath, slowtiger
- synthsin75
- Posts: 10267
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: How to script applying or pasting range of ColorPoints,color properties to selected Keyframes&points?
Best to take this one or two steps at a time. So, ActivePoint and ActiveKeyframe (the VBA syntax and custom variables just muddy the water).
ActivePoint
You want to loop through all the points in a layer and check for which ones are selected.
ActiveKeyframe
I assume by this you mean selected keyframes.
I'm sure you can find the functions used there on www.mohoscripting.com
Let me know if you have any questions so far.
ActivePoint
You want to loop through all the points in a layer and check for which ones are selected.
Code: Select all
local mesh = moho:Mesh() -- http://mohoscripting.com/methods/78
--or
local mesh = moho.layer:Mesh() -- http://mohoscripting.com/methods/579
for i=0, mesh:CountPoints()-1 do -- http://mohoscripting.com/methods/832
local pt = mesh:Point -- http://mohoscripting.com/methods/836
if (pt.fSelected) then -- http://mohoscripting.com/classes/M_Point
-- operate on selected points, store them to a table, etc.
end
end
I assume by this you mean selected keyframes.
Code: Select all
local chanCnt = moho.layer:CountChannels()-1
local ch = MOHO.MohoLayerChannel:new_local()
for i=0, chanCnt do
local chan = moho.layer:Channel(i, 0, moho.document)
moho.layer:GetChannelInfo(i, ch)
if (chan) and (chan:CountKeys() > 1) then
for k=0, chan:CountKeys()-1 do
local when = chan:GetKeyWhen(k)
if (when > 0) then
if (chan:IsKeySelected(when)) then
print(ch.name:Buffer(), " ", when)
end
end
end
end
end
Let me know if you have any questions so far.
- 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: How to script applying or pasting range of ColorPoints,color properties to selected Keyframes&points?
Awesome Wes, so exiting to see Lua in action on familiar processes, providing a per line understanding of the language. Your method &class references specified are as helpful since the naming conventions &locations are counterintuitive to Color Points and vectors etc. ie: M_Point.fColor & M_Mesh = "vector shapes..points, curves, and fill and outline,."
1) what is fColored use for please?
Code is made even more concise not requiring MsgBox prompts for user input, instead verifying if the point(s) are selected. Thx.
Lua variable declarations(pointers) are much more efficient\effective than at least my level of VBA.
Now i'll learn all the functions in your ChannelCount section,
treat the 1st selected cp's channel keyframe as the SOURCE color,
determine the method to iterate and store the SOURCE color rgb value by as many times as selected TARGET cp's keyframes,
2) then use SetValue? to apply each cp's color in that range into each selected cp's keyframe color property.
..Codings' so cool, forgot how much its missed(Asm,VxD,Sys ring0: flight sim decades ago),
Thx again Wes,
Look forward to next,
Jeff
1) what is fColored use for please?
Code is made even more concise not requiring MsgBox prompts for user input, instead verifying if the point(s) are selected. Thx.
Lua variable declarations(pointers) are much more efficient\effective than at least my level of VBA.
Now i'll learn all the functions in your ChannelCount section,
treat the 1st selected cp's channel keyframe as the SOURCE color,
determine the method to iterate and store the SOURCE color rgb value by as many times as selected TARGET cp's keyframes,
2) then use SetValue? to apply each cp's color in that range into each selected cp's keyframe color property.
..Codings' so cool, forgot how much its missed(Asm,VxD,Sys ring0: flight sim decades ago),
Thx again Wes,
Look forward to next,
Jeff
- synthsin75
- Posts: 10267
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: How to script applying or pasting range of ColorPoints,color properties to selected Keyframes&points?
pt.fColored is a boolean that tells you if the point has colored point applied to it. You should also be able to set this as true or false to enable or disable the colored point.
Yes, pt.fColor:SetValue(when, value) changes the point's color. You'll just need to find the selected keyframes in that channel and use their frame as the "when" argument.2) then use SetValue? to apply each cp's color in that range into each selected cp's keyframe color property.
- 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/
- synthsin75
- Posts: 10267
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: How to script applying or pasting range of ColorPoints,color properties to selected Keyframes&points?
Forget that second code block above. You won't need to do all that. Once you find the selected/desired points, you can check the fColor channel directly. For every point that's colored (as per fColored), you can just count through the keys (for i=0, pt.fColor:CountKeys()-1 do) and check for the selected keys (if pt.fColor:IsKeySelected(i) then).
- 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: How to script applying or pasting range of ColorPoints,color properties to selected Keyframes&points?
..appreciate the increased efficiency code Wes, will implement 1st block counting then confirming selected keys, then develope code to iterate and store the SOURCE color, rgb value range by as many times as selected TARGET cp's keyframes.
Talk soon,
J
Talk soon,
J