forked from lookbothways/vfxTools
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrandRotExport
More file actions
77 lines (59 loc) · 2.04 KB
/
Copy pathrandRotExport
File metadata and controls
77 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Random scale selected, rotate selected
import maya.cmds as cmds
import random
import time
import os
import os.path
import glob
import os.path
import sys
import subprocess
"""
Get the correct mask value using these constants:
AI_NODE_UNDEFINED 0x0000
AI_NODE_OPTIONS 0x0001
AI_NODE_CAMERA 0x0002
AI_NODE_LIGHT 0x0004
AI_NODE_SHAPE 0x0008
AI_NODE_SHADER 0x0010
AI_NODE_OVERRIDE 0x0020
AI_NODE_DRIVER 0x0040
AI_NODE_FILTER 0x0080
AI_NODE_ALL 0xFFFF
mask = arnold.AI_NODE_OPTIONS | arnold.AI_NODE_LIGHT | arnold.AI_NODE_SHAPE | arnold.AI_NODE_OVERRIDE | arnold.AI_NODE_FILTER
print mask
mask=173 mesh no shaders, but tse on.
mask=253 export all the things
"""
randomiseThese = cmds.ls(sl=True)
outputName = "brick"
def randomiseObjects():
i = []
for i in randomiseThese:
randX = random.random()*100.5
randY = random.random()*100.5
randZ = random.random()*100.5
randRotX = (cmds.getAttr( i+'.rotateX')*randX)
randRotY = (cmds.getAttr( i+'.rotateX')*randY)
randRotZ = (cmds.getAttr( i+'.rotateX')*randZ)
cmds.setAttr( i+'.rotate', randRotX, randRotY, randRotZ)
step = 1
numberOfThingsToExport = 15
cmds.currentTime( 1 )
# Choose output directory
dir = cmds.fileDialog2(fm=3, dialogStyle=2, cap='Select output location', okCaption='Save here')
dir = dir[0]+"/"
print dir
while cmds.currentTime( query=True ) < numberOfThingsToExport+1:
randomiseObjects()
frameNow = str(round(cmds.currentTime( query=True )))[0:-2]
name = outputName+"_"+frameNow
timeNow = cmds.currentTime( query=True )
print timeNow
nextStep = timeNow+step
cmds.currentTime( nextStep, update=True, edit=True )
timeNow = cmds.currentTime( query=True )
export_file = "{}{}.ass".format(dir,name)
print "Exporting "+export_file
cmds.arnoldExportAss(f=export_file,fsh=True,s=True,frameStep=1,mask=253,lightLinks=0,shadowLinks=0,selected=True,boundingBox=True)
#end