Notifications
Clear all

[Closed] A rename object question

Hi all,
I have a question,I made a function, but running it returns different results,I want to get help

fn Rename_tex thename =
(
IF $.material != undefined then
$.material.name = thename as string
$.name = thename as string
)

	 Rename_tex 11
             Rename_tex abc

returns
“11”
“undefined”
Why “undefined”

2 Replies

To Max, abc looks like a variable, but there’s no variable called abc defined in your code. So when you say Rename_tex abc, mxs silently passes undefined to your function. Then, in your function, you convert the incoming parameter to string so you get “undefined”.

Try Rename_tex “abc” instead.

Cheers,

Drea

I understand, thanks DreaTawn