def __init__(self, file_path='', **kwargs): super(Component, self).__init__(**kwargs) self.file_path = fields.FilePathField( name='File Path', value=file_path, filter='Skeleton Files (*.json)', help_text='The Skeleton file path.') self.add_field(self.file_path)
class Component(core.Component): """A Component that imports or references in a Maya file.""" import_operation = 'Import' reference_operation = 'Reference' files = fields.ArrayField('files', add_label_text='Add File', display_name=False) container = fields.ContainerField('file', parent=files, container_view=FileView()) operation = fields.CharField( 'operation', choices=[import_operation, reference_operation], default=import_operation, help_text='Whether to import or reference the file.', parent=container) file_path = fields.FilePathField('file_path', filter='Maya Files (*.ma *.mb)', help_text='The Maya file path.', parent=container) namespace = fields.CharField( 'namespace', help_text='The import or reference namespace.', parent=container) @classmethod def image_path(cls): return ':/fileOpen.png' def help_url(self): return 'https://github.com/chadmv/cmt/wiki/File-Component' def execute(self): for container in self.files: operation = container['operation'].value() file_path = container['file_path'].get_path() namespace = container['namespace'].value() flag = 'i' if operation == Component.import_operation else 'r' kwargs = { flag: True, 'type': { '.ma': 'mayaAscii', '.mb': 'mayaBinary', '.fbx': 'FBX', }[os.path.splitext(file_path.lower())[-1]] } if namespace: kwargs['namespace'] = namespace cmds.file(file_path, **kwargs)
def __init__(self, file_paths=None, **kwargs): super(Component, self).__init__(**kwargs) self.array_field = fields.ArrayField(name='File Paths', add_label_text='Add Skin File') self.add_field(self.array_field) if file_paths is None: file_paths = [''] if isinstance(file_paths, basestring): file_paths = [file_paths] for file_path in file_paths: self.array_field.add_field(fields.FilePathField( name='File Path', value=file_path, filter='Skin Files (*.skin)', help_text='The Skeleton file path.'))
class Component(core.Component): """A Component that imports skin weights using skinio.""" files = fields.ArrayField('files', add_label_text='Add Skin File', display_name=False) file_path = fields.FilePathField('file_path', filter='Skin Files (*.skin)', help_text='The Skeleton file path.', parent=files) @classmethod def image_path(cls): return ':/importSmoothSkin.png' def execute(self): for file_field in self.files: file_path = file_field.get_path() skinio.import_skin(file_path)
def __init__(self, file_path='', namespace='', operation=import_operation, **kwargs): super(Component, self).__init__(**kwargs) self.operation = fields.ChoiceField( name='Operation', choices=[ Component.import_operation, Component.reference_operation ], value=operation, help_text='Whether to import or reference the file.') self.add_field(self.operation) self.file_path = fields.FilePathField(name='File Path', value=file_path, filter='Maya Files (*.ma *.mb)', help_text='The Maya file path.') self.add_field(self.file_path) self.namespace = fields.CharField( name='Namespace', value=namespace, help_text='The import or reference namespace.') self.add_field(self.namespace)