# Copy enums from struct to struct

**URL:** <https://forums.unrealengine.com/t/copy-enums-from-struct-to-struct/487849>\
**Category:** Editor Scripting\
**Tags:** UProperty, ustruct, UEnum, ENUM, unreal-engine, question\
**Created:** [August 23, 2021, 3:46am UTC](https://forums.unrealengine.com/t/copy-enums-from-struct-to-struct/487849 "2021-08-23T03:46:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![VesperDuck](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vesperduck/32/895457_2.png) [@VesperDuck](https://forums.unrealengine.com/u/VesperDuck)\
**Post date:** [August 23, 2021, 3:46am UTC](https://forums.unrealengine.com/t/copy-enums-from-struct-to-struct/487849/1 "2021-08-23T03:46:42Z")

</div>

Hey all,

I’ve got a pair of structs which both inherit from the same parent, and both have the same enum UProperties inherited from the parent, of which there are at least 20+ enum properties, and at some points, I want to copy the enums from one struct to the other without having to manually list out each enum property = other enum property for the sake of extensibility.

So I’ve got a TFieldIterator loop which successfully iterates through and retrieves the UEnumProperty’s, but when trying to use the StructA-\>SetEnum(StructB-\>GetEnum()), it throws an error (though doesn’t crash the engine).

The code so far…

```
for (TFieldIterator<UProperty> PropIt(OriginalStruct.StaticStruct()); PropIt; ++PropIt)
	{
		UProperty* Property = *PropIt;
		UEnumProperty* EnumProperty = FindFProperty<UEnumProperty>(AddedStruct->StaticStruct(), Property->GetFName());
		
		if (EnumProperty)
		{
			UEnumProperty* OriginalEnumProperty = CastFieldChecked<UEnumProperty>(Property);
			if (OriginalEnumProperty)
				EnumProperty->SetEnum(OriginalEnumProperty->GetEnum());
		}
	}

```

Any ideas?
