Notifications
Clear all

[Closed] create rollout problem

I forgot from where i found this script, and it work fine when i copy and paste the script to the maxscript editor and evaluate it:

for o in objects do (
o.controller=prs()
if classof o.parent == LinkComposite do o.parent = undefined
)
for o in objects where classof o == LinkComposite do delete o

but when i create a button for it like this:

rollout test "Options"
(
  button btn_DAblock "delete"

on btn_DAblock pressed do
	(
		for o in objects do (
		o.controller=prs()
		if classof o.parent == LinkComposite do o.parent = undefined
		)
		
		for o in objects where classof o == LinkComposite do delete o
	)
	
)

i get the below error from maxscript listener:

-- Error occurred in btn_DAblock.pressed(); filename: C:\Users\jackie.AJMI\Downloads\delte acad test.ms; position: 324; line: 14
--  Frame:
>> MAXScript Rollout Handler Exception:
-- Unknown system exception <<

why is this happen? how to fix it?

2 Replies

Deleting from a live object set is definitely bad practice, it will change while you are iterating it… instead, I’d use

delete (for o in objects where classof o == LinkComposite collect o)

1 Reply
(@jackieteh)
Joined: 10 months ago

Posts: 0

It work like a charm!! actually what is the difference between your code and mine?
because mine also work before create rollout, but it give error warning i create the rollout for it??

could you please explain? i want to learn maxscript, not just copy and paste code, thank you. :drool: