Notifications
Clear all

[Closed] Getting an obect's node

I want to create a hierarchy, father and son usingmaxscript

The idea is, I have an object, with a modifier called Alouatta Object, and through a pick object button, I use attachObjects to link them together… but…

When I try that, it gives me an error:

Unable to Convert Alouatta:Alouatta Object to type: <node>

In my modifier I have this code:

    on pickMesh picked obj do
    (
        if isValidNode obj then (
            if (classOf(obj) as string) == "NxActor" then (
                nxactorTxt.text = obj.name
                NodeNxActor = obj
                attachObjects this obj
            )
        )
    )

The line where it fails is “attachObjects this obj”, saying the “this” is not a node…

My question is: How can I get the node from my object that has the modifier?

2 Replies

Hmm… you seem to be muddling quite a few things up here.

if classOf obj == NxActor – you don’t need to convert the classname to a string, just check the object directly
if classof obj.modifiers[1] == NxActor – however, this code would check the class of the first modifier

                    nxactorTxt.text = obj.name  -- not sure what you're doing here
                    NodeNxActor = obj -- or here...

attachObjects this obj – no such variable this (it will return undefined)

obj.parent = $sphere01 – parent obj (your newly picked object) to the object called “sphere01”

Ok, I can now link them doing this:

obj.parent = selection[1] –> selection[1] is the object with the modifier

That works perfectly…

And unlink them with

obj.parent = undefined

Thanks…