Notifications
Clear all

[Closed] Recursive material Function

Hi,

I’m trying lately create recursive function to crawl whole material structure. I got stuck on :
SubAnim:RGB_Color_Map where as the Maxscript help says that points SubAnim:Point_1 are
not accessible til they are animated, how to animate them then to access the values?

I

Regards
Eryk

My Script :

clearlistener()
fn GofindMtl MtlTex imersion=
(
PrefixTex=""
PropertiesFormated=""
SubAnimsFormated =""
local imersion
imersion+=1
for i=0 to imersion do PrefixTex+="\__"
for i=1 to (getPropNames MtlTex).count do PropertiesFormated+=("  "+i as string +": "+(getPropNames MtlTex)[i])
for i=1 to (getSubAnimNames MtlTex).count do 
(
subAnimAnim=""
--if getSubAnimNames(getSubAnimNames MtlTex)[i]> 0 then subAnimAnim+=("  "+i as string +": "+(getPropNames MtlTex)[i])
SubAnimsFormated+=("  "+i as string +": "+(getSubAnimNames MtlTex)[i])
---Check for subanims

)
print (PrefixTex+(MtlTex as string )+"Number of Subtex Maps: "+(getNumSubTexmaps MtlTex)as string+"    Subanim Count: "+(getPropNames MtlTex).count as string  )
print (PrefixTex+"=========================="+"___Subanims:"+SubAnimsFormated)
print (PrefixTex+"=========================="+"___Properties:"+PropertiesFormated)
-- print ((getSubAnimNames (getSubMtl MtlTex 1)))
if MtlTex.name == "FindMe" then print "I FOUND IT"

try(	if  (getNumSubMtls MtlTex) > 0 then 
			(
				for i=1 to (getNumSubMtls MtlTex)  do 
				(
					if (getSubMtl MtlTex i) != undefined then 
					(			
					GofindMtl (getSubMtl MtlTex i) imersion
					)
				)
			)
)catch()
try(		if (getNumSubTexmaps MtlTex) >0 then
			(
				for j=1 to (getNumSubTexmaps MtlTex)  do 
				(
					if (getSubTexmap MtlTex j) != undefined then 
					(
					GofindMtl (getSubTexmap MtlTex j) imersion
					)
				)
			)
)catch()

)
MtlTex= $.material
GofindMtl MtlTex -2 ---Function GofindMtl:material Imersion:tab fro make output look cleaner


----CODE Below only for test and debug
MtlTex_CHECK=getSubAnimNames(getSubTexmap(getSubTexmap (getSubMtl $.material[1]1)1)1)
theBitmap=(getSubTexmap(getSubTexmap (getSubMtl $.material[1]1)1)1)
for i=1 to MtlTex_CHECK.count do print ( ( getSubAnimNames (getSubAnim  theBitmap  MtlTex_CHECK[i])))
(getSubAnim (getSubAnim (getsubanim (getSubAnim  theBitmap  MtlTex_CHECK[7]) 5)1)1).keys
addnewkey (getSubAnim (getsubanim (getSubAnim  theBitmap  MtlTex_CHECK[7]) 5)1) 1
7 Replies

Guess this must be the solution

Continuing the discussion from BitmapTex RGB_Color_Map not exposed?!:

Seems I can not animate them via maxscript, this is very sad
Is there some tricky way/bypass to do this?

This is out of my scope(dont know to much about C++), but…maybe this is the right track?
https://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__cpp_ref_class_i_curve_html
Get the referenceTarget(curve) via some provider…

See Edit Curve Control for an example of how to edit mapcurves.

Hi Swordslayer,

This is funny, because i’m studying your scrptspot script right now

Thank You very much Vojtech!
I think I’m much closer to solve the problem.
Trying to breakdown your code, there are parts that i don’t understand.

  1. Why are you using rollout as local variable?
  2. Can I skip open “curveEdit open” and add keys to curve points and assign curve back to material only in variable?
  3. How can I enable the “Enable Color Map” without opening the Material Editor?

refs.replaceReference for curve does the work, because I want to use rollout anyway.
I had several Max crashes along the way but finally It is possible to print\access the points when the rollout is open.

  1. I prefer not to mess with global scope when not needed

  2. With C# you could do it directly, mxs .net access is missing the ability to cast .net types to get there. But you can open the rollout somewhere offscreen or with empty style and zero size:

     rollout invisRollout "" width:0 height:0 (;)
     createDialog invisRollout style:#()
    
  3. Not directly (yeah, user accessor sucks) but you can have a .mat file with a texture with the output StdTexoutGen where the checkbox is activated and replace the .output with a copy of this .output (setting the other parameters to identical values).

Thank You once more, for setting up back on track