def get_dictionary_items(prop, context): id_tag = prop.as_pointer() if id_tag and DictionaryEnum.__items_id == id_tag: return DictionaryEnum.__items_cache DictionaryEnum.__items_id = id_tag DictionaryEnum.__items_cache = items = [] if 'import' in prop.bl_rna.identifier: items.append(('DISABLED', 'Disabled', '', 0)) items.append(('INTERNAL', 'Internal Dictionary', 'The dictionary defined in ' + __name__, len(items))) for txt_name in sorted(x.name for x in bpy.data.texts if x.name.lower().endswith('.csv')): items.append( (txt_name, txt_name, "bpy.data.texts['%s']" % txt_name, 'TEXT', len(items))) import os from mmd_tools_local.bpyutils import addon_preferences folder = addon_preferences('dictionary_folder', '') if os.path.isdir(folder): for filename in sorted(x for x in os.listdir(folder) if x.lower().endswith('.csv')): filepath = os.path.join(folder, filename) if os.path.isfile(filepath): items.append( (filepath, filename, filepath, 'FILE', len(items))) if 'dictionary' in prop: prop['dictionary'] = min(prop['dictionary'], len(items) - 1) return items
def update_toon_texture(self): mmd_mat = self.__material.mmd_material if mmd_mat.is_shared_toon_texture: shared_toon_folder = addon_preferences('shared_toon_folder', '') toon_path = os.path.join(shared_toon_folder, 'toon%02d.bmp'%(mmd_mat.shared_toon_texture+1)) self.create_toon_texture(bpy.path.resolve_ncase(path=toon_path)) elif mmd_mat.toon_texture != '': self.create_toon_texture(mmd_mat.toon_texture) else: self.remove_toon_texture()
def build(self): rigidbody_world_enabled = rigid_body.setRigidBodyWorldEnabled(False) if self.__root.mmd_root.is_built: self.clean() self.__root.mmd_root.is_built = True logging.info('****************************************') logging.info(' Build rig') logging.info('****************************************') start_time = time.time() self.__preBuild() self.buildRigids( bpyutils.addon_preferences('non_collision_threshold', 1.5)) self.buildJoints() self.__postBuild() logging.info(' Finished building in %f seconds.', time.time() - start_time) rigid_body.setRigidBodyWorldEnabled(rigidbody_world_enabled)
if id_tag and DictionaryEnum.__items_id == id_tag: return DictionaryEnum.__items_cache DictionaryEnum.__items_id = id_tag DictionaryEnum.__items_cache = items = [] if 'import' in prop.bl_rna.identifier: items.append(('DISABLED', 'Disabled', '', 0)) items.append(('INTERNAL', 'Internal Dictionary', 'The dictionary defined in '+__name__, len(items))) for txt_name in sorted(x.name for x in bpy.data.texts if x.name.lower().endswith('.csv')): items.append((txt_name, txt_name, "bpy.data.texts['%s']"%txt_name, 'TEXT', len(items))) import os from mmd_tools_local.bpyutils import addon_preferences folder = addon_preferences('dictionary_folder', '') if os.path.isdir(folder): for filename in sorted(x for x in os.listdir(folder) if x.lower().endswith('.csv')): filepath = os.path.join(folder, filename) if os.path.isfile(filepath): items.append((filepath, filename, filepath, 'FILE', len(items))) if 'dictionary' in prop: prop['dictionary'] = min(prop['dictionary'], len(items)-1) return items @staticmethod def get_translator(dictionary): if dictionary == 'DISABLED': return None if dictionary == 'INTERNAL':