Need help on some Miraco files please

For the first issue, see this thread:

https://forum.revopoint3d.com/t/empty-revo-file-after-crash-during-saving/39234/1

Second issue has no easy answer. When the scanner actually knows that it lost tracking, it creates a new prefix number for the following frames. So in the cache folder you’ll see frame_000_0000 for the first sequence, and frame_001_0000 for the next, etc. Duplicate your project as many times as you need to isolate each sequence (delete the frames from all but one of those sequences in each duplicate project). That might give you a better view as you’re not working with all the pieces simultaneously. Of course it isn’t always broken up that neatly but sometimes you get lucky.

I have a Python module that splits a scan up into pieces based on prefix number and creates a new project with each piece as a separate scan. I don’t pretend that I know how to write proper code but it works most of the time.

import json, uuid, os, subprocess, glob, copy

#project_file includes full path
#model_num is index of model to split as found under 'nodes' key in project file

def create_project(project_file, model_num, export_path_input):
    new_guid = str(uuid.uuid4())
    project_name=os.path.split(project_file)[1]
    project_path=os.path.normpath(os.path.split(project_file)[0])+'\\'
    export_path=os.path.normpath(export_path_input)+'\\'

    with open(project_file, 'r') as json_file:
        project_data = json.load(json_file)

    model = project_data["nodes"][model_num]

    source_dir = project_path+"data\\"+project_data["nodes"][model_num]["guid"]+"\\cache\\"
    source_dir_model = project_path+"data\\"+project_data["nodes"][model_num]["guid"]+"\\"
    dest_dir = export_path + project_data["nodes"][model_num]["name"]
    dest_dir_data = dest_dir+"\\data\\"

    with open(source_dir_model+"property.rvproj", 'r') as json_file:
        model_properties = json.load(json_file)

    print(source_dir)
    print(dest_dir)

    if not os.path.exists(dest_dir):
        os.mkdir(dest_dir)
        os.mkdir(dest_dir_data)        

    new_project_name = model["name"]
    new_project = project_data
    new_project["guid"] = new_guid
    new_project["name"] = new_project_name
    new_project["nodes"] = []

    components = {}

    x = 0
    searching = True
    filename_to_search = f"{source_dir}\\{x:0>3}_*."

    while searching:
        
        filelist = glob.glob(f"{source_dir}\\frame_{x:0>3}_*.inf")

        if len(filelist) == 0:
            searching = False
            print('While loop ended')
        else:
            components[x] = filelist
            x += 1

    base_name = model['name']

    for a in range(len(components)):
        new_model = model
        new_properties = model_properties
        new_model['name'] = f'p{a}_' + base_name
        new_model['guid'] = f'p{a}_' + base_name
        new_project['nodes'].append(copy.copy(new_model))
        new_properties['guid'] = new_model['name']
        new_properties['vf_count'] = len(components[a])
        new_properties['scan_step'] = 1
        dest_dir_new_name = dest_dir_data+new_model['name']
        dest_dir_cache = dest_dir_new_name+'\\cache\\'

        print("Creating destination directories...")
        os.mkdir(dest_dir_new_name)
        os.mkdir(dest_dir_cache)
        os.mkdir(dest_dir_new_name+'\\param')
        os.mkdir(dest_dir_new_name+'\\dump')
        print(f"Copying files for component {a}...")
        copy_return = subprocess.check_output(["copy", f"{source_dir}frame_{a:0>3}_*.*", dest_dir_cache], shell=True)
        copy_return = subprocess.check_output(["copy", f"{source_dir_model}param\\", dest_dir_new_name+'\\param\\'], shell=True)
        copy_return = subprocess.check_output(["copy", f"{source_dir_model}frameFlag.json", dest_dir_new_name+'\\'], shell=True)
        if os.path.isdir(f'{source_dir_model}param1'):
            print('param1 directory found')
            os.mkdir(dest_dir_new_name+'\\param1')
            copy_return = subprocess.check_output(["copy", f"{source_dir_model}param1\\", dest_dir_new_name+'\\param1\\'], shell=True)


        with open(f"{dest_dir_new_name}\\property.rvproj", "w") as f:
            json.dump(new_properties, f, indent=4)
        
    with open(f"{dest_dir}\\{new_project_name}.revo", "w") as f:
        json.dump(new_project, f, indent=4)

    print('Done.')
    return
2 Likes