[Closed] [Maxscript] Passing a string variable to SelectionSets[]
I’ve been trying to write a script that allows me to set a string in a text field and then hide a selection set by name which matches what is in my text field. I tested:
myName = “MySet”
hide selectionSets[myName]
And
myName = “MySet”
myObjectName = execute (“$’”+myName + “’”)
hide selectionSets[myObjectName]
Either way I get: – Unable to convert: undefined to type: String
hide selectionSets[“MySet”]
Works the way I would expect, but I can’t pass in a string variable? I can only assume I’m not passing the string properly, but I’ve been unable to find any help in the online documentation or otherwise. Is there a way to pass a string variable
Any help would be very appreciated, thanks in advance!
This works with no problems:
(
myName = "MySet"
hide selectionSets[myName]
)
but only if I have selection set with the name “MySet”
I get:
– Unable to convert: undefined to type: String
I only have one Selection Set and it’s name is “MySet”.
I wonder where the missing piece is…
Using 2016. I don’t see where I can upload a scene but here’s a screenshot:
The scene is just a test scene. All I did was create a new scene created 4 boxes with mouse drag actions and then selected 2 of the boxes and entered “MySet” in the Create Selection Set dropdown box.
Everything works fine in 3ds Max 2016. I suppose that the problem is in the code you use, the whole code. You cna post it here and can tell which button you press to get the error.
I can’t get past the MAVScript Listener error.
When I type in:
myName = “MySet”
hide selectionSets[myName]
I get:
– Unable to convert: undefined to type: String
Like it’s not seeing the string I defined and filled one line earlier.
Ok that code does work, I was trying to debug using the listener. I guess that isn’t the right approach?
In the Maxscript listener you have to do the following:
type:
myName = “MySet”
and hit numpad enter
type:
hide selectionSets[myName]
and hit numpad enter
Then it will work.