# Programmatically set blueprint defaults in editor

**URL:** <https://forums.unrealengine.com/t/programmatically-set-blueprint-defaults-in-editor/442078>\
**Category:** Blueprint\
**Tags:** unreal-engine, Automation, editor, UE4, question, CPP\
**Created:** [January 25, 2019, 5:53pm UTC](https://forums.unrealengine.com/t/programmatically-set-blueprint-defaults-in-editor/442078 "2019-01-25T17:53:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MeessenPhilips](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MeessenPhilips](https://forums.unrealengine.com/u/MeessenPhilips)\
**Post date:** [January 25, 2019, 5:53pm UTC](https://forums.unrealengine.com/t/programmatically-set-blueprint-defaults-in-editor/442078/1 "2019-01-25T17:53:42Z")

</div>

Hello,

I need to programmatically assign default values to a blueprint’s parameters in the editor via c++ (at editor time).  
The idea is to change the default values, recompile the blueprint and then all instances of it will automatically update to the new values.

I have the code below, it runs, but the default value doesn’t change in the editor. If I read back the set value it is correct.

```
void UEditBlueprint::TestSetPropertyDefault(UBlueprint* aBlueprint)
{
	UBoolProperty* boolProp = Cast<UBoolProperty>(aBlueprint->GeneratedClass->FindPropertyByName(FName(TEXT("SetPropertyTestBool"))));
	boolProp->SetPropertyValue_InContainer(aBlueprint, true);
		
	// Test read back
	bool propVal = boolProp->GetPropertyValue_InContainer((UObject*)(aBlueprint));

	aBlueprint->MarkPackageDirty();
	FKismetEditorUtilities::CompileBlueprint(aBlueprint);
}

```

It is needed for an automation pipeline, so ideally I want to solve it like this, not with setting values of every reference in every level. This example is for a bool, the actual parameter will be an array of actors which are created programmatically.

I have tried many different approaches and am out of ideas. I think I might be working on a wrong reference or perhaps missing a call which propagates the change (to the UI)?

---

<div class="post-metadata">

**Author:** ![KristofMorva](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kristofmorva/32/1194508_2.png) [@KristofMorva](https://forums.unrealengine.com/u/KristofMorva)\
**Post date:** [January 25, 2019, 9:22pm UTC](https://forums.unrealengine.com/t/programmatically-set-blueprint-defaults-in-editor/442078/2 "2019-01-25T21:22:26Z")

</div>

If I don’t misunderstand what you’re trying to achieve, I believe you can change the default values simply by setting any values on `Class->GetDefaultObject()`. If I remember correctly, it’ll be propagated back to the editor immediately.

---

<div class="post-metadata">

**Author:** ![MeessenPhilips](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MeessenPhilips](https://forums.unrealengine.com/u/MeessenPhilips)\
**Post date:** [January 28, 2019, 10:09am UTC](https://forums.unrealengine.com/t/programmatically-set-blueprint-defaults-in-editor/442078/3 "2019-01-28T10:09:15Z")

</div>

Thanks that did the trick, I needed to call the above code on the default object.  
The change is reflected in the editor, but not propagated to the instances, I will look into that now, as it does work when setting manually.

---

<div class="post-metadata">

**Author:** ![ianFisch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ianFisch](https://forums.unrealengine.com/u/ianFisch)\
**Post date:** [May 8, 2024, 5:27am UTC](https://forums.unrealengine.com/t/programmatically-set-blueprint-defaults-in-editor/442078/4 "2024-05-08T05:27:52Z")

</div>

This doesn’t seem to work. Changing the values in the default object doesn’t seem to affect any instances of that actor in my map.
