convert String To Command

How in code bellow convert string A to command M.texmap_diffuse ? I need in strings, because want to manipulate with them :
(
local M = meditMaterials[activeMeditSlot]
if classof M == VrayMtl do A = "M.texmap_diffuse"
A
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Yog's picture

Thanks to all! I solved this

Thanks to all! I solved this with execute command:
(
fn fn_A = (
local M = meditMaterials[activeMeditSlot]
local B = "meditMaterials[activeMeditSlot]."
if classof M == VrayMtl do local A = #("texmap_diffuse")
A[1] = execute (B + A[1])
)
D = fn_A()
)

fajar's picture

hmmm....

fn fn_A = (
local M = meditMaterials[activeMeditSlot]
--local B = "meditMaterials[activeMeditSlot]."
--if classof M == VrayMtl do local A = #("texmap_diffuse")
--A[1] = execute (B + A[1]) ///why execute it?
if (iskindof M vraymtl) do (A[1]=getProperty M #texmap_diffuse)
--I dont know (A[1]) is for, but it could lead to error, because theres no array here...
---better to access it in another function,no? 
)

better like this

fn fn_A = 
(
local mat
local M = meditMaterials[activeMeditSlot]
if (iskindof M vraymtl) do (mat=getProperty M #texmap_diffuse)
mat
)

then like this =

myArr = #()
obj = fn_A()
if obj!=undefined do (myArr[1]=obj )
myArr 
fajar's picture

instead"M.texmap_diffuse"it

instead of

"M.texmap_diffuse"

it would be better

A= #texmap_diffuse or A= "texmap_diffuse"

later you can use it like this

 
--get material prop 
obj = vrayMtl()
 
getProperty obj A --==> equiv : obj.texmap_diffuse
 
--set material prop
 
setProperty obj A( Bitmaptexture fileName:(xxx)).....
 
 --==> equiv :obj.texmap_diffuse=Bitmaptexture fileName:(xxx)

see getProperty and setProperty in max help
also its not good practice using "execute" command in maxscript.....

here is the sample code

(
		local prop
		local idx = medit.GetActiveMtlSlot()
		local theMat = getMeditMaterial idx
		local num = random 1 10000
		local myMat=vrayMtl name:("VRayMtl_" + formattedPrint num format:"04d")
		case of 
		(
			(iskindof theMat standardMaterial) :(prop=#diffuseMap)
			(iskindof theMat VrayMtl) : (prop=#texmap_diffuse)
		)
 
		if prop!=undefined do 
		(
			if (isKindof ( x = getProperty theMat prop) Bitmaptexture and x.filename!=undefined ) do
			(
				setProperty myMat #texmap_diffuse x
			)
		)
		meditMaterials[idx]=mymat
 
	)
Maarten's picture

I think I found it :D

Hello, I saw your post and started playing around in max and got this bit of code (below) to work, I think it should work for your purpose too (hope it does).

-Maarten

(
str = "select geometry"
execute str 
 
 
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.