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
)
Forum topic · General Scripting
convert String To Command
By Yog · 2016-08-05
Description
Comments (4)
Yog · 2016-08-08
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()
)
hmmm....
fajar · 2016-08-08
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
instead"M.texmap_diffuse"it
fajar · 2016-08-08
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
)
I think I found it :D
Maarten · 2016-08-05
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
)