# Why can I not edit the Mesh name in field created with row.prop(obj, “data”)

With the following code I can read out the name of a mesh data block.

row.prop(obj, "data")


And with the following code I can read out the name of the object.

row.prop(obj, "name")


But I noticed that I cannot edit the mesh data name only the object name.

Here is the code from Blender that generated the mesh data block UI.

class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
bl_label = ""
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}

def draw(self, context):
layout = self.layout

ob = context.object
mesh = context.mesh
space = context.space_data

if ob:
layout.template_ID(ob, "data")
elif mesh:
layout.template_ID(space, "pin_id")


Think of Objects as containers, which can contain Curve data or Mesh data (and a few other kinds).

obj.data will refer to the Mesh or the Curve of the object. You would need to do the following to display the mesh's name

row.prop(obj.data, "name")


Or replicating what the standard panels do (with or without the icon).

    obj = context.object

col = layout.column()
if obj.data:
col.prop(obj.data, "name")
col.prop(obj.data, "name", icon="OUTLINER_DATA_" + obj.type)
else:
col.label('An empty selected')


• Thank your very much. I learned a lot in the past days. I start to understand now how my students must feel when I teach Blender and they are new to it. There is a lot to take in. – Claas Kuhnen Jan 5 '16 at 18:30