Notifications
Clear all

[Closed] SetSelectionFilter Script Problems

I just did a search on the Forums and also googled for the solution I am looking for first.

Here is what I am experiencing

if it do the following

 
 SetSelectFilter 8 --Bones
 Max Select All
 for i in $selection do 
 (
	  print i.name --prints a list of Bones names
 )
 
 clearSelection()
 

It does not output the expected result of bone names.

however if I do the any of the lower numbered filters it works just fine.
so doing

  
 SetSelectFilter 2 --Geometry
 Max Select All
 for i in $selection do 
 (
	  print i.name --Prints a list of my Meshes in the Scene
 )
 
 clearSelection()
 

The only difference between the two is the selection filter.
But it gets even more bizzare.

If you do the following from the listener.

 
 SetSelectFilter 8 --Bones
 Max Select All
clearSelection()

and then run the script from above for Filter 8 it seems to work correctly. However if you change the filter to 9 (IK Chains) the output is still from filter 8. If you insert a print statement to see the filter it is on before or after the select all or after the filter change it reports what one would see as the correct filter. Maxscript just does not seem to be picking up the change.

5 Replies

Hi David,
I guess selection filers in MaxScript are only used to set current UI status and affect selections done manually in the scene.

If you want to work on a subset of objects, just collect them checking their class.

for item in Geometry where ((classOf item) == BoneGeometry) do ( print item.name )
aBones = for item in Geometry where ((classOf item) == BoneGeometry) collect item
format "Bones: %
" aBones
  • Enrico

I will try out the classof code. But it comes across as poor coding on autodesks part.

I would also be more inclined to believe that selection Filters were only good for setting current UI status. Except for the fact that it works correctly for items 1-7 but not for 8 9 and 10. Which are Bones, IK Chains, and Points.

It may be that Autodesk never checked it and that most people don’t use this small subset of maxscript therefore it checked out on shapes, geo, etc, but was never tested with Bones, IK and points.

The code doesn’t seem to work for IK Chains as they are not a class of geometry. I will look up what their superclass is…

IK_chains -> class: IK_Chain_Object, superClass: Helper

If you want to test over every node in the scene, run through “Objects” rather than “Geometry”.

  • Enrico

for objs in Objects where (classOf(objs) == IK_Chain_Object) do
(
	iks = objs
	select iks
)

had to make a couple of changes for my own usage but the classOf is working well enough for me to get the information that I need. However the bug is going to annoy me for a while.