
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a python equivalent of converting a bitarray to a List / Tuple?
In Maxscript:
-- BitArray to Array
selectedFaces = getFaceSelection $
faceIndices = selectedFaces as array
-- Array to BitArray
newBitArray = faceIndices as bitarray
I can get the list of face indices I need, it's quick and most importantly fast, especially on a dense mesh.
In Python however, I cannot find any equivalent function or help on the "as" keyword, nor a conversion function from pymxs.runtime.BitArray to pymxs.runtime.Array / List / Tuple
Currently I'm using a work around, with involves going through all of the vertices and retrieving it using a list comprehension.
In Python:
from pymxs import runtime as rt
# BitArray to Array
selectedFaces = rt.getFaceSelection(rt.selection[0])
faceIndices = [(index+1) for index in range(len(selectedFaces.count)) if selectedFaces[index] == True]
# Array to BitArray
newBitArray = rt.BitArray()
newBitArray.count = selectedFaces.count
for index in faceIndices: newBitArray[index] = True
I have been looking for an answer for a while now, to no avail. There is no documentation on pymxs, and maxscript documentation just tells me to use the "as" keyword. rt.show(rt.BitArray) just returns be the wrapper functions, and help(rt.BitArray) gives me nothing as well.
As you can imagine, everytime i need to convert an array to a bitarray or an array to a bitarray, i'm going through all of the indices, and with dense meshes, this slows down a lot.
Help is very much appreciated, if anyone could provide an alternative method to convert these data types, or know of the python wrapping function. This would help my optimization pass on my tool. Thank you.
Solved! Go to Solution.