Notifications
Clear all

[Closed] objects vs geometry

Hi,

I was wondering why my code performed so slow today and I could break it down to one single line:

arrtemp = for obj in geometry where classof obj == VrayProxy collect obj – about 5 seconds

I thought this might be a problem because there are several thousands geometry objects in the scene.
When I changed the code just for fun to:

arrtemp = for obj in objects where classof obj == VrayProxy collect obj – almost immediately

The Operation was done right after I hit Shift+E.

Since “geometry” is a subclass of “objects” I thought making the amount of objects to search smaller before collecting the array is a good idea but MaxScript prooved me wrong. Could someone explain this to me?

  • kogen
3 Replies
 lo1

I get better results when using the geometry collection, but even for 5000 objects it’s still a matter of 10ms vs 50ms, never more than a second.

Sometimes we can speedup the things when use predefined array and append method. But I not tested this for your case.

vrProxyArr = #()
for p in geometry where isKindOf p VRayProxy do append vrProxyArr p 

Yeah, Io I see your point, I’ve never had this problem before, but this time it was very obvious.
gazybara, your idea is good, but I’m not sure if I understand that right. As far as I know using collect instead of append is faster and creating the array (arrtemp) with the collect statement results in the same as your code. Did I maybe get something wrong?