ScriptSpot

Forum topic · General Scripting

Newb problem: Convert a string to scene object name?

By Vancent · 2010-02-21

Description

Hi, I'm currently trying to develop some custom tools for a project I'm working on.

I've currently got a rollout featuring a dropdownlist (ddlObjects) and a button (btnMove), among other things.

ddlObjects contains the names of several scene objects, either poly meshes or splines. These names are stored in the ddlObjects.items array as strings.

What I want is for btnMove to move whatever object is selected in ddlObjects by a set amount. Preferably without the object being visibly selected in a viewport.

Currently I'm been trying

move ddlObjects.selected [0,1,0]

or other variation there of, but am stuck on the problem of the selection from ddlObjects being read as a string.

I know that this is probably a simple thing to fix but I can't for the life of me find out how. Please advise.

Comments (6)

Anubis · 2010-02-22

Execute is bad way to do... you can use getNodeByName() function, ie:

target = getNodeByName ddlObjects.selected

Vancent · 2010-02-22

Thanks for the info. I'll try your way.

Could you explain why execute is a bad way to do it? I'd like to know.

Ok, "execute" borrowed by

Anubis · 2010-02-23

Ok, "execute" is borrow from pure C and has very slow runtime performance.

turbinea · 2010-02-21

you can try command 'execute'
something like this: FF = execute("Spehere01") which will be understood as FF = Spere01
not sure if this is "correct" way to do scripts but works for me.

Vancent · 2010-02-21

This seems useful but doesn't seem to work in this case. I'm trying it like this:

target = execute(ddlObjects.selected)
move target [0,1,0]

But keep getting this error:

-- No ""move"" function for undefined

I am, of course, making sure that there is items in the list and that they are selected.

Vancent · 2010-02-22

Problems solved. Found the sulution in 3ds Max's FAQ/

It seems I just needed to expand the string for the execute command. My new code looks like this:

target = execute("$" + lbxObj.selected + "'")
move target [0,1,0]

It now works gloriously thank you for your help.