PDA

View Full Version : Delegate returning undefined


Mathieson
01-11-2008, 07:18 PM
I have a number of maxfiles all using a scripted plugin. In just one of these files the plugin is erroring. The error is occuring on a line that is using the delegate variable. I commented this line out and the plugin no longer errored. I included an if statement to check if delegate was returning undefined, and found out that it is infact returning undefined.

This is the only shot where this is happening. I don't understand how delegate could be returning undefined when it is a reserved variable.

If anybody has any explanations it would be greatly appreciated. Thank you.

RustyKnight
01-11-2008, 10:57 PM
I have a number of maxfiles all using a scripted plugin. In just one of these files the plugin is erroring. The error is occuring on a line that is using the delegate variable. I commented this line out and the plugin no longer errored. I included an if statement to check if delegate was returning undefined, and found out that it is infact returning undefined.

This is the only shot where this is happening. I don't understand how delegate could be returning undefined when it is a reserved variable.

If anybody has any explanations it would be greatly appreciated. Thank you.Please foregive me complete ignorance, not having played with scripted plugins...

As I read it, delegate relates to "extended" plugins, that is, the plugin needs a parent (I'm assuming you understand all this)...so, the ONLY reasons I can think of (again, scripted plugin noob) are:
1. The plugin has no parentIf theextends: parameter is not supplied for a plug-in, delegate returns undefined
2. The method you are trying to call does not exist in the parent plugin.

I hope this helps
Shane

Mathieson
01-14-2008, 05:31 PM
Hi Shane,

Thanks for the reply. I actually wasn't aware that it would return undefined if the plugin was not extending one that already exists! I looked into it though and the plugin actually is extending the standardmaterial. I also looked into the parameters being called on through delegate and they do exist on a standardmaterial.

I did a bit more messing around as well and found a few more things that are a bit strange.

I am able to access and change any of the plugin's or parent's parameters. I am also able to access any of the plugin's functions, although when I run the function the error occurs.

I am able to create a new instance of the plugin material in the scene and it works just fine. Only those which were in the scene beforehand are broken.

We have decided to just do save/load on the scene in question to just bypass the issue all together. I am still really curious about what might have happened to cause the problem though.

PEN
01-14-2008, 05:41 PM
I'm the one that actualy wrote the tool but I have not seen the file in question. Just so you know the extended standard material is in use on hundreds of files at this time without a problem to date.

Mat, just a thought, why don't you use getClassInstances and get all the instances of the pinkyMat and see if they are all valid by calling on parameters in them or just make sure that they are all defined correctly in some way. Maybe there is a bum one in there for some reason.

I think just rebuilding the file is what will have to happen but I would hate to see this keep popping up.

Klonsemann
11-14-2008, 07:50 AM
...
I am able to access and change any of the plugin's or parent's parameters.
...

Hi Mathieson,

im working on a scripted plugin that extends an existing geometryclass, how did you access the parents parameters ?

I only can access the baseObject properties within the delegate variable.


The delegate local variable in a scripted plug-in that creates a
scene object does not contain the node itself, but a the BaseObject
of that node. As such, you can not access the node level properties
of the object being created.


But how to access the .position property ?

Mathieson
11-14-2008, 06:17 PM
Hi Christian,

In the example above I was actually dealing with a plugin that was extending a standard material. So when I said I could access and the delegate's parameters I only meant I was able to get access to it's diffuse and specular properties, for example.

If you are extending a geometry class it makes sense that you can only access the baseobject's properties and not the position. The position and transform data belongs to the node and not the geometry class, and like the quote you've provided states, "does not contain the node itself".

To get access to the node and it's position, try using the line:

(refs.dependentNodes this)[1].position
I'm not too keen on using refs.dependents, or refs.dependentNodes, and just grabbing the first item in the resulting array. There is no guarantee it is going to be what you're actually looking for. In this case though, it should really only be the one node that belongs to that instance of the plugin.

Klonsemann
11-15-2008, 11:33 AM
Thanks a lot,

i will hav a look on refs.dependentNodes .

CGTalk Moderation
11-15-2008, 11:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.