[Closed] "this" variable in simple scripted plugin to extend Point helper
Hi all
I am writing a simple plugin that extends the Point helper (see below). The instance of the plugin is going to be created from another script. When an instance of this plugin is created I want it to grab some data from a currently selected object and then position the instance relative to this object. To do this I used the
on create do ()
Event handler. I am using the “this” local variable to set some of the instance parameters (LouvrePos, LouvreDir, LouvreWith, LouvreHeight), which works fine. But if I try and use “this” to access the position or name, I am getting “unknown property” errors. See below
plugin helper LouvreControl
name:"LouvreControl"
classID:#(0x727e101b, 0xbf75d18)
extends:Point
replaceUI:true
invisible:true
(
.........
on postcreate do
(
--look at first spline in selection
RefSpline = for o in selection collect o
RefSpline = RefSpline[1]
--Function to extract an array of information from the spline
LouvreStats = ApertureSplinePositioningData RefSpline
--This all works fine
this.LouvrePos = LouvreStats[1]
this.LouvreDir = LouvreStats[2]
this.LouvreWith = LouvreStats[3]
this.LouvreHeight = LouvreStats[4]
--These next lines kick up errors! saying unknown property
this.pos = RefSpline.pos
)
)
Error: Unknown Property pos in LouvreControl
Is there anyway to access name or position (and other) propertes, so I can position etc the instance of the pluggin correctly? Even if I could select it, it woudl do, but “select this” returns an error too.
I am getting the feeling I am doing something very basic wrong, if someone could shed some light on the situation I would be very grateful indeed!
Thanks for your time guys…
Rich
this refers to the plugin parameters block not to the actual node.
you could store the object itself in a weak reference in the plugin in a maxobject
you can then refer to it and set the position
mark
Hi,
check out this thread for another way to get the nodes to which the scripted plugin instance is attached:
http://forums.cgsociety.org/showthread.php?f=98&t=511989
hOpe this helps,
o
Thanks for your input, that has definitely got me going in the right direction.
Thanks also to Paul Neale for his cool link explaining a bit about weak referencing. It has definitely helped me understand some of these new concepts that I am meeting!
Thanks for your time,
rich