[Closed] Variable of Element Pack and Optimization
Hey MaxScripters.
What I am trying to optimize:
How can I store UVW Element information in a loop. Like each element in the scene is information I can store into a variable. Right now I am using a for loop to basically make like a data cluster as max calls it.
How it would just make it so much easier that I am thinking of:
a one line like “selection[1].modifiers[1].getSelectedElements”
Any thoughts?
Here is the code so you can see what I am doing:
local totele=#()
button thePackbyElementButton "Pack By Element" width: 160 align:#left offset:[0,0]
on thePackbyElementButton pressed do
(
selfac = (selection[1].modifiers[1].getSelectedFaces() as array)
for j in selfac do
(
t = findItem totele j
if t == 0 then
(
selection[1].modifiers[1].selectFaces #{j}
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
selection[1].modifiers[1].expandGeomFaceSelection()
aof = selection[1].modifiers[1].getSelectedFaces()
append totele aof as array
)
else
(
continue
)
for e in totele do
(
z = e as bitArray
selection[1].modifiers[1].selectFaces z
selection[1].modifiers[1].pack 1 0.02 true false false
selection[1].modifiers[1].GroupCreateBySelection()
)
)
)
The reason why I am needing this is to optimize for speed. Right now it is just unacceptably slow on a scene with 100k polygons.
For anyone, I hope this isn’t being a necromancer, but this is here in case the keyword “.getSelectedElements” and maxscript is posted, that hopefully they will find this thread and get the help they need. When I finish the code I’ll see if I can’t post it here.
But here you go!
P.S. Read all of it. They make it a duel on who can get the fastest memory lol. And if you are green like me. You can see how there is plenty to learn