How to get self node in a scripted object?


#1

I have a scripted plugin helper in maxscript and need to get the node that is the object. How can I archieve it inside the scripted plugin?


#2

use the on attachToNode event

local thisnode = undefined;

on attachtoNode n do  thisnode = n;
on detachedFromNode n do thisnode  = undefined;

then when ever you want to use it

if thisnode != undefined then ...

#3

if you want to get the correct answer on your question please ask the question clear …
show the “header” of your plugin, specify the moment when you want to know about which node uses this plugin…

Klvnk
attachtoNode doesn’t work for object plugins


#4

It´s more or les still about that modifier helper example, I would like to rotate the trimesh in the local coordsys of the node. At the moment I am only able to rotate the trimesh in world coordsys and even using “in coordsys local” doesn´t worck. I was thinking to use “in coordsys theNode” where theNode is my node.


#6

You can retrieve the node that this plugin is attached to:
(refs.dependentnodes this)[1]


#7

OK thanks, I try it.


#8

Geting this error mesage:


#9

It first appeared in

What was New in MAXScript in 3ds Max 2008

ps. All of your threads should probably mention right in the first post that you need a working solution for a pretty ancient max version. Otherwise most of the answers may be useless for you and pure waste of time for those who answer them.


#10

Nice point, Thank You!
I never thought someone still uses Max 2008.


#11

use this:

ThisNode = undefined
for o in refs.dependents this while ThisNode == undefined where isvalidnode o do ThisNode = o

#12

Sorry I forgot to mention it this time again. I am even using max 9, which was befor max 2008.


#13

Will it worck with older max versions? At least version 9.


#14

So the code from MZ with some small changes worcked:

nodes=for o in refs.dependents this where isvalidnode o collect o