Notifications
Clear all

[Closed] why this function runs too slow in max 5?

i have write a fn for collapse objects with same material . but i dont know why this function runs too too slow in max 5 , but works fast in max6 and max7 . maybe some setting wrong with my max 5 ? thanks for reply .
fn code :


fn objsByMat selectObjs =
(
local end_array=for i in sceneMaterials collect #()
for i=1 to sceneMaterials.count do 
 (
 for j in selectObjs do 
  (
  if (j.material)!=undefined do 
   (
   if (j.material)==sceneMaterials[i] do 
	(
	append end_array[i] j--.name
	)
   
   )
  )
 )
return end_array
)

4 Replies

Hi, try this, although im not sure if there will be a significant change in speed coz this one is also from max6


fn objsByMat selectObjs =
(
count = sceneMaterials.count
local end_array = for i in 1 to count collect #()
for i in selectObjs where i.material != undefined do
 (
 index = finditem sceneMaterials i.material
 if index != 0 do append end_array[index] i
 )
return end_array
)

there’s also a good section in the reference titled: “How to Make it Faster” just in case you havent bumped into it yet.

Is that slow with this function too ?

fn objByMat selectObjs = (
	local theMats = for m in sceneMaterials collect m
	local objByMatArray = for m=1 to theMats.count collect #()
	for obj in selectObjs do (
		local posMat = findItem theMats obj.material
		if posMat!=0 do append objByMatArray[posMat] obj.name
		)
	objByMatArray
	)

objByMat selection

yes , i have read the topic , learned more ,thanks .

by the way ,arketip`s head portrait makes me missing my friend “prettyPixel” .

Yes it’s me

My hypothesis is that the access to ‘sceneMaterials’ is slower in 3DSmax5. This is why I store it in an array. That is just an hypothesis…