Notifications
Clear all

[Closed] Getting object name from a string

Sorry if this is a dumb request, but I can’t figure out how to use filterString to return the object name from this intersectRayScene string (in red):

#($Box:Box02 @ [30.000000,0.000000,0.000000], (ray [17.5,0,0] [-1,0,0])) 

Any help is greatly appreciated.

4 Replies

From the Help

Returns an array of results, one entry per node hit, where each entry is a 2 element array containing the node and the intersectRay result for that node.

That mean u need not use a filterString for getting the name, its already there. Just store the result a empty array, the first element of the array would be node.
eg if ary is the empty array then ary[1].name gives u the name of the object

it’s not returning a string, it’s returning a node, which is better than a string since max allows you to name multiple objects the same name. because of that, working with strings for objects can be dangerous.

if you’re running the sample code from the docs… hits[1][1] will give you the node, which you can then use directly (like akramparvez said)

 PEN

theArray[1].name would get it. As it is the first item in the array and that item is a node that has a name property. As has been said, try to avoid using names as a way to access nodes in the scene.

Thanks guys, that did it. I was sorting the nodes, so [2][1] got me the name.