Notifications
Clear all

[Closed] Remove multilisbox selections

hi,

I was wondering how my multilistbox selection. I’m using a button to do it.

I tried this:

deleteItem pNamearr ParentRollout.parentLbx.selection 
  ParentRollout.parentLbx.items = pNamearr

but i’ve got this error message:

MAXScript Rollout Handler Exception: -- Runtime error: array index must be positive number, got: #{5..11}

I tried this:

 res = parentRollout.parentLbx.selection 
  for elem in res do 
  ( 
  	deleteItem pNamearr elem 
  )
 

but got this error:

>> MAXScript Rollout Handler Exception: -- Runtime error: array index out of bounds: 7 <<

now i’m lost :S

btw, how is it possible to put 2 fn in one?

i would like to use this 2 fonctions for a SelectByName filter:


fn ShapeSelectionLimit = shape_filt obj = isKindOf obj shape
fn filterUnique obj = findItem pNameArr obj.name == 0
14 Replies
1 Reply
(@davestewart)
Joined: 11 months ago

Posts: 0

I odn’t think so, I tried the exact same thing the other day, and only one function was created. Easiest thinfg is to use 2 intermediate functions that call the main function.

For multilistboxes, the selection is a bit-array (NOT an index) in your case elements 5 to 11 are selected, so you would need to loop BACKWARDS through your array (from 11 to 5), calling deleteItem on it, then re-apply the items to the multilistbox.

If you don’t go backwards, you count up from 5 to 11, but by the time you’re halfway through deleting items (5, 6, 7, 8), you’ve already shortened the array below, say 8, so iterations 8 and above would fail, as you can’t delete element 8, 9, 10, or 11 as the array is already too short.

Make sense?

Dave

thx for your answer.

i m going to try it

I’m back again
I just continue my script and fund the answer about how to use 2 functions in 1

the original functions are:


 fn PathfilterUnique obj = findItem PathNameArr obj.name == 0
 fn ShapeSelectionLimit = shape_filt obj = isKindOf obj shape

and the answer is:

fn PathfilterUnique obj = ((findItem PathNameArr obj.name == 0) and ( isKindOf obj shape))

about the question; how to delete my Mlb selection; a friend fund this;

on parentDelBtn pressed do 
     (
         index=parentRollout.parentLbx.items.count    
         while index > 0 do
         (
             temp = parentRollout.parentLbx.items        
             if parentRollout.parentLbx.selection[index] == true then
             (
                 deleteItem temp index
                 parentRollout.parentLbx.items =  temp
             )
             index-=1
         )
     )

I hope it can help some people.

Here’s another way that’s a little more optimized


-- list is the multiListBox

on bt_remove pressed do
  (
  	   items = (list.items as array)
  	   for o = (list.items as array).count to 1 by -1 where ( findItem (list.selection as array) o ) != 0 do deleteItem items o
  	   list.items = items
  )

thx for your answer Jason ^^

Sorry for replying way after the fact

Or even shorter

list.items = for i = 1 to list.items.count where not list.selection[i] collect list.items[i]

Martijn

bedankt Martijn

Oh snapple!

2 Replies
(@zeboxx2)
Joined: 11 months ago

Posts: 0
list.items = for i in (-list.selection) collect list.items[i]

cough

(@magicm)
Joined: 11 months ago

Posts: 0

Google > define:snapple > Soft drinks ???

pfffff

echt bedankt

Page 1 / 2