PDA

View Full Version : Prevent object cloning ?


kittikun
10-29-2009, 09:57 AM
Hi all,

I have a helper that attaches itself to an object. I don’t want to the user to be able to clone it for various reasons. Is there a way to achieve this ?

Even by hooking on the preNodesCloned callback, there is no way to cancel the operation from what i’ve found…

Thanks !

bkravi
10-29-2009, 11:50 AM
you may use #postNodesCloned callback which returns 3 element array (first element is an array of the original nodes, the second element is an array of the cloned nodes, and the third element is a name value of #copy, #instance, or #reference, reflecting the clone type)

then if the returning 1st element is your helper object then immidiatly delete your cloned nodes from second element (which contains cloned nodes.)

I don't think you can stop cloning after calling the #preNodescloned callback.

kittikun
10-30-2009, 11:46 AM
Hum, the copy still happens even if I do

fn test =
(
t = callbacks.notificationParam()
t[1] = #()
t[2] = #()
t[3] = #()
)

callbacks.addScript #postNodesCloned "test ()" id:#testHelper

SyncViewS
10-30-2009, 02:02 PM
Hi kittykun, bkravi idea is to allow cloning, because you cannot stop 3ds max to do it, but to set a callback that deletes the clones as soon as they're created.
callbacks.notificationParam() returns an array of arrays you can use to find what nodes have been creted after a clone operation to delete them.

Following code creates a callback broadcasted after every clone operation that call a function which deletes every new object, as listed in second array from callbacks.notificationParam().

function preventCloning =
(
local aClonedNodes = (callbacks.notificationParam())[2]
for theNode in aClonedNodes do delete theNode
)

-- evaluate this to add the callback
callbacks.addScript #postNodesCloned "preventCloning()" id:#cbClonePreventer

-- evaluate this to remove the callback
callbacks.removeScripts id:#cbClonePreventer
- Enrico

CGTalk Moderation
10-30-2009, 02:02 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.