[Closed] Select random single object
Hi
I’ve never done any kind of scripting before, but I need a way to go through a scene and select individual objects.
Basically, I have a scene full of Editable Mesh objects that I need to convert to Editable Poly which I will then run Quadrify on. I’ve figured how I can do this if I manually select each object I want to quadrify, by running the Macro Recorder whilst doing my process.
macros.run "Modifier Stack" "Convert_to_Poly"
macros.run "PolyTools" "Quadrify"
But I have close to 800 objects I need to do this to, and doing it one-by-one is just going to take too much time. Is there any way I can run some kind of batch that will go through each editable_mesh object and do what I described above?
Thank you.
FOR Loops are meant to be used in MAXScript for doing what you asked for.
There are many ways to filter the scene objects you want to affect, but from what you described, it sounds like filtering for Editable_Mesh is all you want.
Here is one possible way to implement a FOR loop that goes through all scene geometry objects, finds the ones that are an Editable_Mesh either because their BaseObject is Editable_Mesh, or because they have a modifier on the stack that turns them to one at the top of the stack (e.g. Geosphere with Mesh_Select is also a kind of Editable_Mesh):
for o in geometry where isKindOf o Editable_Mesh do
(
select o --the object must be selected for the Quadrify to work
convertToPoly o --MAXScript has a function for converting to EPoly
PolyToolsModeling.Quadrify false false --this is the actual MAXScript call to Quadrify
)
You can replace the last line with ‘macros.run “PolyTools” “Quadrify”’ and it will also work. Keep in mind that there will be a lot of flashing in the modify panel due to the changing selection, so it won’t be very fast, but it will still be better than clicking manually…
I suspect others might post different variations of this solution. There are many ways to skin a cat / loop the scene in MAXScript…
Thank you very much, Bobo! This is exactly what I was looking for. I had tried my hands on the FOR loops, but just couldn’t get it to cycle through my selection rather than just applying it to everything.
Using this I also managed to add on the other features that I realised I would need after I posted this thread.
Thank you again!