Notifications
Clear all

[Closed] filtering selectionSets by name?

Hi guys,

i’m working on a little script where it opens a rollout with a listBox, and you can see all the selection sets from the scene in that listBox, my idea is that I only want it to show the selection sets with a specificy name, in this case “*_cache”, so whatever selection that ends in “_cache” should show up in the rollout…but I ‘m having some problems with it and nothing will show up unless i explicitly put the name of the selection set i want…

Any help really appreciated, thanks!

and here’s what i got so far

theSets = selectionSets
rollout cacheImporter “cache importer”
(
listbox mysetsBox “Objects:” items:(for s in theSets where s.name == “*_cache” collect s.name) selection: 0 height: 20
edittext base_name “prefix” fieldWidth: 150
button import_them “Import Caches…”

on mysetsBox selected nameIndex do
	(
		print nameIndex
		index = nameIndex
		select selectionsets[index]
	)

)
createDialog cacheImporter 250 350

3 Replies

I gave you the answer on another forum, but for anyone else that comes here it is because the current code is looking for a specific entry equal to “_cache” not a wild card search. Replacing [B][I]s.name == “_cache”[/I][/B] with (matchpattern s.name pattern:”*_cache”) fixed the issue.

-Eric

yeah I saw it, thanks again Eric, really helpful!

Try this concept with search bar


   try (DestroyDialog ::testRoll) catch()
   rollout testRoll "Combo Box"
   (
   	fn ssCollection patt: =
   	(
   		if selectionSets.count == 0 then return #() else
   		(
   			if patt == unsupplied or patt == "" then 
   			(
   				for i in 1 to selectionSets.count collect selectionSets[i].name
   			)
   			else (for i in 1 to selectionSets.count where MatchPattern selectionSets[i].name pattern:("*"+patt+"*") collect selectionSets[i].name)
   		)
   	)
   	edittext et "Search" text:"_cache"
   	listbox lb "Objects" items:#() selection:0
   	on et changed txt do lb.items = ssCollection patt:et.text
   	on lb selected itm do select selectionSets[lb.selected]
   	on testRoll open do (lb.items = ssCollection patt:et.text)
   )
   createDialog testroll
   

Edit:
I have not seen Eric post but he was probably thinking of this