# Import Xgen Groom with conversion settings not working (Python)

**URL:** <https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929>\
**Category:** Editor Scripting\
**Tags:** Python, unreal-engine, UE4-26, Alembic, question\
**Created:** [June 3, 2022, 4:16am UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929 "2022-06-03T04:16:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_87e5ba83](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_87e5ba83](https://forums.unrealengine.com/u/anonymous_user_87e5ba83)\
**Post date:** [June 3, 2022, 4:16am UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/1 "2022-06-03T04:16:31Z")

</div>

I am trying to import an alembic groom and apply conversion settings via Python.

In the `unreal` module I’ve found `unreal.GroomImportOptions` and `unreal.GroomConversionSettings`. I’ve created instances of both, and set the “conversion\_settings” editor property of the `GroomImportOptions` with my `GroomConversionSettings`. The `GroomImportOptions` are then passed to my asset import function. The imported groom did not receive the conversion settings during the import.

I’m new to unreal and wondering where this is breaking down. Is my build\_import\_task function breaking something, or missing something? Do I need to modify the editor’s Groom Import Options (the ui) via Python somehow before attempting to import? Using UE 4.26. Appreciate any help here. Thanks!

Here’s the code I’m using:

```auto
def build_groom_options():
    # xgen conversion values
    vec_rot = unreal.Vector(-90, 0.0, 0.0)
    vec_scl = unreal.Vector(1.0, 1.0, -1.0)
    
    # conversion settings
    groom_settings = unreal.GroomConversionSettings()
    groom_settings.set_editor_property('rotation', vec_rot)
    groom_settings.set_editor_property('scale', vec_scl)

    # generate options and combine conversion settings
    groom_options = unreal.GroomImportOptions()
    groom_options.set_editor_property('conversion_settings', groom_settings)
    
    return groom_options

def build_import_task(path, destination, name=None, options=None):
    if not name:
        name = "no_name" 
    task = unreal.AssetImportTask()
    task.set_editor_property('automated', True)
    task.set_editor_property('destination_name', name)
    task.set_editor_property('destination_path', destination)
    task.set_editor_property('filename', path)
    task.set_editor_property('replace_existing', True)
    task.set_editor_property('replace_existing_settings', True)
    task.set_editor_property('save', False)
    task.set_editor_property('options', options)

    return task

def exec_import(tasks):
    result = unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(tasks)

    return result

def import_asset(path, destination, name=None, options=None):
    task = build_import_task(path, destination, name, options)
    exec_import([task])

    return task

# test
path = "/path/to/hair.abc"
dest = "/Game/Hair"
name = "hair_001"
options = build_groom_options()

import_asset(path, dest, name, options)

```

---

<div class="post-metadata">

**Author:** ![Yan\_kmmVFXHub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yan\_kmmVFXHub](https://forums.unrealengine.com/u/Yan_kmmVFXHub)\
**Post date:** [August 24, 2022, 7:16am UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/3 "2022-08-24T07:16:13Z")

</div>

Okay @anonymous_user_87e5ba83 … I have figured out how to get this to work:

You have to create an GroomAssetImportData object and pass in the GroomImportOptions object into the constructor. The finally set the GroomAssetImportData as the AssetImportTask options.

conversionSettings = unreal.GroomConversionSettings(rotation=[90.0, 0.0, 0.0],  
scale=[1.0, -1.0, 1.0]) # maya to unreal diffs  
options = unreal.GroomImportOptions()  
options.set\_editor\_property(‘conversion\_settings’, conversionSettings)  
groomData = unreal.GroomAssetImportData(options)  
AssetImportTask.set\_editor\_property(‘options’, groomData)

I had to troll through the C/C++ headers to figure that one out… yikes.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_87e5ba83](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_87e5ba83](https://forums.unrealengine.com/u/anonymous_user_87e5ba83)\
**Post date:** [August 27, 2022, 10:57pm UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/4 "2022-08-27T22:57:18Z")

</div>

Thank you for responding! I really appreciate you digging through the C/C++ to find an answer.

Unfortunately I was not able to get this to work. I know that I had some false positives previously (before I posted my original question) where it looked like it was working. Apparently if you manually import via Unreal dialogs, when you specify the conversion settings, those values stick for future imports.

Can you confirm your editor’s conversion settings are at their defaults before importing a groom via python?  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/3/783992503286ce0b05276dcf06ef70bb97d9d889.png)

I tried using the GroomAssetImportData as you suggested. Here’s what I tried.

```auto
groom_settings = unreal.GroomConversionSettings(rotation=[-90, 0.0, 0.0],
                                                scale=[1.0, 1.0, -1.0])

groom_options = unreal.GroomImportOptions()
groom_options.set_editor_property('conversion_settings', groom_settings)

groom_import_data = unreal.GroomAssetImportData(groom_options)

name = 'hair_001'
path = "/path/to/hair.abc"
dest = "/Game/Hair"

task = unreal.AssetImportTask()
properties = {'destination_name': name,
              'destination_path': dest,
              'filename': path,
              'replace_existing': True,
              'replace_existing_settings': True,
              'save': False,
              'options': groom_import_data,
              'automated': True}

task.set_editor_properties(properties)

unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])

```

The conversion settings do not get applied in both UE4\_26 and UE5.  
Do you see anything wrong with this code?

---

<div class="post-metadata">

**Author:** ![Yan\_kmmVFXHub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yan\_kmmVFXHub](https://forums.unrealengine.com/u/Yan_kmmVFXHub)\
**Post date:** [August 28, 2022, 11:29pm UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/5 "2022-08-28T23:29:40Z")

</div>

Hiya @anonymous_user_87e5ba83

My GUI import settings are:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/b/3aba9cc2aa10b2d65e6c84cf5ca89babfef07b38.png)

while my code conversion settings are:

conversionSettings = unreal.GroomConversionSettings(rotation=[90.0, 0.0, 0.0],  
scale=[1.0, -1.0, 1.0])

And the grooms do come in correctly. So yes, the code is being applied correctly.

The only difference that I see with your code versus mine is that I call

AssetImportTask.set\_editor\_property(‘options’, groomData)

after the AssetImportTask object is created. Logically, that shouldn’t make any difference but who knows what voodoo is going on under the hood in the C/C++ layer.

Here is my full import function, if you want to copy and paste that to try:

def doImport(sourcePath, destPath, replaceExisting) :  
AssetTools = unreal.AssetToolsHelpers.get\_asset\_tools()  
import\_tasks = []

```
for fname in os.listdir(sourcePath):
    if fname.endswith('.abc'):
        AssetImportTask = unreal.AssetImportTask()
        AssetImportTask.set_editor_property('automated', True)
        AssetImportTask.set_editor_property('filename', sourcePath + '/' + fname)
        AssetImportTask.set_editor_property('destination_path', destPath)
        AssetImportTask.set_editor_property('replace_existing', replaceExisting)
        AssetImportTask.set_editor_property('save', True)

        conversionSettings = unreal.GroomConversionSettings(rotation=[90.0, 0.0, 0.0],
                                                            scale=[1.0, -1.0, 1.0]) # maya to unreal diffs
        options = unreal.GroomImportOptions()
        options.set_editor_property('conversion_settings', conversionSettings)

        groomData = unreal.GroomAssetImportData(options) # this part is critical, you have to pass in the options into the GroomAssetImportData object

        AssetImportTask.set_editor_property('options', groomData)

        import_tasks.append(AssetImportTask)

AssetTools.import_asset_tasks(import_tasks)

```

I have a loop in there because our characters have multiple grooms.

Cheers!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_87e5ba83](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_87e5ba83](https://forums.unrealengine.com/u/anonymous_user_87e5ba83)\
**Post date:** [August 29, 2022, 3:19am UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/6 "2022-08-29T03:19:30Z")

</div>

Hey, thanks again for keeping the conversation alive 🙂

Thanks for posting your code. I tried it, but did not have any success. It imported all of the grooms in the directory, but did not apply any conversion settings.

Thanks for posting your GUI import conversion settings, but I’m pretty sure those ones only apply to FBX import. I believe the only way to see the Groom Import Options dialog is by manually importing a groom. Would you be able to test that for me? Could you try to manually import a groom In order to see the Groom Import Options dialog? I need to know that your options for conversion settings are not affecting anything you are doing through code. If you find values, set them back to defaults (rotation 0, 0, 0; scale 1, 1, 1) and try your code again and let me know what you find.

I really appreciate your time and patience on this. This is driving me crazy.

---

<div class="post-metadata">

**Author:** ![Yan\_kmmVFXHub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yan\_kmmVFXHub](https://forums.unrealengine.com/u/Yan_kmmVFXHub)\
**Post date:** [September 1, 2022, 5:14am UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/7 "2022-09-01T05:14:57Z")

</div>

Hiya @anonymous_user_87e5ba83,

Unfortunately, you are right. The options are sticky from the last GUI import. Arrrggghhh…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_87e5ba83](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_87e5ba83](https://forums.unrealengine.com/u/anonymous_user_87e5ba83)\
**Post date:** [September 2, 2022, 2:16am UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/8 "2022-09-02T02:16:07Z")

</div>

Hey,

Thanks for confirming my suspicions.

It’s as though we have all of the right ingredients, but lack the correct way to cook up this recipe. We need some Unreal Dev chefs.

Thanks again for your effort to help. Much appreciated.

---

<div class="post-metadata">

**Author:** ![DW\_MaxR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DW\_MaxR](https://forums.unrealengine.com/u/DW_MaxR)\
**Post date:** [March 8, 2023, 6:09pm UTC](https://forums.unrealengine.com/t/import-xgen-groom-with-conversion-settings-not-working-python/572929/9 "2023-03-08T18:09:07Z")

</div>

Hello !

I found how to correctly apply the groom options on import, you were so close !  
Thanks for your scripts, was helpful 🙂  
Here is the solution:  
the ‘options’ of the AssetImportTask should be the GroomImportOptions and not a GroomAssetImportData. We don’t need an GroomAssetImportData.

Edit:  
I’m realizing that it is what you did initially, but it didn’t work for you.  
I’m on 5.1.1 though, maybe it was silently fixed.
