Esempio n. 1
0
 def __init__(self, element, parent):
     super(RollbackWindow, self).__init__()
     self.element = element
     self.parent = parent
     self.environment = Environment()
     self.project = Project()
     self.publishes = []
     self.result = None
     self.initUI()
     self.list_publishes()
Esempio n. 2
0
 def __init__(self, src, parent, dept_list=Department.ALL):
     super(PublishWindow, self).__init__()
     self.environment = Environment()
     self.project = Project()
     self.eList = ElementList(self)
     self.parent = parent
     self.src = src
     self.result = None
     self.elementType = None
     self.initUI(dept_list)
     self.published = False
Esempio n. 3
0
 def __init__(self, element, parent):
     super(RollbackWindow, self).__init__()
     if element is None:
         message_gui.error("Please checkout a shot to rollback.\n")
         return
     self.element = element
     self.parent = parent
     self.environment = Environment()
     self.project = Project()
     self.publishes = []
     self.result = None
     self.initUI()
     self.list_publishes()
 def __init__(self, element, parent):
     super(RollbackWindow, self).__init__()
     self.element = element
     self.parent = parent
     self.environment = Environment()
     self.project = Project()
     self.publishes = []
     self.result = None
     self.initUI()
     self.list_publishes()
Esempio n. 5
0
 def __init__(self, src, parent, dept_list=Department.ALL):
     super(PublishWindow, self).__init__()
     self.environment = Environment()
     self.project = Project()
     self.eList = ElementList(self)
     self.parent = parent
     self.src = src
     self.result = None
     self.elementType = None
     self.initUI(dept_list)
     self.published = False
Esempio n. 6
0
	def setUp(self):
		project_dir = os.path.dirname(os.path.realpath(__file__))
		self.assets_dir = os.path.join(project_dir, "assets")
		self.shots_dir = os.path.join(project_dir, "shots")
		self.users_dir = os.path.join(project_dir, "users")
		pipeline_io.mkdir(self.assets_dir)
		pipeline_io.mkdir(self.shots_dir)
		pipeline_io.mkdir(self.users_dir)
		datadict = Environment.create_new_dict("test", self.assets_dir, self.shots_dir, self.users_dir)
		pipeline_io.writefile(Environment.PIPELINE_FILENAME, datadict)
		os.environ[Environment.PROJECT_ENV] = project_dir

		self.project = Project()
Esempio n. 7
0
    def setUp(self):
        project_dir = os.path.dirname(os.path.realpath(__file__))
        self.assets_dir = os.path.join(project_dir, "assets")
        self.shots_dir = os.path.join(project_dir, "shots")
        self.users_dir = os.path.join(project_dir, "users")
        self.assmelby_dir = os.path.join(project_dir, "otls")
        pipeline_io.mkdir(self.assets_dir)
        pipeline_io.mkdir(self.shots_dir)
        pipeline_io.mkdir(self.users_dir)
        datadict = Environment.create_new_dict("test", self.assets_dir,
                                               self.shots_dir, self.users_dir,
                                               self.assmelby_dir)
        pipeline_io.writefile(Environment.PIPELINE_FILENAME, datadict)
        os.environ[Environment.PROJECT_ENV] = project_dir

        self.project = Project()
def go(body=None, type=AssetType.SET):
    if not body:
        parent = publish.maya_main_window()
        filePath = pm.sceneName()
        fileDir = os.path.dirname(filePath)
        project = Project()
        checkout = project.get_checkout(fileDir)
        if not checkout:
            filePath = Environment().get_user_workspace()
            filePath = os.path.join(filePath, 'untitled.mb')
            filePath = pipeline_io.version_file(filePath)

        global maya_publish_dialog
        selection_list = []
        if type == "shot":
            selection_list = Project().list_shots()
        elif type == AssetType.PROP:
            selection_list = []
            for asset in Project().list_assets():
                body = project.get_body(asset)
                if body.get_type() != AssetType.PROP:
                    continue
                selection_list.append(asset)
        elif type == AssetType.SET:
            selection_list = Project().list_sets()
        else:
            print("Didn't export JSON, because it probably is a character.")
            return

        maya_publish_dialog = SelectFromList(parent=maya_main_window())
        maya_publish_dialog.setWindowTitle("Select shot" if type ==
                                           "shot" else "Select prop" if type ==
                                           AssetType.PROP else "Select set")
        maya_publish_dialog.setList(selection_list)
        maya_publish_dialog.filePath = filePath
        maya_publish_dialog.selected.connect(publish_submitted)
        maya_publish_dialog.show()
    else:
        if type == "shot":
            confirmWriteShotReferences(body)
        elif type == AssetType.PROP:
            confirmWritePropReference(body)
        elif type == AssetType.SET:
            confirmWriteSetReferences(body)
Esempio n. 9
0
selection = mc.ls(selection=True)[0]
rigPrefix = re.search(r'\w*main_\w*:?Viking', selection, re.I).group()
rigPrefix = "viking_with_facial_rig_main"  #until I can figure out that regex lol

vikingBodyGeo = rigPrefix + '_body_GEO_01'
vikingRigName = rigPrefix + '_primary_global_cc_01'

cache_name = rigPrefix  # look in shots cfx/main/cache

#########################
## ESTABLISH CFX SCENE ##
#########################

project = Project()
environment = Environment()

# Create a global position locator for viking's starting location
mc.currentTime(STARTPRE)
globalPos = mc.spaceLocator(p=[0, 0, 0])
globPos = mc.rename(globalPos, "vikingGlobalPos")
mc.select(vikingRigName)
mc.select(globPos, add=True)
mc.pointConstraint(
    offset=[0, 0, 0],
    weight=1)  #constrains the globPos position to where viking's rig_main is
mc.orientConstraint(
    offset=[0, 0, 0], weight=1
)  #orients the globPos to match viking's rig_main (I think it just does the rotation)

# Get transformation variables from globPos locator
Esempio n. 10
0
class RollbackWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, element, parent):
        super(RollbackWindow, self).__init__()
        self.element = element
        self.parent = parent
        self.environment = Environment()
        self.project = Project()
        self.publishes = []
        self.result = None
        self.initUI()
        self.list_publishes()

    def initUI(self):
        #define gui elements
        self.setGeometry(300, 300, WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Rollback Manager')

        self.publish_list = QtGui.QListWidget()
        self.publish_list.currentItemChanged.connect(self.update_detail_view)
        self.infoLabel = QtGui.QLabel()

        self.rollbackButton = QtGui.QPushButton('Rollback')
        self.rollbackButton.clicked.connect(self.rollback)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.close)

        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.publish_list, 0, 0, 3, 1)
        self.grid.addWidget(self.infoLabel, 0, 1)
        self.grid.addWidget(self.rollbackButton, 3, 0)
        self.grid.addWidget(self.cancelButton, 3, 1)

        self.show()

    def list_publishes(self):
        publishes = self.element.list_publishes()
        for p in publishes:
            publish = Publish(p[0], p[1], p[2])
            self.publishes = self.publishes + [publish]
            item = QtGui.QListWidgetItem(publish.timestamp)
            self.publish_list.addItem(item)

    def update_detail_view(self):
        selectedVersion = self.publishes[self.publish_list.currentRow()]
        self.infoLabel.setText(
            "Author: {0} \nTimestamp: {1} \n\nComment: {2}".format(
                selectedVersion.author, selectedVersion.timestamp,
                selectedVersion.comment))

    def rollback(self):
        selectedVersion = self.publishes[self.publish_list.currentRow()]
        versionDir = self.element.get_version_dir(
            self.publish_list.currentRow())
        versionFile = listdir(versionDir)[0]
        filepath = versionDir + '/' + versionFile
        user = self.environment.get_current_username()
        comment = "Rollback to version dated \n{0}".format(
            selectedVersion.timestamp)
        self.element.publish(user, filepath, comment)
        #checkout element again to user to remove errors upon multiple uses of rollback
        self.result = self.element.checkout(user)
        self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Esempio n. 11
0
 def __init__(self, parent, dept_list=Department.ALL):
     super(CheckoutWindow, self).__init__()
     self.parent = parent
     self.project = Project()
     self.environment = Environment()
     self.initUI(dept_list)
Esempio n. 12
0
class AssembleWindow(QtWidgets.QWidget):

	finished = QtCore.Signal()

	def __init__(self, parent, dept_list=Department.ALL):
		super(AssembleWindow, self).__init__()
		self.parent = parent
		self.project = Project()
		self.environment = Environment()
		self.initUI(dept_list)

	def initUI(self, dept_list):
		#define gui elements
		self.resize(WINDOW_WIDTH,WINDOW_HEIGHT)
		self.setWindowTitle('Assemble')
		self.dept_tabs = QtWidgets.QTabWidget()
		self.dept_list = dept_list
		self.result = None

		#create Tabs
		self.createTabs()

		#create buttons
		self.assemble_button = QtWidgets.QPushButton('Assemble')
		self.assemble_button.clicked.connect(self.assemble)
		self.cancel_button = QtWidgets.QPushButton('Cancel')
		self.cancel_button.clicked.connect(self.close)

		#create button layout
		button_layout = QtWidgets.QHBoxLayout()
		button_layout.addWidget(self.assemble_button)
		button_layout.addWidget(self.cancel_button)

		self.img = QtWidgets.QLabel()
		banner_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui', 'assets', 'images', 'film-banner.jpg')
		pixmap = QtGui.QPixmap(banner_path)
		scaled = pixmap.scaledToWidth(self.size().width())
		self.img.setPixmap(scaled)

		#create main layout
		main_layout = QtWidgets.QVBoxLayout()
		self.setLayout(main_layout)
		main_layout.addWidget(self.img)
		main_layout.setSpacing(5)
		# main_layout.setMargin(6)
		main_layout.addWidget(self.dept_tabs)
		main_layout.addLayout(button_layout)

		self.show()

	def createTabs(self):
		#remember the current index so that we can restore it when we create the tabs
		currIndex = self.dept_tabs.currentIndex()
		#clear out the old tabs
		self.dept_tabs.clear()
		#create tabs
		for dept in self.dept_list:
			tab = DepartmentTab(self)
			self.dept_tabs.addTab(tab, dept)
			tab_layout = QtWidgets.QHBoxLayout()
			element_list = QtWidgets.QListWidget()

			if dept in Department.ASSET_DEPTS:
				for asset in self.project.list_assets():
					item = QtWidgets.QListWidgetItem(asset)
					element_list.addItem(item)
					element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.SHOT_DEPTS:
				for shot in self.project.list_shots():
					item = QtWidgets.QListWidgetItem(shot)
					element_list.addItem(item)
					element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.TOOL_DEPTS:
				for tool in self.project.list_tools():
					item = QtWidgets.QListWidgetItem(tool)
					element_list.addItem(item)
					element_list.currentItemChanged.connect(self.set_current_item)
			tab_layout.addWidget(element_list)
			tab.setLayout(tab_layout)

		#restore the previous index
		self.dept_tabs.setCurrentIndex(currIndex)

	def set_current_item(self, index):
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]
		if current_dept in Department.ASSET_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.SHOT_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.TOOL_DEPTS:
			self.current_item = str(index.text())

		asset_obj = self.project.get_body(self.current_item)
		element_obj = asset_obj.get_element(current_dept)
		last_publish = element_obj.get_last_publish()
		last_publish_comment = None
		if last_publish is not None:
			last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(last_publish[1], last_publish[0], last_publish[2])
		else:
			last_publish_comment = "No publishes for this element"
		currentTab = self.dept_tabs.currentWidget()

	def hasPreviousPublish(self, body, department):
		asset_obj = self.project.get_body(body)
		element_obj = asset_obj.get_element(department)
		last_publish = element_obj.get_last_publish()
		if last_publish is None:
			return False
		return True

	def assemble(self):
		"""
		Checks out the currently selected item
		:return:
		"""
		current_user = self.environment.get_current_username()
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]

		# Make sure that the asset hasn't been assemble yet
		startAssembling = False
		if self.hasPreviousPublish(self.current_item, current_dept):
			startAssembling = message_gui.light_error("This asset has already been assembled for " + current_dept + ".\n Are you sure you want to assemble it again?")
		else:
			startAssembling = True

		if startAssembling is True:
			asset_obj = self.project.get_body(self.current_item)
			element_obj = asset_obj.get_element(current_dept)
			element_path = element_obj.checkout(current_user)
			if element_path != None:
				self.result = self.current_item
				self.close()
		else:
			return

	def closeEvent(self, event):
		self.finished.emit()
		event.accept()
Esempio n. 13
0
class PublishWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, src, parent, dept_list=Department.ALL):
        super(PublishWindow, self).__init__()
        self.environment = Environment()
        self.project = Project()
        self.eList = ElementList(self)
        self.parent = parent
        self.src = src
        self.result = None
        self.elementType = None
        self.initUI(dept_list)
        self.published = False
        
    def initUI(self, dept_list):
        #load checkout information
        src_dir = os.path.dirname(self.src)
        checkout_element = self.project.get_checkout_element(src_dir)
        checkout_dept = None
        checkout_body_name = None
        if checkout_element is not None:
            checkout_dept = checkout_element.get_department()
            checkout_body_name = checkout_element.get_parent()

        #define gui elements
        self.setGeometry(300,300,WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Publish')
        self.menu = QtGui.QComboBox()
        self.menu.addItem('Asset')
        self.menu.addItem('Shot')
        self.departmentMenu = QtGui.QComboBox()
        checkout_idx = -1
        for i, dept in enumerate(dept_list):
            self.departmentMenu.addItem(dept)
            if dept==checkout_dept:
                checkout_idx = i
        
        self.departmentMenu.activated[str].connect(self.setElementType)
        self.filePath = QtGui.QLineEdit()
        self.filePath.setReadOnly(True)
        self.label = QtGui.QLabel('What did you change?')
        self.comment = QtGui.QTextEdit()
        self.publishBtn = QtGui.QPushButton('Publish')
        self.publishBtn.setEnabled(False)
        
        self.eList.currentItemChanged.connect(self.selectElement)
        self.publishBtn.clicked.connect(self.publish)

        if checkout_idx>-1:
            self.departmentMenu.setCurrentIndex(checkout_idx)
        self.setElementType()
        self.eList.setElement(checkout_body_name)
        
        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.label, 1, 1)
        self.grid.addWidget(self.eList, 2, 0)
        self.grid.addWidget(self.comment, 2, 1)
        self.grid.addWidget(self.filePath, 3, 0)
        self.grid.addWidget(self.publishBtn, 3, 1)
        
        self.show()
        
    def setElementType(self):
        department = str(self.departmentMenu.currentText())
        if department in Department.FRONTEND:
            self.elementType = 'Asset'
        else:
            self.elementType = 'Shot'
        self.eList.refreshList(self.elementType)
        
    def selectElement(self):
        currentItem = self.eList.currentItem()
        if currentItem is not None:
           self.filePath.setText(self.eList.currentItem().text())
           self.publishBtn.setEnabled(True)

    def publish(self):
        self.elementType = str(self.menu.currentText())
        # element = None
        # element = self.project.get_checkout_element(os.path.dirname(self.src))
        try:
            #Leave here to use for advanced options
            body = self.project.get_body(str(self.filePath.text()))
            element = body.get_element(str(self.departmentMenu.currentText()))
            # if self.elementType == 'Asset':
            #    asset = self.project.get_asset(str(self.filePath.text()))
            #    element = asset.get_element(str(self.departmentMenu.currentText()))
            # else:
            #    shot = self.project.get_shot(str(self.filePath.text()))
            #    element = shot.get_element(str(self.departmentMenu.currentText()))
        
            self.user = self.environment.get_current_username()
            self.comment = str(self.comment.toPlainText())
            self.result = element
            self.published = True
            self.close()
        except Exception, e:
            print e
            error = QtGui.QLineEdit()
            error.setText(str(e))
            self.grid.addWidget(error, 4, 1, 2, 1)
            traceback.print_stack()
Esempio n. 14
0
class PublishWindow(QtWidgets.QWidget):

    finished = QtCore.Signal()

    def __init__(self, src, parent, dept_list=Department.ALL):
        super(PublishWindow, self).__init__()
        self.environment = Environment()
        self.project = Project()
        self.eList = ElementList(self)
        self.parent = parent
        self.src = src
        self.result = None
        self.elementType = None
        self.initUI(dept_list)
        self.published = False

    def initUI(self, dept_list):
        #load checkout information
        src_dir = os.path.dirname(self.src)
        checkout_element = self.project.get_checkout_element(src_dir)
        checkout_dept = None
        checkout_body_name = None
        if checkout_element is not None:
            checkout_dept = checkout_element.get_department()
            checkout_body_name = checkout_element.get_parent()

        #define gui elements
        self.setGeometry(300, 300, WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Publish')
        self.menu = QtWidgets.QComboBox()
        self.menu.addItem('Asset')
        self.menu.addItem('Shot')
        self.departmentMenu = QtWidgets.QComboBox()
        checkout_idx = -1
        for i, dept in enumerate(dept_list):
            self.departmentMenu.addItem(dept)
            if dept == checkout_dept:
                checkout_idx = i

        self.departmentMenu.activated[str].connect(self.setElementType)
        self.filePath = QtWidgets.QLineEdit()
        self.filePath.setReadOnly(True)
        self.label = QtWidgets.QLabel('What did you change?')
        self.comment = QtWidgets.QTextEdit()
        self.lastPublish = QtWidgets.QTextEdit()
        self.lastPublish.setReadOnly(True)
        self.publishBtn = QtWidgets.QPushButton('Publish')
        self.publishBtn.setEnabled(False)

        self.eList.currentItemChanged.connect(self.selectElement)
        self.publishBtn.clicked.connect(self.publish)

        if checkout_idx > -1:
            self.departmentMenu.setCurrentIndex(checkout_idx)
        self.setElementType()
        self.eList.setElement(checkout_body_name)

        self.clearHistoryCheckbox = QtWidgets.QCheckBox(
            'Freeze all transformations and clear all construction history')

        #set gui layout
        self.grid = QtWidgets.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.clearHistoryCheckbox, 0, 1)

        self.grid.addWidget(self.lastPublish, 1, 1)
        self.grid.addWidget(self.label, 2, 1)
        self.grid.addWidget(self.comment, 3, 1)

        self.grid.addWidget(self.eList, 1, 0, 3, 1)
        self.grid.addWidget(self.filePath, 4, 0)
        self.grid.addWidget(self.publishBtn, 4, 1)

        self.show()

    def setElementType(self):
        self.department = str(self.departmentMenu.currentText())
        if self.department in Department.ASSET_DEPTS:
            self.elementType = 'Asset'
        elif self.department in Department.SHOT_DEPTS:
            self.elementType = 'Shot'
        elif self.department in Department.TOOL_DEPTS:
            self.elementType = 'Tool'
        elif self.department in Department.CROWD_DEPTS:
            self.elementType = 'CrowdCycle'
        else:
            message_gui.error('There was an error loading the ' +
                              str(self.department) + ' department')
        self.eList.refreshList(self.elementType)

    def selectElement(self):
        currentItem = self.eList.currentItem()
        print(currentItem)
        if currentItem is not None:
            self.filePath.setText(self.eList.currentItem().text(1))
            print("Current Item 0: " + self.eList.currentItem().text(0))
            print("Current Item 1: " + self.eList.currentItem().text(1))
            self.publishBtn.setEnabled(True)

            current_dept = str(self.departmentMenu.currentText())
            print("Current Department " + current_dept)

            asset_obj = self.project.get_body(str(currentItem.text(1)))
            element_obj = asset_obj.get_element(current_dept)
            last_publish = element_obj.get_last_publish()
            last_publish_comment = None
            if last_publish is not None:
                last_publish_comment = 'Last published {0} by {1} \n "{2}"'.format(
                    last_publish[1], last_publish[0], last_publish[2])
            else:
                last_publish_comment = 'No publishes for this element'
            self.lastPublish.setText(last_publish_comment)

    def publish(self):

        if str(self.comment.toPlainText()) == '':
            message_gui.error(
                'Please add a publish comment.\nComments help to track the progress.'
            )
            return

        self.elementType = str(self.menu.currentText())
        try:
            body = self.project.get_body(str(self.filePath.text()))
            element = body.get_element(str(self.departmentMenu.currentText()))

            self.user = self.environment.get_current_username()
            self.comment = str(self.comment.toPlainText())
            self.elementName = str(self.departmentMenu.currentText())
            self.result = element
            self.published = True
            self.close()
        except Exception, e:
            print e
            error = QtWidgets.QLineEdit()
            error.setText(str(e))
            self.grid.addWidget(error, 4, 1, 2, 1)
            traceback.print_stack()
def go():
    project = Project()
    environment = Environment()

    # Create a global position locator which will grab Jampa's position despite his scaled translations
    mc.currentTime(0)
    globalPos = mc.spaceLocator(p=[0,0,0])
    globPos = mc.rename(globalPos, "jampaGlobalPos")
    mc.select("jampa_rig_main_global_cc_01")
    mc.select(globPos, add=True)
    mc.pointConstraint(offset=[0,0,0], weight=1)
    mc.orientConstraint(offset=[0,0,0], weight=1)

    # Get transformation variables from globPos locator
    tx = mc.getAttr(globPos+".translateX")
    ty = mc.getAttr(globPos+".translateY")
    tz = mc.getAttr(globPos+".translateZ")
    rx = mc.getAttr(globPos+".rotateX")
    ry = mc.getAttr(globPos+".rotateY")
    rz = mc.getAttr(globPos+".rotateZ")

    # get alembic filepath for scene's animation (requires prior export)
    src = mc.file(q=True, sceneName=True)
    src_dir = os.path.dirname(src)
    checkout_element = project.get_checkout_element(src_dir)
    checkout_body_name = checkout_element.get_parent()
    body = project.get_body(checkout_body_name)
    element = body.get_element(Department.ANIM)
    cache_file = os.path.join(element.get_dir(), "cache", "jampa_rig_main.abc")

    # checkout cfx scene for corresponding shot number
    current_user = environment.get_current_username()
    element = body.get_element(Department.CFX)
    cfx_filepath = element.checkout(current_user)

    #open cfx file 
    if cfx_filepath is not None:
        if not mc.file(q=True, sceneName=True) == '':
            mc.file(save=True, force=True) #save file

        if not os.path.exists(cfx_filepath):
            mc.file(new=True, force=True)
            mc.file(rename=cfx_filepath)
            mc.file(save=True, force=True)
        else:
            mc.file(cfx_filepath, open=True, force=True)

    # import alembic
    command = "AbcImport -mode import \"" + cache_file + "\""
    maya.mel.eval(command)

    # delete all geo except jampa skin and rename
    geometry = mc.ls(geometry=True)
    transforms = mc.listRelatives(geometry, p=True, path=True)
    mc.select(transforms, r=True)
    for geo in mc.ls(sl=True):
        if(geo != "jampa_rig_main_jampa_geo_body"):
            mc.delete(geo)
    collide = "JAMPA_COLLIDE"
    mc.rename("jampa_rig_main_jampa_geo_body", collide)

    # reference robe
    body = project.get_body("jampa_robe")
    element = body.get_element(Department.MODEL)
    robe_file = element.get_app_filepath()
    mc.file(robe_file, reference=True)

    # set robe transforms to variables above
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateX", tx)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateY", ty)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateZ", tz)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateX", rx)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateY", ry)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateZ", rz)

    # make jampa skin a passive collider
    mc.select(collide)
    command = "makeCollideNCloth"
    maya.mel.eval(command)
    rigid_shape = "nRigid_jampa"
    mc.rename("nRigid1", rigid_shape)
    mc.setAttr(rigid_shape+".stickiness", 0.2)
    mc.setAttr(rigid_shape+".friction", 0.5)

    # make cloth objects and display layers of each robe piece
    jampa_torso = "jampa_robe_model_main_robe_torso_01"
    jampa_sash = "jampa_robe_model_main_robe_sash_01"
    jampa_skirt = "jampa_robe_model_main_robe_skirt_01"

    cloth_pieces = {jampa_torso, jampa_sash, jampa_skirt}
    command = "createNCloth 0"
    for cp in cloth_pieces:
        mc.select(cp)
        maya.mel.eval(command)
        mc.rename("nCloth1", "nCloth_"+cp)
        mc.select(cp)
        layername = "cloth_"+cp[:-3].replace("robe_model_main_robe_", "")
        mc.createDisplayLayer(name=layername.upper(), number=1, noRecurse=True)

    # set appropriate values in nucleus node
    nucleus = "nucleus_jampa"
    mc.rename("nucleus1", nucleus)
    mc.setAttr(nucleus+".subSteps", 30)
    mc.setAttr(nucleus+".startFrame", -30)
    mc.setAttr(nucleus+".spaceScale", 0.23)

    mc.currentTime(-50)
def generateScene():
    project = Project()
    environment = Environment()

    # Create a global position locator for Ten's Starting Location
    mc.currentTime(STARTANIM)
    globalPos = mc.spaceLocator(p=[0, 0, 0])
    globPos = mc.rename(globalPos, "tenGlobalPos")
    mc.select("ten_rig_main_m_global_CTL")
    mc.select(globPos, add=True)
    mc.pointConstraint(offset=[0, 0, 0], weight=1)
    mc.orientConstraint(offset=[0, 0, 0], weight=1)

    # Get transformation variables from globPos locator
    tx = mc.getAttr(globPos + ".translateX")
    ty = mc.getAttr(globPos + ".translateY")
    tz = mc.getAttr(globPos + ".translateZ")
    rx = mc.getAttr(globPos + ".rotateX")
    ry = mc.getAttr(globPos + ".rotateY")
    rz = mc.getAttr(globPos + ".rotateZ")

    # get alembic filepath for scene's animation (requires prior export)
    src = mc.file(q=True, sceneName=True)
    src_dir = os.path.dirname(src)
    checkout_element = project.get_checkout_element(src_dir)
    checkout_body_name = checkout_element.get_parent()
    body = project.get_body(checkout_body_name)
    element = body.get_element(Department.ANIM)
    cache_file = os.path.join(element.get_dir(), "cache", "ten_rig_main.abc")

    # checkout cfx scene for corresponding shot number
    current_user = environment.get_current_username()
    element = body.get_element(Department.CFX)
    cfx_filepath = element.checkout(current_user)

    #open cfx file
    if cfx_filepath is not None:
        if not mc.file(q=True, sceneName=True) == '':
            mc.file(save=True, force=True)  #save file

        if not os.path.exists(cfx_filepath):
            mc.file(new=True, force=True)
            mc.file(rename=cfx_filepath)
            mc.file(save=True, force=True)
        else:
            mc.file(cfx_filepath, open=True, force=True)

    # import alembic
    command = "AbcImport -mode import \"" + cache_file + "\""
    maya.mel.eval(command)

    # delete all geo except ten's skin and rename
    geometry = mc.ls(geometry=True)
    transforms = mc.listRelatives(geometry, p=True, path=True)
    mc.select(transforms, r=True)
    for geo in mc.ls(sl=True):
        if (geo != "ten_rig_main_Ten_Skin_RENDER"):
            mc.delete(geo)
    collide = "TEN_ANIM"
    mc.rename("ten_rig_main_Ten_Skin_RENDER", collide)

    # Reference Ten's Sim Robe
    body = project.get_body("ten_robe_sim")
    element = body.get_element(Department.MODEL)
    robe_file = element.get_app_filepath()
    mc.file(robe_file, reference=True)

    # Reference Ten's Hero Robe
    body = project.get_body("ten_robe")
    element = body.get_element(Department.MODEL)
    robe_hero_file = element.get_app_filepath()
    mc.file(robe_hero_file, reference=True)

    # Set Sim Robe transforms to variables above
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateX", tx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateY", ty)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateZ", tz)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateX", rx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateY", ry)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateZ", rz)

    # Set Hero Robe transforms to variables above
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateX", tx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateY", ty)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateZ", tz)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateX", rx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateY", ry)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateZ", rz)
####
#### Welcome to the shelf script!
####
#### If you'd like to add a shelf button, you can add it to
#### shelf.json. Follow the example of the other buttons in there.
#### Remember, the icon must be a 33X33 .xpm, and the python_file key
#### must be the name of the file where your python script is
#### stored. (Careful, it's not an absolute path!)
####
from pymel.core import *
import os
import sys
import json
from byuam.environment import Environment

env = Environment()

#### CONSTANTS, Edit these for customization.
PROJ = env.get_project_name()
SHELF_DIR = os.environ.get('MAYA_SHELF_DIR')
ICON_DIR = os.path.join(SHELF_DIR, "icons")
SCRIPT_DIR = os.path.join(SHELF_DIR, "scripts")
####

#### Shelf building code. You shouldn't have to edit anything
#### below these lines. If you want to add a new shelf item,
#### follow the instructions in shelf.json.
sys.path.append(SCRIPT_DIR)

def BYU_load_shelf():
    BYU_delete_shelf()
Esempio n. 18
0
class CheckoutWindow(QtWidgets.QWidget):

	finished = QtCore.Signal()

	def __init__(self, parent, dept_list=Department.ALL):
		super(CheckoutWindow, self).__init__()
		self.parent = parent
		self.project = Project()
		self.environment = Environment()
		self.initUI(dept_list)

	def initUI(self, dept_list):
		#define gui elements
		self.resize(WINDOW_WIDTH,WINDOW_HEIGHT)
		self.setWindowTitle('Checkout')
		self.dept_tabs = QtWidgets.QTabWidget()
		self.dept_list = dept_list
		self.result = None

		#create checkbox to show only published assets
		self.show_published = QtWidgets.QCheckBox("Display only assets or shots with previous publishes")
		self.show_published.setCheckState(QtCore.Qt.Unchecked)
		self.show_published.stateChanged.connect(self.changeBodyCheckoutVisibility)

		#create Tabs
		self.createTabs()

		#create buttons
		self.checkout_button = QtWidgets.QPushButton('Checkout')
		self.checkout_button.clicked.connect(self.checkout)
		self.cancel_button = QtWidgets.QPushButton('Cancel')
		self.cancel_button.clicked.connect(self.close)

		#create button layout
		button_layout = QtWidgets.QHBoxLayout()
		button_layout.addWidget(self.checkout_button)
		button_layout.addWidget(self.cancel_button)

		self.img = QtWidgets.QLabel()
		banner_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui', 'assets', 'images', 'film-banner.jpg')
		pixmap = QtGui.QPixmap(banner_path)
		scaled = pixmap.scaledToWidth(self.size().width())
		self.img.setPixmap(scaled)

		#create main layout
		main_layout = QtWidgets.QVBoxLayout()
		self.setLayout(main_layout)
		main_layout.addWidget(self.img)
		main_layout.setSpacing(5)
		# main_layout.setMargin(6)
		main_layout.addWidget(self.dept_tabs)
		main_layout.addWidget(self.show_published)
		main_layout.addLayout(button_layout)

		self.show()

	def createTabs(self):
		#remember the current index so that we can restore it when we create the tabs
		currIndex = self.dept_tabs.currentIndex()
		#clear out the old tabs
		self.dept_tabs.clear()
		#create tabs
		for dept in self.dept_list:
			tab = DepartmentTab(self)
			self.dept_tabs.addTab(tab, dept)
			tab_layout = QtWidgets.QHBoxLayout()
			element_list = QtWidgets.QListWidget()
			commentBox = QtWidgets.QTextEdit()
			commentBox.setReadOnly(True)
			tab.commentBox = commentBox

			if dept in Department.ASSET_DEPTS:
				for asset in self.project.list_assets():
					if not self.show_published.isChecked() or self.hasPreviousPublish(asset, dept):
						item = QtWidgets.QListWidgetItem(asset)
						element_list.addItem(item)
						element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.SHOT_DEPTS:
				for shot in self.project.list_shots():
					if not self.show_published.isChecked() or self.hasPreviousPublish(shot, dept):
						item = QtWidgets.QListWidgetItem(shot)
						element_list.addItem(item)
						element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.CROWD_DEPTS:
				for crowdCycle in self.project.list_crowd_cycles():
					if not self.show_published.isChecked() or self.hasPreviousPublish(crowdCycle, dept):
						item = QtWidgets.QListWidgetItem(crowdCycle)
						element_list.addItem(item)
						element_list.currentItemChanged.connect(self.set_current_item)
			tab_layout.addWidget(element_list)
			tab_layout.addWidget(commentBox)
			tab.setLayout(tab_layout)

		#restore the previous index
		self.dept_tabs.setCurrentIndex(currIndex)

	def hasPreviousPublish(self, body, department):
		asset_obj = self.project.get_body(body)
		element_obj = asset_obj.get_element(department)
		last_publish = element_obj.get_last_publish()
		if last_publish is None:
			return False
		return True

	def changeBodyCheckoutVisibility(self):
		#recreate tabs the with the new check option
		self.createTabs()

	def set_current_item(self, index):
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]
		if current_dept in Department.ASSET_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.SHOT_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.CROWD_DEPTS:
			self.current_item = str(index.text())
			#TODO what the heck? Why do we have three identical results from three different conditions? What are we trying to accomplish here? Admitadly the last one I added just following the crowd.

		asset_obj = self.project.get_body(self.current_item)
		element_obj = asset_obj.get_element(current_dept)
		last_publish = element_obj.get_last_publish()
		last_publish_comment = None
		if last_publish is not None:
			last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(last_publish[1], last_publish[0], last_publish[2])
		else:
			last_publish_comment = "No publishes for this element"
		currentTab = self.dept_tabs.currentWidget()
		currentTab.commentBox.setText(last_publish_comment)

	def checkout(self):
		"""
		Checks out the currently selected item
		:return:
		"""
		current_user = self.environment.get_current_username()
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]
		asset_obj = self.project.get_body(self.current_item)
		element_obj = asset_obj.get_element(current_dept)
		element_path = element_obj.checkout(current_user)
		if element_path != None:
			self.result = element_path
			self.close()


	def closeEvent(self, event):
		self.finished.emit()
		event.accept()
Esempio n. 19
0
class PublishWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, src, parent, dept_list=Department.ALL):
        super(PublishWindow, self).__init__()
        self.environment = Environment()
        self.project = Project()
        self.eList = ElementList(self)
        self.parent = parent
        self.src = src
        self.result = None
        self.elementType = None
        self.initUI(dept_list)
        self.published = False
        
    def initUI(self, dept_list):
        #load checkout information
        src_dir = os.path.dirname(self.src)
        checkout_element = self.project.get_checkout_element(src_dir)
        checkout_dept = None
        checkout_body_name = None
        if checkout_element is not None:
            checkout_dept = checkout_element.get_department()
            checkout_body_name = checkout_element.get_parent()

        #define gui elements
        self.setGeometry(300,300,WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Publish')
        self.menu = QtGui.QComboBox()
        self.menu.addItem('Asset')
        self.menu.addItem('Shot')
        self.departmentMenu = QtGui.QComboBox()
        checkout_idx = -1
        for i, dept in enumerate(dept_list):
            self.departmentMenu.addItem(dept)
            if dept==checkout_dept:
                checkout_idx = i
        
        self.departmentMenu.activated[str].connect(self.setElementType)
        self.filePath = QtGui.QLineEdit()
        self.filePath.setReadOnly(True)
        self.label = QtGui.QLabel('What did you change?')
        self.comment = QtGui.QTextEdit()
        self.publishBtn = QtGui.QPushButton('Publish')
        self.publishBtn.setEnabled(False)
        
        self.eList.currentItemChanged.connect(self.selectElement)
        self.publishBtn.clicked.connect(self.publish)

        if checkout_idx>-1:
            self.departmentMenu.setCurrentIndex(checkout_idx)
        self.setElementType()
        self.eList.setElement(checkout_body_name)
        
        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.label, 1, 1)
        self.grid.addWidget(self.eList, 2, 0)
        self.grid.addWidget(self.comment, 2, 1)
        self.grid.addWidget(self.filePath, 3, 0)
        self.grid.addWidget(self.publishBtn, 3, 1)
        
        self.show()
        
    def setElementType(self):
        department = str(self.departmentMenu.currentText())
        if department in Department.FRONTEND:
            self.elementType = 'Asset'
        else:
            self.elementType = 'Shot'
        self.eList.refreshList(self.elementType)
        
    def selectElement(self):
        currentItem = self.eList.currentItem()
        if currentItem is not None:
           self.filePath.setText(self.eList.currentItem().text())
           self.publishBtn.setEnabled(True)

    def publish(self):
        self.elementType = str(self.menu.currentText())
        try:
            body = self.project.get_body(str(self.filePath.text()))
            element = body.get_element(str(self.departmentMenu.currentText()))
        
            self.user = self.environment.get_current_username()
            self.comment = str(self.comment.toPlainText())
            self.result = element
            self.published = True
            self.close()
        except Exception, e:
            print e
            error = QtGui.QLineEdit()
            error.setText(str(e))
            self.grid.addWidget(error, 4, 1, 2, 1)
            traceback.print_stack()
Esempio n. 20
0
    def test_element(self):

        count = 0
        for body in self.bodies:
            for dept in Department.ALL:
                try:
                    element = body.get_element(dept)
                except EnvironmentError:
                    continue
                count += 1
                self.assertEquals(element.get_parent(), body.get_name())
                self.assertEquals(element.get_department(), dept)
                self.assertEquals(element.get_status(), Status.WAIT)
                element.update_status(Status.DONE)
                element.update_assigned_user(self.user)
                self.assertEquals(element.get_status(), Status.DONE)
                self.assertEquals(element.get_assigned_user(), self.user)
                element = body.get_element(
                    dept
                )  # re-read data from file to ensure nothing gets lost in i/o
                self.assertEquals(element.get_status(), Status.DONE)
                self.assertEquals(element.get_assigned_user(), self.user)

                # publish empty file
                empty_file = os.path.join(Environment().get_user_workspace(),
                                          "empty.txt")
                open(empty_file, 'a').close()
                element.publish(self.user, empty_file, "first publish")

                # test checkout
                checkout_path = element.checkout(self.user)
                self.assertTrue(os.path.exists(checkout_path))

                checkout_path2 = element.checkout(self.user)
                self.assertTrue(os.path.exists(checkout_path2))

                self.assertTrue(self.user in element.list_checkout_users())
                self.assertNotEqual(checkout_path, checkout_path2)

                checkout_dir = element.get_checkout_dir(self.user)
                checkout = self.project.get_checkout(checkout_dir)
                self.assertEquals(element.get_parent(),
                                  checkout.get_body_name())
                self.assertEquals(element.get_department(),
                                  checkout.get_department_name())
                self.assertEquals(element.get_name(),
                                  checkout.get_element_name())
                self.assertEquals(self.user, checkout.get_user_name())
                self.assertEquals(len(checkout.list_files()), 2)
                self.assertTrue(checkout_path in checkout.list_files())
                self.assertTrue(checkout_path2 in checkout.list_files())
                self.assertEquals(len(checkout.list_times()), 2)

                # test publish
                comment = "automated testing"
                element.publish(self.user, checkout_path, comment)
                self.assertEquals(len(element.list_publishes()), 2)
                publish = element.get_last_publish()
                self.assertEquals(self.user, publish[0])
                self.assertEquals(comment, publish[2])
                self.assertTrue(os.path.exists(element.get_version_dir(0)))

                element.update_cache(checkout_path)
                self.assertTrue(os.path.exists(element.get_cache_dir()))
                self.assertEquals(element.list_cache_files()[0],
                                  os.path.basename(checkout_path))

        self.assertEquals(count, self.element_count)
Esempio n. 21
0
####
#### Welcome to the shelf script!
####
#### If you'd like to add a shelf button, you can add it to
#### shelf.json. Follow the example of the other buttons in there.
#### Remember, the icon must be a 33X33 .xpm, and the python_file key
#### must be the name of the file where your python script is
#### stored. (Careful, it's not an absolute path!)
####
from pymel.core import *
import os
import sys
import json
from byuam.environment import Environment

env = Environment()

#### CONSTANTS, Edit these for customization.
PROJ = env.get_project_name()
SHELF_DIR = os.environ.get('MAYA_SHELF_DIR')
ICON_DIR = os.path.join(SHELF_DIR, "icons")
SCRIPT_DIR = os.path.join(SHELF_DIR, "scripts")
####

#### Shelf building code. You shouldn't have to edit anything
#### below these lines. If you want to add a new shelf item,
#### follow the instructions in shelf.json.
sys.path.append(SCRIPT_DIR)


def BYU_load_shelf():
class RollbackWindow(QtGui.QWidget):
    
    finished = QtCore.pyqtSignal()
    
    def __init__(self, element, parent):
        super(RollbackWindow, self).__init__()
        self.element = element
        self.parent = parent
        self.environment = Environment()
        self.project = Project()
        self.publishes = []
        self.result = None
        self.initUI()
        self.list_publishes()
        
    def initUI(self):
        #define gui elements
        self.setGeometry(300,300,WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Rollback Manager')
        
        self.publish_list = QtGui.QListWidget()
        self.publish_list.currentItemChanged.connect(self.update_detail_view)
        self.infoLabel = QtGui.QLabel()
        
        self.rollbackButton = QtGui.QPushButton('Rollback')
        self.rollbackButton.clicked.connect(self.rollback)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.close)
        
        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.publish_list, 0, 0, 3, 1)
        self.grid.addWidget(self.infoLabel, 0, 1)
        self.grid.addWidget(self.rollbackButton, 3, 0)
        self.grid.addWidget(self.cancelButton, 3, 1)
        
        self.show()
        
    def list_publishes(self):
        publishes = self.element.list_publishes();
        for p in publishes:
            publish = Publish(p[0], p[1], p[2])
            self.publishes = self.publishes + [publish]
            item = QtGui.QListWidgetItem(publish.timestamp)
            self.publish_list.addItem(item)
            
    def update_detail_view(self):
        selectedVersion = self.publishes[self.publish_list.currentRow()]
        self.infoLabel.setText("Author: {0} \nTimestamp: {1} \n\nComment: {2}".format(selectedVersion.author, selectedVersion.timestamp, selectedVersion.comment))
        
    def rollback(self):
        selectedVersion = self.publishes[self.publish_list.currentRow()]
        versionDir = self.element.get_version_dir(self.publish_list.currentRow())
        versionFile = listdir(versionDir)[0]
        filepath = versionDir + '/' + versionFile
        user = self.environment.get_current_username()
        comment = "Rollback to version dated \n{0}".format(selectedVersion.timestamp)
        self.element.publish(user, filepath, comment)
        #checkout element again to user to remove errors upon multiple uses of rollback
        self.result = self.element.checkout(user)
        self.close()
        
    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Esempio n. 23
0
class CheckoutWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)

    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtGui.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        #create tabs
        for dept in dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtGui.QHBoxLayout()
            element_list = QtGui.QListWidget()
            commentBox = QtGui.QTextEdit()
            commentBox.setReadOnly(True)
            tab.commentBox = commentBox

            if dept in Department.FRONTEND:
                for asset in self.project.list_assets():
                    item = QtGui.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            elif dept in Department.BACKEND:
                for shot in self.project.list_shots():
                    item = QtGui.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            tab_layout.addWidget(element_list)
            tab_layout.addWidget(commentBox)
            tab.setLayout(tab_layout)

        #create buttons
        self.checkout_button = QtGui.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtGui.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtGui.QHBoxLayout()
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtGui.QLabel()
        pixmap = QtGui.QPixmap(os.environ['BYU_TOOLS_DIR'] +
                               '/byugui/assets/images/taijitu.jpg')
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtGui.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)

        self.show()

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.FRONTEND:
            self.current_item = str(index.text())
        elif current_dept in Department.BACKEND:
            self.current_item = str(index.text())

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = "No publishes for this element"
        currentTab = self.dept_tabs.currentWidget()
        currentTab.commentBox.setText(last_publish_comment)

    def checkout(self):
        """
        Checks out the currently selected item
        :return:
        """
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            self.result = element_path
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
class CheckoutWindow(QtWidgets.QWidget):

    finished = QtCore.Signal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)

    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtWidgets.QTabWidget()
        self.dept_list = dept_list
        self.result = None

        #create checkbox to show only published assets
        self.show_published = QtWidgets.QCheckBox(
            "Display only assets or shots with previous publishes")
        self.show_published.setCheckState(QtCore.Qt.Unchecked)
        self.show_published.stateChanged.connect(
            self.changeBodyCheckoutVisibility)

        #create Tabs
        self.createTabs()

        #create buttons
        self.checkout_button = QtWidgets.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtWidgets.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtWidgets.QLabel()
        banner_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui',
                                   'assets', 'images', 'film-banner.jpg')
        pixmap = QtGui.QPixmap(banner_path)
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        # main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addWidget(self.show_published)
        main_layout.addLayout(button_layout)

        self.show()

    #Recursivly goes through the asset's file name
    def recurseTree(self, treeItem, array, asset):
        #This is for setting bottom level text attributes
        if len(array) == 0:
            treeItem.setText(1, asset)
            treeItem.setTextColor(0, "#3c83f9")
            font = QtGui.QFont()
            font.setPointSize(12)
            font.setBold(False)
            treeItem.setFont(0, font)
            return
        else:  #This is for setting parent level text attributes and settin up the structure
            item = QtWidgets.QTreeWidgetItem(array[0])
            item.setText(0, array[0])
            item.setText(1, "This is not a file")
            item.setTextColor(0, "#d0d0d0")
            font = QtGui.QFont()
            font.setPointSize(11)
            font.setBold(True)
            item.setFont(0, font)
            skip = False
            # this is to check if the child already exists
            for i in range(0, treeItem.childCount()):
                if treeItem.child(i).text(0) == item.text(0):
                    item = treeItem.child(i)
                    skip = True
            if skip == False:  # Executes if the child doesnt already exist
                treeItem.addChild(item)
            newArray = array[1:]
            self.recurseTree(item, newArray, asset)
        return

    def createTabs(self):
        #remember the current index so that we can restore it when we create the tabs
        currIndex = self.dept_tabs.currentIndex()
        #clear out the old tabs
        self.dept_tabs.clear()
        #create tabs
        for dept in self.dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtWidgets.QHBoxLayout()
            element_list = QtWidgets.QTreeWidget()
            element_list.setColumnCount(1)
            commentBox = QtWidgets.QTextEdit()
            commentBox.setReadOnly(False)
            tab.commentBox = commentBox

            if dept in Department.ASSET_DEPTS:
                for asset in self.project.list_assets():
                    #print(asset)
                    if not self.show_published.isChecked(
                    ) or self.hasPreviousPublish(asset, dept):
                        asset_array = asset.split("_")
                        firstelement = element_list.findItems(
                            asset_array[0], 0, 0)
                        if not firstelement:
                            item = QtWidgets.QTreeWidgetItem(asset_array[0])
                            item.setText(0, asset_array[0])
                            item.setTextColor(0, "#d0d0d0")
                            font = QtGui.QFont()
                            font.setPointSize(11)
                            font.setBold(True)
                            item.setFont(0, font)
                            self.recurseTree(item, asset_array[1:], asset)
                            element_list.insertTopLevelItem(0, item)
                        else:
                            self.recurseTree(firstelement[0], asset_array[1:],
                                             asset)
                        element_list.currentItemChanged.connect(
                            self.set_current_item)
            elif dept in Department.SHOT_DEPTS:
                for shot in self.project.list_shots():
                    #print(shot)
                    if not self.show_published.isChecked(
                    ) or self.hasPreviousPublish(shot, dept):
                        shot_array = shot.split("_")
                        firstelement = element_list.findItems(
                            shot_array[0], 0, 0)
                        if not firstelement:
                            item = QtWidgets.QTreeWidgetItem(shot_array[0])
                            item.setText(0, shot_array[0])
                            item.setTextColor(0, "#d0d0d0")
                            font = QtGui.QFont()
                            font.setPointSize(11)
                            font.setBold(True)
                            item.setFont(0, font)
                            self.recurseTree(item, shot_array[1:], shot)
                            element_list.insertTopLevelItem(0, item)
                        else:
                            self.recurseTree(firstelement[0], shot_array[1:],
                                             shot)
                        element_list.currentItemChanged.connect(
                            self.set_current_item)
            elif dept in Department.CROWD_DEPTS:
                for crowdCycle in self.project.list_crowd_cycles():
                    if not self.show_published.isChecked(
                    ) or self.hasPreviousPublish(crowdCycle, dept):
                        crowdCycle_array = crowdCycle.split("_")
                        firstelement = element_list.findItems(
                            crowdCycle_array[0], 0, 0)
                        if not firstelement:
                            item = QtWidgets.QTreeWidgetItem(
                                crowdCycle_array[0])
                            item.setText(0, crowdCycle_array[0])
                            item.setTextColor(0, "#d0d0d0")
                            font = QtGui.QFont()
                            font.setPointSize(11)
                            font.setBold(True)
                            item.setFont(0, font)
                            self.recurseTree(item, crowdCycle_array[1:],
                                             crowdCycle)
                            element_list.insertTopLevelItem(0, item)
                        else:
                            self.recurseTree(firstelement[0],
                                             crowdCycle_array[1:], crowdCycle)
                        element_list.currentItemChanged.connect(
                            self.set_current_item)
            tab_layout.addWidget(element_list)
            tab_layout.addWidget(commentBox)
            tab.setLayout(tab_layout)

        #restore the previous index
        self.dept_tabs.setCurrentIndex(currIndex)

    def hasPreviousPublish(self, body, department):
        asset_obj = self.project.get_body(body)
        element_obj = asset_obj.get_element(department)
        last_publish = element_obj.get_last_publish()
        if last_publish is None:
            return False
        return True

    def changeBodyCheckoutVisibility(self):
        #recreate tabs the with the new check option
        self.createTabs()

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.ASSET_DEPTS:
            self.current_item = str(index.text(1))
        elif current_dept in Department.SHOT_DEPTS:
            self.current_item = str(index.text(1))
        elif current_dept in Department.CROWD_DEPTS:
            self.current_item = str(index.text(1))
            #TODO what the heck? Why do we have three identical results from three different conditions? What are we trying to accomplish here? Admitadly the last one I added just following the crowd.

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = "No publishes for this element"
        currentTab = self.dept_tabs.currentWidget()
        currentTab.commentBox.setText(last_publish_comment)

    def checkout(self):
        """
		Checks out the currently selected item
		:return:
		"""
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept, force_create=True)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            self.result = element_path
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Esempio n. 25
0
class SelectionWindow(QtWidgets.QDialog):

    finished = QtCore.Signal()

    def __init__(self, parent, dept_list=Department.ALL, showWindow=True):
        super(SelectionWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list, showWindow)

    def initUI(self, dept_list, showWindow):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Select Asset')
        self.dept_tabs = QtWidgets.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        self.instructions = QtWidgets.QLabel(
            'Select the asset you would like affect:')

        #create Tabs
        self.createTabs()

        #create buttons
        self.select_button = QtWidgets.QPushButton('Select')
        self.select_button.clicked.connect(self.select)
        self.cancel_button = QtWidgets.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addWidget(self.select_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtWidgets.QLabel()
        image_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui',
                                  'assets', 'images', 'film-banner.jpg')
        pixmap = QtGui.QPixmap(image_path)
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        # main_layout.setMargin(6)
        main_layout.addWidget(self.instructions)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)

        if showWindow:
            self.show()

    def createTabs(self):
        #remember the current index so that we can restore it when we create the tabs
        currIndex = self.dept_tabs.currentIndex()
        #clear out the old tabs
        self.dept_tabs.clear()
        #create tabs
        for dept in self.dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtWidgets.QHBoxLayout()
            element_list = QtWidgets.QListWidget()

            if dept in Department.ASSET_DEPTS:
                for asset in self.project.list_assets():
                    item = QtWidgets.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            elif dept in Department.SHOT_DEPTS:
                for shot in self.project.list_shots():
                    item = QtWidgets.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            tab_layout.addWidget(element_list)
            tab.setLayout(tab_layout)

        #restore the previous index
        self.dept_tabs.setCurrentIndex(currIndex)

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.ASSET_DEPTS:
            self.current_item = str(index.text())
        elif current_dept in Department.SHOT_DEPTS:
            self.current_item = str(index.text())

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = 'Last published {0} by {1} \n \"{2}\"'.format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = 'No publishes for this element'
        currentTab = self.dept_tabs.currentWidget()

    def hasPreviousPublish(self, body, department):
        asset_obj = self.project.get_body(body)
        element_obj = asset_obj.get_element(department)
        last_publish = element_obj.get_last_publish()
        if last_publish is None:
            return False
        return True

    def select(self):
        '''
		Selects the currently selected item
		:return:
		'''
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        if element_obj != None:
            self.result = element_obj
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
def generateScene():
    project = Project()
    environment = Environment()

    # Create a global position locator for Ten's Starting Location
    mc.currentTime(STARTANIM)
    globalPos = mc.spaceLocator(p=[0,0,0])
    globPos = mc.rename(globalPos, "tenGlobalPos")
    mc.select("ten_rig_main_m_global_CTL")
    mc.select(globPos, add=True)
    mc.pointConstraint(offset=[0,0,0], weight=1)
    mc.orientConstraint(offset=[0,0,0], weight=1)

    # Get transformation variables from globPos locator
    tx = mc.getAttr(globPos+".translateX")
    ty = mc.getAttr(globPos+".translateY")
    tz = mc.getAttr(globPos+".translateZ")
    rx = mc.getAttr(globPos+".rotateX")
    ry = mc.getAttr(globPos+".rotateY")
    rz = mc.getAttr(globPos+".rotateZ")

    # get alembic filepath for scene's animation (requires prior export)
    src = mc.file(q=True, sceneName=True)
    src_dir = os.path.dirname(src)
    checkout_element = project.get_checkout_element(src_dir)
    checkout_body_name = checkout_element.get_parent()
    body = project.get_body(checkout_body_name)
    element = body.get_element(Department.ANIM)
    cache_file = os.path.join(element.get_dir(), "cache", "ten_rig_main.abc")

    # checkout cfx scene for corresponding shot number
    current_user = environment.get_current_username()
    element = body.get_element(Department.CFX)
    cfx_filepath = element.checkout(current_user)

    #open cfx file 
    if cfx_filepath is not None:
        if not mc.file(q=True, sceneName=True) == '':
            mc.file(save=True, force=True) #save file

        if not os.path.exists(cfx_filepath):
            mc.file(new=True, force=True)
            mc.file(rename=cfx_filepath)
            mc.file(save=True, force=True)
        else:
            mc.file(cfx_filepath, open=True, force=True)

    # import alembic
    command = "AbcImport -mode import \"" + cache_file + "\""
    maya.mel.eval(command)

    # delete all geo except ten's skin and rename
    geometry = mc.ls(geometry=True)
    transforms = mc.listRelatives(geometry, p=True, path=True)
    mc.select(transforms, r=True)
    for geo in mc.ls(sl=True):
        if(geo != "ten_rig_main_Ten_Skin_RENDER"):
            mc.delete(geo)
    collide = "TEN_ANIM"
    mc.rename("ten_rig_main_Ten_Skin_RENDER", collide)

    # Reference Ten's Sim Robe
    body = project.get_body("ten_robe_sim")
    element = body.get_element(Department.MODEL)
    robe_file = element.get_app_filepath()
    mc.file(robe_file, reference=True)
    
    # Reference Ten's Hero Robe
    body = project.get_body("ten_robe")
    element = body.get_element(Department.MODEL)
    robe_hero_file = element.get_app_filepath()
    mc.file(robe_hero_file, reference=True)
    
    # Set Sim Robe transforms to variables above
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateX", tx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateY", ty)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateZ", tz)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateX", rx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateY", ry)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateZ", rz)
    
    # Set Hero Robe transforms to variables above
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateX", tx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateY", ty)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateZ", tz)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateX", rx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateY", ry)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateZ", rz)
Esempio n. 27
0
 def __init__(self, parent, dept_list=Department.ALL, showWindow=True):
     super(SelectionWindow, self).__init__()
     self.parent = parent
     self.project = Project()
     self.environment = Environment()
     self.initUI(dept_list, showWindow)
Esempio n. 28
0
class CheckoutWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)
        
    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtGui.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        #create tabs
        for dept in dept_list:
            tab = DepartmentTab(self)
            #tab = QtGui.QWidget()
            # self.dept_tabs.insertTab(self.ASSET_INDEX, tab, dept)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtGui.QVBoxLayout()
            element_list = QtGui.QListWidget()
				
            if dept in Department.FRONTEND:
                for asset in self.project.list_assets():
                    item = QtGui.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(self.set_current_item)
            elif dept in Department.BACKEND:
                for shot in self.project.list_shots():
                    item = QtGui.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(self.set_current_item)
            tab_layout.addWidget(element_list)
            tab.setLayout(tab_layout)
            
        #create buttons
        self.checkout_button = QtGui.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtGui.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)    
		
        #create button layout
        button_layout = QtGui.QHBoxLayout()
        #button_layout.setSpacing(2)
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtGui.QLabel()
        pixmap = QtGui.QPixmap(os.environ['BYU_TOOLS_DIR'] + '/byugui/assets/images/taijitu.jpg')
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtGui.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)
            
        self.show()
            
    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.FRONTEND:
            self.current_item = str(index.text())
        elif current_dept in Department.BACKEND:
            self.current_item = str(index.text())
            
    def checkout(self):
        """
        Checks out the currently selected item
        :return:
        """
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            # self.parent.close()
            self.result = element_path
            self.close()
            

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Esempio n. 29
0
 def __init__(self, parent, dept_list=Department.ALL):
     super(CheckoutWindow, self).__init__()
     self.parent = parent
     self.project = Project()
     self.environment = Environment()
     self.initUI(dept_list)
Esempio n. 30
0
                        maintainOffset=1,
                        weight=1.0)

    #Hide original chain/clasp because we don't need them for this part
    mc.hide('beowulf_cape_model_main_beowulf_cape_clasps')
    mc.hide('beowulf_cape_model_main_beowulf_cape_clasp_chain')

    #Export an alembic of just the chaingroup in the ANIM folder for this shot with the name:  beowulf_cape_chain_main.abc - you probably have to do this manually


###########################################
#### MAIN ####
###########################################
# Reference Beowulf's Cape - it comes with both sim and beauty meshes
project = Project()
environment = Environment()
body = project.get_body("beowulf_cape")
element = body.get_element(Department.MODEL)
cape_sim_file = element.get_app_filepath()
mc.file(cape_sim_file, reference=True)
global rigPrefix
rigPrefix = "beowulf_rig_main_"  #concatenate this with every other control name

#Keyframe Initial Frame
mc.currentTime(STARTANIM)
fullRig = selectRig()
setRigKey(fullRig)

#KEY ARM FK.IK here so it will be at frame 0 in the mode the animators intended
mc.setKeyframe(rigPrefix + 'Beowulf_LFT_arm_settings_cc_01.FK_IK')
mc.setKeyframe(rigPrefix + 'Beowulf_RGT_arm_settings_cc_01.FK_IK')