PDA

View Full Version : deleteItem from point3Tab


zortech
03-30-2012, 03:30 PM
Hi,

I have a problem modifying tab parameters from "inside" the plugin, which screams scope issue in my face but I'm sort of stuck. Calling the same function (fnDeleteItem) from within the onMouseDown event does invoke the tabChange event handler, but has no effect on the tab itself. Whereas calling it from "outside" works just fine.

Here's an example:

(
plugin simpleManipulator manipTest name:"Test" category:"Test" classID:#(0x24e63f49, 0x652cb098) (
local colA = [0,0,1]
local colB = [1,0,0]

parameters main rollout:dlgParams (
aPoint3Tab type:#point3Tab tabSize:0 tabSizeVariable:true
p3Offset type:#point3 default:[0,0,0]

on aPoint3Tab tabChanged change index count do format "Change: % \t Index: %\t Total: %\n" change index count
)

rollout dlgParams "Test" (
)

tool create (
on mousePoint iClick do (
if (iClick == 1) then nodeTM.translation = p3Offset = gridPoint
else append aPoint3Tab (gridPoint - p3Offset)
)

on mouseAbort iClick do return #stop
)

function fnDeleteItem iItem = (
deleteItem aPoint3Tab iItem
)

on canManipulate target return (classOf target == manipTest)

on mouseDown m iGizmo do (
if (keyboard.controlPressed) do fnDeleteItem (iGizmo + 1)
)

on updateGizmos do (
this.clearGizmos()

if (target != undefined) do (
this.aPoint3Tab = target.aPoint3Tab
)

for nPoint in this.aPoint3Tab do (
gizShape = manip.makeGizmoShape()
gizShape.startNewLine()

gizShape.addPoint (nPoint + [10,10,0])
gizShape.addPoint (nPoint + [10,-10,0])
gizShape.addPoint (nPoint + [-10,-10,0])
gizShape.addPoint (nPoint + [-10,10,0])
gizShape.addPoint (nPoint + [10,10,0])

this.addGizmoShape gizShape 0 colA colB
)

return ""
)
)
)


This way it works fine:

$.fnDeleteItem 2


I checked the forums but there isn't much on handling tab parameters. I also tried "deleteItem this.aPoint3Tab iItem" but that didn't change anything.

Any help would be appreciated!
Max.

denisT
03-30-2012, 03:57 PM
Hi,

I have a problem modifying tab parameters from "inside" the plugin, which screams scope issue in my face but I'm sort of stuck. Calling the same function (fnDeleteItem) from within the onMouseDown event does invoke the tabChange event handler, but has no effect on the tab itself. Whereas calling it from "outside" works just fine.



(
function fnDeleteItem iItem = (
deleteItem target.aPoint3Tab iItem
)



you have to delete item from paramblock of node (target), you are trying to delete from plugin defenition (this).

zortech
03-30-2012, 08:33 PM
Thank you for the clarification, that makes sense now! And also solves another problem I sort of worked around. :thumbsup:

CGTalk Moderation
03-30-2012, 08:33 PM
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.