# Create custom mesh actor with python

**URL:** <https://forums.unrealengine.com/t/create-custom-mesh-actor-with-python/451009>\
**Category:** Editor Scripting\
**Tags:** Python, actor-blueprint, unreal-engine, question\
**Created:** [June 20, 2019, 5:54pm UTC](https://forums.unrealengine.com/t/create-custom-mesh-actor-with-python/451009 "2019-06-20T17:54:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_c6d1ecef](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c6d1ecef](https://forums.unrealengine.com/u/anonymous_user_c6d1ecef)\
**Post date:** [June 20, 2019, 5:54pm UTC](https://forums.unrealengine.com/t/create-custom-mesh-actor-with-python/451009/1 "2019-06-20T17:54:34Z")

</div>

Hello there.  
I’m trying to use the Python plugin to automate some content creation. Specifically, I am trying to create an actor with a HierarchicalInstancedStaticMeshComponent and place it in a scene, without resorting to blueprints.

I’ve been trying this for a while now and haven’t quite figured out the way yet. Here is how far I’ve got:

1. Create actor: "ac = unreal.EditorLevelLibrary.spawn\_actor\_from\_class(unreal.Actor, unreal.Vector())
2. Create my static mesh: "■■■ = unreal.EditorAssetLibrary.load\_asset(‘/Game/foo/bar’)
3. Create my component: "c = unreal.HierarchicalInstancedStaticMeshComponent(ac, ‘mycomponent’)

Notice above that I am forced to provide an “outer” to the component. I just picked “ac” (my actor) but that feels incorrect. a ‘None’ is not accepted. What is the correct way to create the component?

1. Assign the mesh to the component: c.set\_static\_mesh(acc)

Now comes the problematic part. I’d like to set the component as the actor’s root component. But if I do:  
“`ac.set_editor_property("root_component", c)`”  
then the component shows up, but it is flagged as (inherited) in the level editor, and I cannot edit it. The editor displays a warning that it needs to be a UProperty to be editable, or something like that.

If I attach it to the root component, by:

```
c.attach_to_component(ac.root_component, "", unreal.AttachmentRule.KEEP_RELATIVE, unreal.AttachmentRule.KEEP_RELATIVE, unreal.AttachmentRule.KEEP_RELATIVE, False)

```

Then it doesn’t show up. Additionally, I start to get errors like:  
LogPython: Error: Exception: Actor: Internal Error - ObjectInstance is null!

So: What is the correct way to a) create the component without having an “outer” and  
b) attaching it as the root component to an Actor?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d01dda73](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d01dda73](https://forums.unrealengine.com/u/anonymous_user_d01dda73)\
**Post date:** [October 8, 2019, 10:45pm UTC](https://forums.unrealengine.com/t/create-custom-mesh-actor-with-python/451009/2 "2019-10-08T22:45:49Z")

</div>

Were you able to resolve this?

---

<div class="post-metadata">

**Author:** ![Ashermind](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ashermind](https://forums.unrealengine.com/u/Ashermind)\
**Post date:** [March 13, 2025, 2:42pm UTC](https://forums.unrealengine.com/t/create-custom-mesh-actor-with-python/451009/3 "2025-03-13T14:42:24Z")

</div>

I will assume that he weren’t.
