def rego():
    '''
    reassembles the currently selected node. That means leaving all of the shop nets in place but throwing out the geo and bringing it in fresh.
    '''

    selection = hou.selectedNodes()

    if len(selection) > 1:
        message_gui.error('Please only select one item')
        return
    if len(selection) <1:
        message_gui.error('Please select an item to be reassembled')
        return

    hda = selection[0]

    name = hda.type().name()
    index = name.rfind('_')
    main = name[index:]
    asset_name = name[:index]

    if main.find('_main') == -1:
        message_gui.error('There was something wrong with the name. Try tabbing in the asset again and trying one more time.')
        return

    project = Project()
    environment = Environment()
    username = project.get_current_username()
    asset = project.get_asset(asset_name)
    assembly = asset.get_element(Department.ASSEMBLY)
    # Checkout assembly
    checkout_file = checkout.checkout_hda(hda, project, environment)
    reassemble(hda, project, environment, assembly, asset, checkout_file)
예제 #2
0
def assemble_hda():
    asset_name = checkout_window.current_item

    project = Project()
    username = project.get_current_username()
    asset = project.get_asset(asset_name)

    assembly = asset.get_element(Department.ASSEMBLY)
    checkout_file = assembly.checkout(username)

    element = asset.get_element(Department.MODEL)
    cache = element.get_cache_dir()
    cache = cache.replace(project.get_project_dir(), '$JOB')
    # TODO: only load files whose extension matches element.get_cache_ext()
    geo_files = [
        x for x in os.listdir(element.get_cache_dir()) if not os.path.isdir(x)
    ]

    obj = hou.node('/obj')
    subnet = obj.createNode('subnet')
    for geo_file in geo_files:
        geo = subnet.createNode('geo')
        for child in geo.children():
            child.destroy()
        abc = geo.createNode('alembic')
        geo_file_path = os.path.join(cache, geo_file)
        abc.parm('fileName').set(geo_file_path)
        name = ''.join(geo_file.split('.')[:-1])
        geo.setName(name, unique_name=True)

    subnet.setName(asset_name, unique_name=True)
def assemble_hda():
    asset_name = checkout_window.current_item

    project = Project()
    username = project.get_current_username()
    asset = project.get_asset(asset_name)
    
    assembly = asset.get_element(Department.ASSEMBLY)
    checkout_file = assembly.checkout(username)

    element = asset.get_element(Department.MODEL)
    cache = element.get_cache_dir()
    cache = cache.replace(project.get_project_dir(), '$JOB')
    # TODO: only load files whose extension matches element.get_cache_ext()
    geo_files = [x for x in os.listdir(element.get_cache_dir()) if not os.path.isdir(x)]

    obj = hou.node('/obj')
    subnet = obj.createNode('subnet')
    for geo_file in geo_files:
        geo = subnet.createNode('geo')
        for child in geo.children():
            child.destroy()
        abc = geo.createNode('alembic')
        geo_file_path = os.path.join(cache, geo_file)
        abc.parm('fileName').set(geo_file_path)
        name = ''.join(geo_file.split('.')[:-1])
        geo.setName(name, unique_name=True)

    subnet.setName(asset_name, unique_name=True)
def post_assemble():
    mari.projects.close()
    asset_name = mari_assemble_dialog.result
    print asset_name

    if asset_name is None:
        return

    # Set up the project and environment
    project = Project()
    environment = Environment()
    # get the username and asset
    username = project.get_current_username()
    asset = project.get_asset(asset_name)

    # get the texture element and check it out
    texture = asset.get_element(Department.TEXTURE)
    checkout_file = texture.checkout(username)

    # Get the path to the directory with all of the alembics
    model = asset.get_element(Department.MODEL)
    cache = model.get_cache_dir()

    geo_files = [
        x for x in os.listdir(model.get_cache_dir()) if not os.path.isdir(x)
    ]
    # Remove anything that is not an alemibic file
    for file_path in list(geo_files):
        if (not str(file_path).lower().endswith('.abc')):
            geo_files.remove(file_path)

    if len(geo_files) > 1:
        result = message_gui.light_error(
            'There are multiple alembic files in ' + str(file_path) +
            ' and there should only be one.\nWould you like to continue anyways?\nIt might not work.'
        )
        if not result:
            return
    elif len(geo_files) > 1:
        message_gui.error(
            'There is not an alembic cache for this asset. Make sure that the model has been published in Maya and that the static alembic has been exported.'
        )
        return

    geo_file_path = os.path.join(cache, geo_files[0])
    mari.projects.create(
        texture.get_long_name(), geo_file_path, [], [], dict(), [
            {
                '/': mari.geo.GEOMETRY_IMPORT_DONT_MERGE_CHILDREN
            },
        ])

    # At this point there should be no files left to add but if there are then the user was warned about it and we can go ahead and try to load those in.
    # This was from when we exported a bunch of alembics from Maya instead of just one. And since it shouldn't get called unless something goes wrong I figure it might be interesting to see what would happen if something goes wrong so we might as well leave it.
    for i in range(1, len(geo_files)):
        geo_file_path = os.path.join(cache, geo_files[i])
        mari.geo.load(geo_file_path)
        print 'Loaded ' + geo_file_path
예제 #5
0
class RequestEmailDialog(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Email")
        # palette = parent.palette
        self.setPalette(parent.palette)

        self.project = Project()
        self.username = self.project.get_current_username()
        self.user = self.project.get_user(self.username)
        self.user_fullname = self.user.get_fullname()

        request_str = '<span style=" font-size:12pt; font-weight:600;">Please input your email address</span>'
        info_str = "username: "******"\nfull name: " + self.user_fullname
        self.request_label = QtGui.QLabel(request_str)
        self.info_label = QtGui.QLabel(info_str)

        input_str = "email:"
        self.input_label = QtGui.QLabel(input_str)

        self.input = QtGui.QLineEdit()
        self.input.textChanged.connect(self._check_valid)

        self.accept_button = QtGui.QPushButton("OK")
        self.accept_button.setEnabled(False)
        self.accept_button.clicked.connect(self._store_email)

        self.layout = QtGui.QVBoxLayout(self)
        self.layout.addWidget(self.request_label)
        self.layout.addWidget(self.info_label)
        self.input_layout = QtGui.QHBoxLayout()
        self.input_layout.addWidget(self.input_label)
        self.input_layout.addWidget(self.input)
        self.layout.addLayout(self.input_layout)
        self.layout.addWidget(self.accept_button)

    def _check_valid(self, text):
        if re.match(r"[^@]+@[^@]+\.[^@]+",
                    text):  # check for valid email address
            self.accept_button.setEnabled(True)
        else:
            self.accept_button.setEnabled(False)

    def _store_email(self):
        self.user.update_email(str(self.input.text()))
        self.done(0)
class RequestEmailDialog(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Email")
        # palette = parent.palette
        self.setPalette(parent.palette)

        self.project = Project()
        self.username = self.project.get_current_username()
        self.user = self.project.get_user(self.username)
        self.user_fullname = self.user.get_fullname()
        
        request_str = '<span style=" font-size:12pt; font-weight:600;">Please input your email address</span>'
        info_str = "username: "******"\nfull name: "+self.user_fullname
        self.request_label = QtGui.QLabel(request_str)
        self.info_label = QtGui.QLabel(info_str)

        input_str = "email:"
        self.input_label = QtGui.QLabel(input_str)

        self.input = QtGui.QLineEdit()
        self.input.textChanged.connect(self._check_valid)

        self.accept_button = QtGui.QPushButton("OK")
        self.accept_button.setEnabled(False)
        self.accept_button.clicked.connect(self._store_email)

        self.layout = QtGui.QVBoxLayout(self)
        self.layout.addWidget(self.request_label)
        self.layout.addWidget(self.info_label)
        self.input_layout = QtGui.QHBoxLayout()
        self.input_layout.addWidget(self.input_label)
        self.input_layout.addWidget(self.input)
        self.layout.addLayout(self.input_layout)
        self.layout.addWidget(self.accept_button)

    def _check_valid(self, text):
        if re.match(r"[^@]+@[^@]+\.[^@]+", text): # check for valid email address
            self.accept_button.setEnabled(True)
        else:
            self.accept_button.setEnabled(False)

    def _store_email(self):
        self.user.update_email(str(self.input.text()))
        self.done(0)
def assemble_hda():
    asset_name = checkout_window.result

    if asset_name is None:
        return

    project = Project()
    environment = Environment()
    username = project.get_current_username()
    asset = project.get_asset(asset_name)
    assembly = asset.get_element(Department.ASSEMBLY)
    # Checkout assembly
    checkout_file = assembly.checkout(username)

    if asset.get_type() == AssetType.SET:
        assemble_set(project, environment, assembly, asset, checkout_file)
    else:
        assemble(project, environment, assembly, asset, checkout_file)