Page 1 of 1

maxscript add new Gradient position

Posted: Fri Oct 18, 2024 3:45 pm
by HHbomb
Hi,

I can see how to move a position or to change its color but how can I create a new position ?

change position is ok : rootScene[#SME][#View1][#Map__45____Gradient_Texture].SMENodeAttr.reference.Positions[17] = 0.489231
change color is ok : rootScene[#SME][#View1][#Map__45____Gradient_Texture].SMENodeAttr.reference.color[17] = color 137 188 0


Thanks.

Re: maxscript add new Gradient position

Posted: Wed Oct 23, 2024 10:42 pm
by neonZorglub
HHbomb wrote:Hi,

I can see how to move a position or to change its color but how can I create a new position ?

change position is ok : rootScene[#SME][#View1][#Map__45____Gradient_Texture].SMENodeAttr.reference.Positions[17] = 0.489231
change color is ok : rootScene[#SME][#View1][#Map__45____Gradient_Texture].SMENodeAttr.reference.color[17] = color 137 188 0


Thanks.
Hi coilbook,

For 'Gradient Texture', there are 3 arrays that store the data (named Positions, Color and TexMap_Tab)
You can manipulate those arrays like any other arrays with maxscript, but when adding or deleting element,
you MUST keep the same size for all of those 3 arrays.

For example, using t as the gradient texture:
t = meditMaterials[1].diffuse_tex
Map #0:Gradient Texture

To add a 'key', you need to add 3 elements (add 1 element for each of those 3 arrays):
append t.Positions 0.67
append t.color (color 57 255 40)
append t.TexMap_Tab undefined

check the size of each array with
t.color.count
t.Positions.count
t.TexMap_Tab.count

Don't change or delete the first 2 elements (1 and 2), that's reserved for the first key (left, position 0.0) and last keys (right, position 1.0)

Note that other octane textures using gradient may have different names, eg gradPositions, gradColors, gradMaps for Apply gradient map (layer of a Composite texture)
(Use showproperties t to check)

Also Toon Ramp and Volume Ramp have only 2 arrays (positions and color)

See also Autodesk documentation on arrays:
https://help.autodesk.com/view/MAXDEV/2 ... 869817282A

Thanks

Re: maxscript add new Gradient position

Posted: Fri Oct 25, 2024 8:14 am
by HHbomb
Thanks ! :-)
But I'm not coilbook ;-)