How To edit StaticMesh BodySetup via Python Script UE 4.27.2

Hello guys,

I am trying to modify StaticMesh asset BodySetup and set double_sided_geometry using Python script and I am having small problem to make it work. I am doing this:


import unreal as ue
asset = ue.EditorAssetLibrary.load_asset('/Game/MyStaticMeshAsset')
bdy = ue.BodySetup(asset)


print( bdy.get_editor_property ("double_sided_geometry"))

bdy.set_editor_property('double_sided_geometry',True)

print(bdy.get_editor_property ('double_sided_geometry'))  #  Returns True  

#but

bdy2 = ue.BodySetup(asset)
print( bdy2.get_editor_property ( 'double_sided_geometry' ))  #  Returns False  - which means bd2 is copy of asset not the reference
ue.EditorAssetLibrary.save_loaded_asset( asset )

# as result in asset is still   double_sided_geometry = False 

I found out that bdy is copy of asset.BodySetup so I need to set it back modified version of BodySetup to asset but I don’t know how. Any help would be amazing!

Thanks!!!

I found the solution

import unreal as ue
asset = ue.EditorAssetLibrary.load_asset('/Game/Cube2')
bdy = ue.BodySetup(asset)
bdy.set_editor_property('double_sided_geometry',True)
asset.set_editor_property('body_setup',bdy)
ue.EditorAssetLibrary.save_loaded_asset(asset,False)

asset.set_editor_property(‘body_setup’,bdy) will set local var bdy to asset so it will become ref from that point any change on bdy is reflected to asset directly.

Maybe someone can have some use of this
Cheers!

1 Like