Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to automate .rdc processing #39

Closed
mwussow opened this issue Mar 13, 2020 · 4 comments
Closed

How to automate .rdc processing #39

mwussow opened this issue Mar 13, 2020 · 4 comments

Comments

@mwussow
Copy link

mwussow commented Mar 13, 2020

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!

@eliemichel
Copy link
Owner

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!

@mwussow
Copy link
Author

mwussow commented Mar 14, 2020

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

@megger-cgfx
Copy link

megger-cgfx commented Jan 26, 2021

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)

@sir306
Copy link

sir306 commented Jul 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants