Notifications
Clear all

[Closed] Rapid Object Creation

Hello again,

I’m curious to see if anyone can come up with some code that creates objects as fast as possible and also deletes as fast as possible.

Right now my code I have isn’t too bad, but when I get up into the 2-4K range, it starts to take 5-10 seconds or more. But this might be a limit to Max and also probably hardware/OS limits. Im using Max 2010 64bit to test right now, but I know for a fact my 2012 Max can do these things usually 2-3x faster.

To make it as fast as possible, as far as I know, I am turning off Undo, SceneRedraw, not accessing the Modifier Panel/Is closed, freezing the objects, not changing the selection and usually instancing meshes instead of making copies.

The objects transforms are being taken from computated positions from a mesh face, using meshop, barycentric coords and UVs, and get pixel. I know get pixel can be slow, but I am only doing this 1-2 times per face.

Im looping through a face array as a bitarray as well, and I have the meshop methods and such outside of the loop in local variables.

The only other way I can think of making this faster, is to use the SDK somehow, which I’m not sure that will make a huge difference or not?

Any Ideas?

Thanks!

6 Replies

there only 2 rules that can help you to create an object using mxs faster:
#1: do any creation in the create mode
#2:
if you are using max version < 2012 give the name to an object, like:


  box name:"theBox" ...
  

in versions < 2012 max takes a lot of time searching for unique name.

if you are in version 2012+ don’t give a name! it makes the creation slower.

and of course. If you have any own creation callbacks (node added, node created, etc.), turn them temporary off.

hmmm… Very interesting about the name. I didn’t think of that one/try that.

So ur saying, check max version in the code, if < 12, use uniquename and if >=2012 nothing?

I’ll check that out now quick and see what it does


 
if ((maxVersion())[1] < 14000) do theObj.name = uniqueName theObj.Name   
 

?? Or should I be giving it a name in the same line as instancing it somehow?

Edit: Nevermind, idk what I’m thikning, thats the same as what u just said makes it slow, hehe… sorry, woke up not long ago.

So yeah, doing name = “wee” or whatever, it was like 2-3x faster now, if not 5x or so!!

#1: do any creation in the create mode

Did you mean that I should activate Box Create Mode or something while doing it, or just be outside of the modifiy panel/ect?

Doing a test with the box mode active, it seemed to be slightly faster, but I didn’t do an actual ms/time check yet.

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

i mean to be outside #modify, #hierarchy, #motion, and #display panels…
#create is the right place… #utility is ok but kinda silly.

So I tested another script/plugin, that does something similar, although it must be going about creating/storing the geo differently.

I think since its a plugin, its creating what looks like seperate meshes, as one mesh. So thats how it can be faster. It might even be creating them as particles or something similar.

I’m talking about http://www.itoosoft.com/forestpack.php .

I would probably have to make a plugin as well to be able to do this sort of thing, huh? Or use particles.

Edit: A quote from their page,

It can create more than 500,000 trees per second at viewport, modify any parameter and rebuild them in real-time.

My script can currently only do around 1100 a second. Although, I’m using the actual geo and not proxies.