eliemichel / MapsModelsImporter

A Blender add-on to import models from google maps

Home Page:https://blog.exppad.com/article/importing-actual-3d-models-from-google-maps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to automate .rdc processing

mwussow opened this issue · comments

I am wondering whether there is a simple way to automate .rdc processing? I am thinking of a little Python loop that performs the following steps for each .rdc file in a provided directory:

  • Open .rdc file with max_blocks = [input]
  • Save file as .blend
  • Close file

I believe such a tool would be extremely useful because it can take several minutes (at least on my machine) to open an *rdc file and only a few seconds to open a *.blend
I would be very grateful for any advice on how to implement this (main question: how to call the rdc importer from a python script?)

Thanks in advance!

You can "record" macros in Blender by more or less copying what appears in the "info" window to a python file. For instance, if you put this in /tmp/import_capture.py:

import bpy
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
bpy.ops.import_rdc.google_maps(filepath="/tmp/capture.rdc", max_blocks=10)
bpy.ops.wm.save_mainfile(filepath="/tmp/capture.blend")

Then you can run in command line blender -b -P /tmp/import_capture.py it'll run Blender in background -b and execute the python script then quit, leaving you with a /tmp/capture.blend with 20 blocks of the capture imported. You may wrap all this script in a for loop to load several captures into several blend files!

Thank you, you tool is amazing and your advice extremely helpful!

For anyone else wondering, I just wrote it up as a nice script that you can just paste into your Text Editor:
Just change the "DIR" parameter in the script on line 5. Works like a charm. :)
After verifying that it's working, of course change the max_blocks back to "-1" to import the whole thing.

import bpy
import glob
from os import path

DIR = r"P:\04_assets\B_mapscap\03_rooseveltisland\01_scans\test\*.rdc"
files = glob.glob(DIR)

# clean scene first
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
for c in bpy.data.collections:
    bpy.data.collections.remove(c)
    

print("\n\nCommander, commencing maps import!\n")


for file in files:
    filename = path.split(file)[1]
    print(filename)
    
    # create collection
    collection = bpy.data.collections.new(filename)
    # link to scene collection
    bpy.context.scene.collection.children.link(collection)
    
    # set active
    layer_collection = bpy.context.view_layer.layer_collection.children[collection.name]
    bpy.context.view_layer.active_layer_collection = layer_collection
    
    # import current file
    bpy.ops.import_rdc.google_maps(filepath=file, max_blocks=30)

I have created an automation script that handles this plugin and if you have the Lily Capture Merger and Lily Texture Packer it handles them as well, my solution is in a pre-release stage and will be undergoing further improvements and will be providing a video tutorial on how to ensure a successful operation of this.
The script solution can be found on GitHub page at: https://github.com/sir306/GoogleEarth_MapImport_CapMerge_TexPack_Automation