Unable to convert: $selection to type: <node> ----- Why?

Hi all you good people!

I'm writing on a small script which is putting all objects in a scene into a container.
The script looks like this:

global assetproxyPUB
select objects
assetUnproxyPUB = $

cnt01 = container size:50 name:h1
cnt01.displaylabel = true
cnt01.localDefinitionFilename = h1 + "_container"
cnt01.AddNodeToContent assetproxyPUB
cnt01.SetAccessType #anythingUnlocked
cnt01.ClearLockedContents()
cnt01.SetLockedContents #lockAllAnimation true
cnt01.saveContainer true
cnt01.setOpen false

Sometimes it works, sometimes it doesn't.
Sometimes maxscript replys: "Unable to convert: $selection to type: "
and highlights this line:

cnt01.AddNodeToContent assetproxyPUB

Does anybody have an idea what could be the reason for this and how to deal with it?

Thank you so much! :)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Travis Bert's picture

Solution

I have tried to find a solution to the problem mentioned here, but is somewhat difficult. However, there are many sources that explain about the nature of the problem and how to solve. I prefer that you don't use the btw format as it can harm the legitimacy of the program itself.

kernberg's picture

ahhhh, where was my head..

ahhhh, where was my head.. Thank you so much! I owe you a beer... Problem solved

kernberg's picture

Hi, I tried to use the

Hi, I tried to use the selection as array but then I get this error message (in the file attachement).
Any idea, what's going on?

Thank you so much :)

AttachmentSize
maxscript-error.jpg 121.91 KB
Swordslayer's picture

Well, it was meant to replace

Well, it was meant to replace the whole line, not just part of it - note that it's AddNodesToContent, not AddNodeToContent.

Swordslayer's picture

It expects one node; when it

It expects one node; when it errors out, you're feeding it multiple nodes. There's no reason to make the variable global, btw. (actually it's a bad practice), and as it's used only once you don't even need the variable. Delete the first three lines and replace the highlighted line with cnt01.AddNodesToContent (selection as array)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.