maxscript add new Gradient position

3D Studio Max Plugin (Export Script Plugins developed by [gk] and KilaD; Integrated Plugin developed by Karba)
Forum rules
Please post only in English in this subforum. For alternate language discussion please go here http://render.otoy.com/forum/viewforum.php?f=18
Post Reply
HHbomb
Licensed Customer
Posts: 1377
Joined: Wed Jun 30, 2010 8:45 pm
Contact:

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.
YOKO Studio | win 10 64 | i7 5930K GTX 3090 | 3dsmax 2022.3 |
neonZorglub
OctaneRender Team
Posts: 1017
Joined: Sun Jul 31, 2016 10:08 pm

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
HHbomb
Licensed Customer
Posts: 1377
Joined: Wed Jun 30, 2010 8:45 pm
Contact:

Thanks ! :-)
But I'm not coilbook ;-)
YOKO Studio | win 10 64 | i7 5930K GTX 3090 | 3dsmax 2022.3 |
Post Reply

Return to “Autodesk 3Ds Max”