How to use the algorithms.print_log_report function in algorithms

To help you get started, we’ve selected a few algorithms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github calben / EasyBastioniLAB / materialengine.py View on Github external
def generate_displacement_image(self):
        disp_data_image_name = self.image_file_names["displ_data"]
        if disp_data_image_name != "":
            disp_data_image = algorithms.get_image(disp_data_image_name)
            if disp_data_image:
                disp_size = disp_data_image.size
                algorithms.print_log_report("INFO","Creating the displacement image from data image {0} with size {1}x{2}".format(disp_data_image.name, disp_size[0], disp_size[1]))
                disp_img = algorithms.new_image(self.image_file_names["body_displ"], disp_size)
            else:
                algorithms.print_log_report("WARNING","Cannot create the displacement modifier: data image not found: {0}".format(algorithms.simple_path(self.image_file_paths["displ_data"])))
github calben / EasyBastioniLAB / humanoid.py View on Github external
def save_backup_character(self, filepath):

        dir_path = os.path.dirname(filepath)
        filename = os.path.basename(filepath)
        filename_root = os.path.splitext(filename)[0]
        new_filename = filename_root + '_backup.json'
        new_filepath = os.path.join(dir_path,new_filename)
        algorithms.print_log_report("INFO","Saving backup character {0}".format(algorithms.simple_path(new_filepath)))
        self.save_character(new_filepath, export_proportions=False, export_materials=True, export_metadata = True)
github calben / EasyBastioniLAB / morphengine.py View on Github external
measures = self.measures
        if "body_height_Z" in measures:
            if "buttock_girth" in measures:
                if "chest_girth" in measures:
                    p1 = round(measures["buttock_girth"]/measures["body_height_Z"],4)
                    p2 = round(measures["chest_girth"]/measures["body_height_Z"],4)
                    p3 = round(measures["waist_girth"]/measures["body_height_Z"],4)
                    p4 = round(measures["upperarm_axillary_girth"]/measures["body_height_Z"],4)
                    p5 = round(measures["upperleg_top_girth"]/measures["body_height_Z"],4)
                    self.proportion_index = [p1,p2,p3,p4,p5]
                else:
                    algorithms.print_log_report("ERROR","The 'chest_girth' measure not present in the analyzed database")
            else:
                algorithms.print_log_report("ERROR","The 'buttock_girth' measure not present in the analyzed database")
        else:
            algorithms.print_log_report("ERROR","The 'body_height_Z' measure not present in the analyzed database")
github calben / EasyBastioniLAB / humanoid.py View on Github external
obj = self.get_object()
        log_msg_type = "character data"

        if type(data_source) == str:  #TODO: better check of types
            log_msg_type = algorithms.simple_path(data_source)
            charac_data = algorithms.load_json_data(data_source,"Character data")
        else:
            charac_data = data_source

        algorithms.print_log_report("INFO","Loading character from {0}".format(log_msg_type))

        if "manuellab_vers" in charac_data:
            if not algorithms.check_version(charac_data["manuellab_vers"]):
                algorithms.print_log_report("WARNING","{0} created with vers. {1}. Current vers is {2}".format(log_msg_type,charac_data["manuellab_vers"],self.lab_vers))
        else:
            algorithms.print_log_report("INFO","No lab version specified in {0}".format(log_msg_type))

        if "structural" in charac_data:
            char_data = charac_data["structural"]
        else:
            algorithms.print_log_report("WARNING","No structural data in  {0}".format(log_msg_type))
            char_data = {}

        if "materialproperties" in charac_data:
            material_data = charac_data["materialproperties"]
        else:
            algorithms.print_log_report("INFO","No material data in  {0}".format(log_msg_type))
            material_data = {}

        if "metaproperties" in charac_data:
            meta_data = charac_data["metaproperties"]
        else:
github calben / EasyBastioniLAB / proxyengine.py View on Github external
def fit_proxy_object(self,proxy_offset=0.0, proxy_threshold = 0.5, create_proxy_mask = False, transfer_w = True):
        scn = bpy.context.scene
        status, proxy, body = self.get_proxy_fitting_ingredients()
        if status == "OK":
            armat = algorithms.get_linked_armature(body)
            self.calibrate_proxy_object(proxy)
            self.reset_proxy_shapekey(proxy)#Always after calibration!

            proxy.matrix_world = body.matrix_world

            template_name = algorithms.get_template_model(body)
            mask_name = "mbastlab_mask_" + proxy.name

            algorithms.print_log_report("INFO","Fitting proxy {0}".format(proxy.name))
            selected_objs_names = algorithms.get_objects_selected_names()

            body_modfs_status = algorithms.get_object_modifiers_visibility(body)
            proxy_modfs_status = algorithms.get_object_modifiers_visibility(proxy)

            algorithms.disable_object_modifiers(proxy, ['ARMATURE','SUBSURF','MASK'])
            algorithms.disable_object_modifiers(body, ['ARMATURE','SUBSURF','MASK'])


            basis_body = algorithms.import_object_from_lib(self.templates_library, template_name, stop_import = False)

            proxy_shapekey = algorithms.new_shapekey(proxy,"mbastlab_proxyfit")


            self.fit_distant_vertices(proxy,basis_body,proxy_shapekey,body)
github calben / EasyBastioniLAB / materialengine.py View on Github external
def assign_image_to_node(self, material_name, node_name, image_name):
        algorithms.print_log_report("INFO","Assigning the image {0} to node {1}".format(image_name,node_name))
        mat_node = algorithms.get_material_node(material_name, node_name)
        mat_image = algorithms.get_image(image_name)
        if mat_image:
            algorithms.set_node_image(mat_node,mat_image)
        else:
            algorithms.print_log_report("WARNING","Node assignment failed. Image not found: {0}".format(image_name))
github calben / EasyBastioniLAB / animationengine.py View on Github external
self.skeleton_mapped = {}
        self.lib_filepath = algorithms.get_blendlibrary_path()
        self.knowledge_path = os.path.join(self.data_path,"retarget_knowledge.json")

        if os.path.isfile(self.lib_filepath) and os.path.isfile(self.knowledge_path):

            self.knowledge_database = algorithms.load_json_data(self.knowledge_path,"Skeleton knowledge data")
            self.local_rotation_bones = self.knowledge_database["local_rotation_bones"]
            self.last_selected_bone_name = None
            self.stored_animations = {}
            self.correction_is_sync = True
            self.is_animated_bone = ""
            self.rot_type =  ""
            self.has_data = True
        else:
            algorithms.print_log_report("CRITICAL","Retarget database not found. Please check your Blender addons directory.")
            return None
github calben / EasyBastioniLAB / humanoid.py View on Github external
def sync_obj_props_to_character_metadata(self):

        self.metadata_realtime_activated = False
        obj = self.get_object()
        for meta_data_prop, value in self.character_metaproperties.items():
            if hasattr(obj, meta_data_prop):
                setattr(obj, meta_data_prop, value)
            else:
                if "last" not in meta_data_prop:
                    algorithms.print_log_report("WARNING","metadata {0}.{1} not found".format(obj.name,meta_data_prop))
        self.metadata_realtime_activated = True
github calben / EasyBastioniLAB / morphengine.py View on Github external
obj = self.get_object()
        #Reset all values (for expressions only) and create the basis key
        for morph_name in self.morph_data.keys():
            if "Expression" in morph_name:
                self.calculate_morph(morph_name, 0.0)
                self.update()
        algorithms.new_shapekey(obj, "basis")         
     

        #Store the character in neutral expression
        obj = self.get_object()
        stored_vertices = []
        for vert in obj.data.vertices:
            stored_vertices.append(mathutils.Vector(vert.co))

        algorithms.print_log_report("INFO","Storing neutral character...OK")
        counter = 0
        for morph_name in sorted(self.morph_data.keys()):
            if "Expression" in morph_name:
                counter += 1
                self.calculate_morph(morph_name, 1.0)
                algorithms.print_log_report("INFO","Converting {} to shapekey".format(morph_name))
                self.update(update_all_verts=True)
                new_sk = algorithms.new_shapekey_from_current_vertices(obj, morph_name)
                new_sk.value = 0               

                #Restore the neutral expression
                for i in range(len(self.final_form)):
                    self.final_form[i] = stored_vertices[i]
                self.update(update_all_verts=True)
        algorithms.print_log_report("INFO","Successfully converted {0} morphs in shapekeys".format(counter))
github calben / EasyBastioniLAB / proxyengine.py View on Github external
def transfer_weights(self, body, proxy):

        body_kd_tree = algorithms.kdtree_from_mesh_vertices(body.data)

        fit_shapekey = algorithms.get_shapekey(proxy, "mbastlab_proxyfit")
        if fit_shapekey:
            proxy_vertices = fit_shapekey.data
        else:
            proxy_vertices = proxy.data.vertices
            algorithms.print_log_report("WARNING","Weights transfer executed without fitting (No fit shapekey found)")



        body_verts_weights = [[] for v in body.data.vertices]
        for grp in body.vertex_groups:
            for idx, w_data in enumerate(body_verts_weights):
                try:
                    w_data.append([grp.name,grp.weight(idx)])
                except:
                    pass #TODO: idx in grp.weight

        for p_idx, proxy_vert in enumerate(proxy_vertices):

            proxy_vert_weights = {}
            nearest_body_vert = body_kd_tree.find(proxy_vert.co)
            min_dist =  nearest_body_vert[2]