Help in getting value from custom property and updating it into a text field

I am struggling in obtaining what I want in a configurator I made using Blender and python scripting.

This is what I would like to achieve: I have 7 custom properties (quotes in mm) which I adjust by using IntProperties in a custom panel in the UI 3D View. As I need to export the results of the configuration, and didn’t want this to be made by a simple print screen, I thought about a button which renders the camera view (top ortho) and composites it with another layer where I have the names and (tentatively) the values of the quotes. Unfortunately I can’t seem to update the content of the text. I managed to see it in a console, and it correctly updates if I update the text by entering edit mode and pressing some key. This is how I achieved it:

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        mytool = scene.my_tool
        mypanel = scene.ignit_panel
        Misura_1_text = scene.objects['Misura 1']
        print(Misura_1_text.data.body)

However, if in the following line I try to assign whichever value (e.g. “Mis_1” to the “Misura_1_text.data.body” by

        Misura_1_text.data.body = "Mis_1"

I get the following error: “Writing to ID classes in this context is not allowed: Text, Curve datablock, error setting TextCurve.body”

Apparently, this should be the right way to go (e.g. https://blender.stackexchange.com/questions/165454/updating-text-object-in-blender-2-81-using-python) but I can’t seem to succeed. And this is just the beginning, as I still didn’t manage to read the custom property value… :worried:

Thanks to anyone who can point me towards the right direction.

1 Like

I seem to have identical problem while writing to textCurve object, python script breaks animations on object , including when its changes of the position should result from constraints only when rendering . I have the same error at the end of rendering.

I hope you get it working but if not then read ahead.
I think you are trying to do something in Panel’s draw code which is not possible.
If you want to change the body of text object, you should create operator. And put it in your panel by
layout.operator("Operator's id_name").You should look into Operator : Here