PDA

View Full Version : Searching for Callbacks..


MikeOwen
04-15-2008, 02:54 PM
Hi All,

Does anyone know the code to search recursively through all the scene callbacks by id:# and use a wildcard to search for there id:# names?
Something like:

for x in 1 to callbacks.count do
(
if matchpattern (callbacks[x].id as string) == "RPM*" then
()
x+=1
)

Mike

MoonDoggie
04-15-2008, 03:02 PM
Assuming you are storing all of your scene callbacks in the variable array "callbacks"


for x = 1 to callbacks.count do (
if (matchPattern (callbacks[x].id as string) "RPM*") == true then (
-- do something if it finds it
)
)

MikeOwen
04-15-2008, 03:26 PM
Sorry, but there is no such thing as callbacks.count! hence my problem!

eek
04-15-2008, 04:49 PM
I think callbacks.show() is the closest your gunna get.

davestewart
04-15-2008, 04:50 PM
Well, callbacks.show() lists all callbacks, so I guess it's just a case of filterstring-ing that string.

MikeOwen
04-15-2008, 05:08 PM
Thanks Dave, but I don't see how filterstring is going to help me here as the command "callbacks.show()" only prints to the Maxscript listerner and is not entered into an array or can be passed to a variable when it is executed?
Any ideas?
Thanks,
Mike

ZeBoxx2
04-15-2008, 05:26 PM
closeLog() -- close the listener log file, if any
openLog "c:\\listener.log" mode:"w" outputOnly:true -- log listener output
callbacks.show() -- get all the callbacks. This output will now be in "c:\\listener.log" as well
flushLog() -- flush the log
closeLog() -- close the log


From there on, open the file, and parse its content for the information you want (i.e. callback type, the ID, etc.)

The above wil destroy any previous listener logging set up, of course.

MikeOwen
04-16-2008, 09:03 AM
thanks Richard. I see the approach now!

MoonDoggie
04-16-2008, 02:34 PM
Assuming you are storing all of your scene callbacks in the variable array "callbacks"

If there isn't a variable array "callbacks" obviously it won't work. My snippet of code was also to show you that you don't have to increase the value of X in your for loop, that's what the loop itself does.

-Colin

davestewart
04-17-2008, 11:07 AM
From there on, open the file, and parse its content for the information

And I wish autodesk would update all its functions use "to:" !

ss = stringstream ""
callbacks.show to:ss

ZeBoxx2
04-17-2008, 12:04 PM
yep.. I tried "to:<stringstream>" just in case it just wasn't documented - but alas.

CGTalk Moderation
04-17-2008, 12:04 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.