Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Rotating in 90º increments in Mash - Python

Rotating in 90º increments in Mash - Python

Parmenides
Collaborator Collaborator
462 Views
2 Replies
Message 1 of 3

Rotating in 90º increments in Mash - Python

Parmenides
Collaborator
Collaborator

Posted this a few weeks ago but no responses. Didn't realize there was a specific programming forum.

 

Previously when you needed to increment 90º in Mash you could run this python script below. But I guess that the updated python has broken it. (Error: object does not exist.) Can someone with python experience update it?  

 

I know there is a way to rotate using the offset tool as well but it breaks down when you get to thousands of tiles and the noise doesn't control it finely enough. 

 

import openMASH
import random

#initialise the MASH network data
md = openMASH.MASHData(thisNode)

#this is how to get the frame number
frame = md.getFrame()
#and this gets the number of objects in the network
count = md.count()
random.seed(0)
#add the index to the Y position
for i in range(count):
    multiplier = random.randint(0,6)
    rot = 90*multiplier
    md.outRotation[i].y=rot

#tell MASH to write the network data
md.setData()

Thanks.  

Accepted solutions (1)
463 Views
2 Replies
Replies (2)
Message 2 of 3

FirespriteNate
Advocate
Advocate
Accepted solution

That code works fine for me on Maya 2022 and 2024. This may be a stupid question, so apologies, but you are putting that code inside an existing python MASH node, and not just executing it in the Script Editor right?

0 Likes
Message 3 of 3

Parmenides
Collaborator
Collaborator

That was exactly what I was doing wrong. Thanks! Never wrote that crucial bit down in my notes. 

0 Likes