I would like to know how I can create a script that specifically deletes a certain object from the scene.
Example: I accidentally select a space warp or particle view or something and I want to be able to click a button that automatically finds particle view and removes it from my scene.
Here's my lousy attempt:
(
on press return (Particle_View.current!=undefined)
on execute do
(
if( Particle_View:Particle View.current==undefined ) then true
else Particle_View.current.DeleteSelected()
)
)
Comments (7)
Comment policy
the fastest way is:
if (pfs = getclassinstances PF_Source).count > 0 do delete pfs
Are you test your code? if
Are you test your code?
First "pfs" variable is local to the IF scope and become undefined for the delete ops, so the well known error appear:
But that not is all, try this:
Thanks Anubis, this for loop is way more efficient and get rid of the Array.
the fast way to delete all PF_Source in the scene:
thank you very much guys. I'm going to experiment with these and see if I can't learn something :)
Here is a version which ask for user if he wants to delete the PF_Source with its name in the querybox.
I'm not sureif I understood correctly, but you could loop through each scene object and make an array with only the PF_Source. Then in a for loop you could delete every object in the array. It's not really clean I'm no maxscript pro but this seems to work.