[Closed] setUserProp not worcking for scripted plugin
I have writen a scripted helper plugin that extends dummy and creating instances of it is no problem, but when I want to setUserProp for one of that instances I geting an error.
Here is my code:
plugin helper myPlugn
name:"myPlugn"
...
extends:dummy
(
...
on create do setuserprop this "x" 1
)
and here the error mesage:
- Error occurred in create()
– Frame:
MAXScript Scripted Plugin Handler Exception: – No ““setUserProp”” function for myPlugin <<
After I have changed the code like this:
on create do setuserprop this.delegate "x" 1
got still a similar mesage:
– Error occurred in create()
– Frame:
>> MAXScript Scripted Plugin Handler Exception: – No ““setUserProp”” function for Dummy <<
SetUserProp works on scene nodes, not on plugin instances. You can get the dependent node(s) with refs.dependentNodes
But can I do it inside on create? That marker flag must be set for every new instance of that and some other plugins.
In that case you most probably don’t want user properties but a different mechanism altogether
you can get the node using
[b]on[/b] [b]attachedToNode[/b] <nodeVar> [b]do.....
[/b]
Sorry, like I said, my maxscript knowledge is very low, so where do I have to insert it in my code? Also what that <nodeVar> means?
plugin helper myPlugn
name:"myPlugn"
...
extends:dummy
(
...
on attachedToNode theNode do setuserprop theNode "x" 1
)
I changed my code this way, but when I try to get the userprop “x” it returns undefined.
works for me…
plugin helper mDummy
name:"mDummy"
category:"Standard"
classID:#(0x47db14fe, 0x4e9b5f90)
extends:dummy
(
local lastSize, meshObj
parameters pblock rollout: params
(
size type:#float animatable:true ui:amount default:40.0
)
rollout params "HelperTest Parameters"
(
Spinner amount "Size:" range:[0, 1e9, 40]
)
on getDisplayMesh do
(
if (meshObj == undefined) do
(
meshObj = createInstance box length:size width:size height:size mapCoords:false
lastSize = size
)
if size != lastSize do
(
meshObj.length = meshObj.width = meshObj.height = size
lastSize = size
)
meshObj.mesh
)
on attachedToNode theNode do setuserprop theNode "x" 1
)
OK, thaks a lot, it worcks. Is there a way to make the box not visible? I tried by including delegate.boxsize=[0, 0, 0] in on create, but it only worcks if I create the instance using maxscript, otherwise still having a box.
Strange, must check where the error in my code is.
Also what about that category:“Standard”? Can I also define category:“myPlugins”?