Notifications
Clear all

[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.

14 Replies

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

1 Reply
(@gtafan)
Joined: 11 months ago

Posts: 0

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

1 Reply
(@gtafan)
Joined: 11 months ago

Posts: 0

But which mechanism? My maxscript knowledge is really low.

you can get the node using


[b]on[/b] [b]attachedToNode[/b] <nodeVar> [b]do.....

[/b]

1 Reply
(@gtafan)
Joined: 11 months ago

Posts: 0

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
)

1 Reply
(@gtafan)
Joined: 11 months ago

Posts: 0

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
)
2 Replies
(@gtafan)
Joined: 11 months ago

Posts: 0

So when you doing this:


d=mDummy()
[i]getUserProp d "x"[/i] 

it returns 1?

(@gtafan)
Joined: 11 months ago

Posts: 0

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.

yes

Strange, must check where the error in my code is.
Also what about that category:“Standard”? Can I also define category:“myPlugins”?