Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed TOC

This page provides information on the automated process of importing a .vrscene inside Unreal Engine.

Floatingpagetoc

 


Overview

...

Section
Column
width45%

Automating the process of importing .vrscenes in Unreal Engine can be easily achieved using the python scripting language.

Column
width5%

 


 
Column
width50%



Set Up Your Project for Python

...

Section
Column
width45%

To be able to use Python in the Unreal Editor you will need to enable the Python Editor Script Plugin for your current Project.

UI Path: ||Toolbar|| Settings > Plugins > Scripting> Python Editor Script Plugin

UI Path: ||Menu Bar|| Edit > Plugins > Scripting> Python Editor Script Plugin


For additional information regarding the python plugin please see the Unreal documentation: Scripting the Editor using Python
 
Column
width5%

Column
width50%


.vrcene Import Properties

...

Code Block
e.g. unreal.VRaySceneImportSettings().set_editor_property('y_axis_up', False)

 


VRaySceneFactory()

import_settings (VRaySceneImportSettings) – Optional override to tweak some of the import settings. If set, the VRayScene import will be executed without any user confirmation (i.e. silent import). If not set the default settings settings will be used and the VRay import settings dialog will be shown to confirm the import settings

Code Block
e.g. unreal.VRaySceneFactory().set_editor_property('import_settings ', unreal.VRaySceneImportSettings().set_editor_property('y_axis_up', False))

 

 



Usage Example

...

Section
Column
width45%

In this short example Test.vrscene file is linked and  some of the Import settings properties are set in a python file which is imported in Unreal using the Python Editor Script Plugin. In Unreal you can type the following command in the console to run the script.

py "PATH_TO_PYTHON_FILE.py"

 
Column
width5%

Column
width50%
Code Block
import unreal

def vrscene_import_test(automated=False):
    file_path = r"PATH_TO_VRSCENE/Test.vrscene"
    task = unreal.AssetImportTask()
    task.set_editor_property('automated', automated)

    factory = unreal.VRaySceneFactory()
    
    importSettings = unreal.VRaySceneImportSettings()
    importSettings.set_editor_property('bYAxisUp', False)
    importSettings.set_editor_property('create_assets', True)
    importSettings.set_editor_property('create_actors', True)
    importSettings.set_editor_property('create_nodes', True)
    importSettings.set_editor_property('create_lights', True)
    factory.set_editor_property('import_settings', importSettings)

    task.set_editor_property('filename', file_path)
    task.set_editor_property('replace_existing', True)
    task.set_editor_property('destination_path', "/Game/Assets/Test/")
    task.set_editor_property('factory', factory)

    tasks = [task]
    t = unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(tasks)

vrscene_import_test(True)