Notifications
Clear all

[Closed] unregister filter functions?

 PEN

So I have a tool that creates selection filters based on a name of an object. You can just type in the name that you want and hit add. This is only for the current session of Max. It doesn’t write out a script that will be loaded again.

The function that creates the filter builds a string and then executes the string. This works as it should and the filter is added. I want to be able to remove the filter. I can use unreg… on a filter that I have hard coded and loaded when max starts without a problem.

The issue I’m having is removing one of the temporary filters. I have named the call back function the same as the filter name but it will not remove it.

Would this have something to do with executing the function from a string in the first place? I’m not sure what the difference is here. Any help would be great.

9 Replies
1 Reply
(@mustan9)
Joined: 2 years ago

Posts: 0

Try removing it via the execute() command.

 PEN

I have, still doesn’t work.

Hi Paul,

I managed to cobble together a trackbar filter script to filter out separate custom attribute keys for the characters on our current project. When you select the head it brings up a dialog giving you options to filter blinks, lipsynch, expressions etc. In mine, I remove the filter before creating another one and as i know the index number i can unregister it via the index number ie –

(maxOps.trackBar).unRegisterFilter 8

I found the whole trackbar filter interface a tad confusing to be honest and Dave Stweart made a good script on the discreet board that helped.

 PEN

Thanks but this isn’t a track bar filter, it is a selection filter in the main tool bar. So you can filter what objects you select.

Hi Paul,

Are the filter functions declared as globals?
This code works on my side. When used without the explicit global decleration, I get an error the first time I run it, but then it work the second time. This might also be affecting your code.


(
	local txt = "fn spheres o = matchPattern o.name pattern:\"sphere*\""
	execute txt
	global spheres
	registerSelectFilterCallback spheres "Spheres"
)
-- unregisterSelectFilterCallback spheres

cheers,
o

 PEN

No but I would have thought that execute made them global. Also I can call the function globaly. I will try forcing it as you have and see what happens.

Ok Paul, I gotcha. Sorry, i got confused with the two. Recursive functions can do that to a man. I dont suppose this is by any chance a character selection filter thing you’re writing to stop people selecting parts of the rig they shouldn’t?

 PEN

Well I use the selection filters for characters so that I can have filters just for a specific character or specific parts of characters. I have a number of them that I use all the time but often just want temporary ones while I’m rigging to make it easy to select certain objects. You cna jsut type in a name and the filter is added. Once I complete it I will release it to the public.

Hi Paul,
That sounds really useful – For our production I use a structure containing the nodes of the characters we use – that way, i can build many utilities that are simple in terms of code and reference multiple characters (like the trackbar filter i mentioned – it just uses a callback when it detects the CA defs on the character’s head) Dont know if its the fastest or best way of doing things but it seems to work well enough! let me know how you get on!

BTW – nice car rigging on your site!