Notifications
Clear all

[Closed] "Rename Objects" very slow

In max9, I use the “Rename Objects…” tool to rename >2000 objects, but it didn’t respond
so I test rename 200 objects, it is very slow, maybe spend 20 seconds!
i try this:

(
for i in selection do i.name = uniqueName “tree”
)

or:
(
gc()
_tree = getCurrentSelection()
disableSceneRedraw()
flag = 0
for i in 1 to _tree.count do
(
_tree[i].name = “tree” + i as string
flag += 1
if flag > 300 then
(
gc()
flag = 0
)
)
enableSceneRedraw()
redrawViews()
)

it still didn’t respond

why sometimes max rename objects very slow?

6 Replies

If I remember correctly it was kind of a bug in max9… I think they fixed it in 2008, or it’s at least fixed now. When I was at Blur, they ended up writing their own function in a plugin to fix it.

Renaming selected nodes can be really slow. :shrug:
To bypass it, you can store the selection in an array.

Benchmark:


for x=1 to 1000 do teapot()

select objects
st = timestamp()
for o in selection do o.name = uniquename "s"
format "With Selection: % ms
" (timestamp()-st)

clearselection()
st = timestamp()
for o in selection do o.name = uniquename "o"
format "Without Selection: % ms
" (timestamp()-st)

delete objects
With Selection: 1911 ms
Without Selection: 8 ms

Solution:

aSelection = selection as array
clearselection()
for pCurNode in aSelection do pCurNode.name = uniquename "s"

haha
the perfect solution!
Thanks for your reply,thanks

Ahh ^ …good to know! Couldn’t remember what the issue was, maybe that was all it was.

the node renaming causes many system notifications. Selected node causes more notifications then unselected. You can temporally disable/enable reference notification using in pair:
[left]disableRefMsgs()
[/left]
[left]enableRefMsgs()

[/left]
[left]


  [/left]
  delete objects
  for k=1 to 1000 do box()
  select objects
  t1 = timestamp()
  for n in objects do n.name = n.name
  t2 = timestamp()
  disableRefMsgs()
  t3 = timestamp()
  for n in objects do n.name = n.name
  t4 = timestamp()
  enableRefMsgs()
  deselect objects
  t5 = timestamp()
  for n in objects do n.name = n.name
  t6 = timestamp()
  format "with notify: %
" (t2-t1)
  format "without notify: %
" (t4-t3)
  format "deselected: %
" (t6-t5)[left]

[/left]

Oh, so that’s it.
cool