[Closed] BitArrays
Hello,
Could someone explain me how works bitarrays ? I have a bitarray, and I need to turn off some of its item so I use only the “on” without changing their index.
I have heard I can perfectly do that with a bitarray but find no infos in the help or google
Thanks
bit arrays as it says in the maxscript help is simply an array that contains values that are either true or false i.e. bits.
A good way to look at how they work is to make an object and set some of the transform lock flags on and off.
If you then run this:
tlf = gettransformlockflags $ –this returns a bit array
for i = 1 to tlf.count do
(
format ((i as string)+”: “+(tlf[i] as string)+”
“)
)
It will show you that some of them are set to true (matching the ticks you set) or false (the ones without the tick).
So say you have a bit array of 20 items and you want the fifth and tenth to be ‘off’ you ensure index 5 and index 10 are set to false (as far as I’m aware anyway!)
fairly simple stuff the way max displays it makes it a touch confusing
for example
(
ba = #{}; -- create empty bit array
print ba;
ba.count = 100 -- create storage for 100 bits
print ba;
ba[100] = true -- set 100th to true
print ba
ba = #{1..100}; -- create 100 bit array all set
print ba
ba[50] = false -- set 50th to false
print ba
)