Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Randomly Rotate Objects

KraiggC
Advocate

Randomly Rotate Objects

KraiggC
Advocate
Advocate

I feel like I'm gonna need to write a script for this, assuming there isn't one out there already for this. I'm trying to find out a way to randomly rotate objects I've place in a scene? Maybe even adjust scale slightly, but I can figure this out once I figure out the rotation part. For example, I place trees into parking medians and have them rotate randomly instead of going through and rotating them manually.

0 Likes
Reply
Accepted solutions (1)
5,546 Views
6 Replies
Replies (6)

10DSpace
Advisor
Advisor

@KraiggC 

 

For o in selection do o.rotation.z_rotation = random 0.0 360.0

 

Will rotate the selected objects on Z axis as you are describing.  If you want to confine the range of random rotation to less than a full 360 degrees make adjustments accordingly.

darawork
Advisor
Advisor
Accepted solution

Hi,

 

There is a script already for this, handily enough, here it is:
https://www.scriptspot.com/3ds-max/scripts/mass-randomizer

 

darawork_1-1663345660345.png

 


Functions:
"

  • Position
  • Rotation
  • Scale
  • Length-width-heigth- radius parameters
  • UV Offset Values
  • G-Buffer ID's
  • Selection (object and subobject)
  • Color and Materials "

    Has the ability to undo too, if I remember correctly.
    Pretty handy script, the additional extras in the drop-down are great.

    Regards,

Darawork
AutoDesk User
Windows 10/11, 3DS Max 2022/24, Revit 2022, AutoCad 2024, Dell Precision 5810/20, ASUS DIY, nVidia Quadro P5000/RTX 5000/GTX760

KraiggC
Advocate
Advocate

Thanks Dara, exactly what I was looking for.. I guess my next question is how do I get it to permanently be in my 3ds, or do I just have to drag it in every time I want to use it? 

Yes, I've done what was mentioned on the download link; but Tik wasn't under the category tab so I don't know how to add this script to any toolbar or quad menu.

0 Likes

darawork
Advisor
Advisor

I have a container script dialogue for all the random scripts I download. I don't make custom buttons, that fill up the toolbar. I have to edit them, just a few lines and it works. I'll explain in a new post this week coming up on here. Just not now. I typed out a massive explaination, to not opt for another button, or shortcut key. It was long and detailed (several full screen screen-shots embedded too. Video links too). 

Then my account page log-on timed out. And I lost all that I had typed or screenshotted.

I suggest you checkout Scriptspot via Google. You can animate or automate anything with free scripts in 3dsMax. But each person might be less comfortable reading code, I say reading, but I mean scanning.

It's entirely doable. Even playing a MassFX game of Alien Invaders.
Less than a mb scene size.

There is a lot of code missing or not correct for anything past maybe 2018 Max.
Always save your main scene first, as a back up, with todays filename and version, at least once per 10mins.
Especially when random people try to type explainations to 3dsmax 2016-2023 online. And ask you to run strange  code. 🙂

Regards,

 

Darawork
AutoDesk User
Windows 10/11, 3DS Max 2022/24, Revit 2022, AutoCad 2024, Dell Precision 5810/20, ASUS DIY, nVidia Quadro P5000/RTX 5000/GTX760

0 Likes

darawork
Advisor
Advisor
" but Tik wasn't under the category tab so I don't know how to add this script to any toolbar or quad menu."
I got a lot of HTML errors in the Maxscript. I fixed two, but it seems yer man has pulled it from scriptspot. Was too hard too download from Github and try to get it as normal Macorscript. The errors the 2018 version had are easily fixed. I just delete the lines of code from the ms wach time it gives a localised error. Or make something up.

https://www.youtube.com/watch?v=CFixg1t5UrM

Best of luck.

Regards,

Darawork
AutoDesk User
Windows 10/11, 3DS Max 2022/24, Revit 2022, AutoCad 2024, Dell Precision 5810/20, ASUS DIY, nVidia Quadro P5000/RTX 5000/GTX760

0 Likes

10DSpace
Advisor
Advisor

@darawork  @KraiggC 

 

I downloaded the script and found that the macroscript header info was commented out.  All you have to do is delete the enclosing " /* " and  " */ " in the first 6 lines of code in a text editor (or the maxscript Editor): 

 

/*   <---delete
macroScript randomize
category: "Tik Works"
toolTip: "Mass Randomizer"
buttonText: "Mass Randomizer"
*/ <---delete

 

and then when you drag the edited Tik_Mass_Randomizer_v1.95.mcr into a viewport it will appear in the list of actions under "Tik Works" category as "Mass Randomizer:

 

10DSpace_0-1663362997118.png

 

 

Thanks, Dara for alerting me to this script.  Very useful.