forked from lookbothways/vfxTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customQuery
169 lines (113 loc) · 3.8 KB
/
customQuery
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#WIP WIP WIP!!!
#-------------
import sgtk
import os
import re
#connect to SG
filename = "/mnt/projects/wb/assets/Light-Rig/arnoldSettings/LGT/work/maya/arnoldSettings_LGT_base_v006.ma"
filename = "/mnt/projects/wb/sequences/001_086/WB_001_086_290/LGT/work/maya/WB_001_086_290_LGT_DTB_v016.ma"
filename = "/mnt/projects/wb/assets/Light-Rig/arnoldSettings/LGT/publish/maya/arnoldSettings_LGT_base_v005.ma"
filename = "/mnt/projects/medinah/episodes/ep003/sequences/032/EP003_032_0110/LGT/publish/maya/EP003_032_0110_LGT_rndr_v011.mb"
#----
import os, sys
sys.path.append(r"/mnt/pipeline/ATK_PIPELINE/atk-api")
from atk_shotgun.ShotgunTankAccess import CustomQuery
reload(CustomQuery)
custom_query_obj = CustomQuery.Custom_Query()
# Example Values
"""
step_name = "Animation"
entity_type_name = "Shot"
asset_shot_code = "WB_001_086_290"
step_name = "Lighting"
entity_type_name = "Shot"
asset_shot_code = "EP003_032_0110"
step_name = "Lighting"
entity_type_name = "Shot"
asset_shot_code = "WB_001_086_290"
"""
import maya.cmds as cmds
import maya.mel as mel
import os
import sys
#set project here
def get_all_projects(active=False):
fields = ['name']
if active:
filters = [["sg_status", "is", "Active"]]
else:
filters = []
project_list = sg.find("Project", filters, fields)
return project_list
projects = get_all_projects()
print projects
print projects[5]
get_frame_rate_by_project_id(101)
def getOpenSceneFilePath():
scene = cmds.file(q=1,sn=1)
project = os.path.dirname(os.path.dirname(scene))
return scene
"""
# Get by ID
def get_frame_rate_by_project_id(project_id):
fields = ['sg_fps']
filters = [['id', 'is', project_id]]
result = sg.find_one("Project", filters, fields)
result = result["sg_fps"]
if result is None or result == 0:
return 24
else:
return result
"""
def get_frame_rate_by_project_name(sg_project_name):
fields = ['sg_fps']
filters = [['name', 'is', sg_project_name]]
result = sg.find_one("Project", filters, fields)
result = result["sg_fps"]
if result is None or result == 0:
return 24
else:
return result
#Get fps
projectName = "mwc"
projectFps = get_frame_rate_by_project_name(projectName)
print projectFps
sg_shots = sg.find("Shot", [['project.Project.name', 'is', projectName]],
['code', 'sg_sequence.Sequence.sg_status_list'])
def getFilePath():
# Get file path name of the latest published Maya scene file
maya_file_path_name = custom_query_obj.get_latest_maya_scene_publish(step_name, entity_type_name, asset_shot_code)['path']['local_path_linux']
print maya_file_path_name
return maya_file_path_name
def getFrameRange():
# Get the frame range of a specific shot as a tuple
frame_range_result = custom_query_obj.get_shot_frame_range_by_shot_code(asset_shot_code)
return frame_range_result[0],frame_range_result[1]
def getShotDetails(filePath):
code = ""
sequence_entity = ""
from atk_shotgun.ShotgunTankAccess import ShotgunTankAccess
reload(ShotgunTankAccess)
sta= ShotgunTankAccess.Shotgun_Tank_Access()
sg= sta.get_sg()
basename= os.path.basename(filename)
regex = r"(\S*?[0-9])_[a-zA-Z]"
matches = re.search(regex, basename)
if matches:
code= matches.groups()[0]
sequence_entity= sg.find("Shot", [["code", "is", code]],['code'])[-1]
shotCode = sequence_entity["code"]
print sequence_entity
return shotCode
# Start of code to gather shot data
#Enter the things:
step_name = "Lighting"
entity_type_name = "Shot"
asset_shot_code = "WB_001_086_290"
getOpenSceneFilePath()
filename = getFilePath()
print filename
startEnd = getFrameRange()
print startEnd
shotName = getShotDetails(currentFilePath)
print shotName