If I understood the problem correctly, you can use Getter / Setter functions to achieve your goal.
def set_value(self, value):
bpy.context.active_object.location.x = value
if __name__ == "__main__":
bpy.types.Scene.someValue = bpy.props.FloatProperty(get=...
I've found an answer via from Detective bpy on the Blender Community Discord. They provided a link to this post:
Which led me to this solution:
bpy.context.scene.someValue = bpy.context.selected_objects.location.x
In the end, the answer is "You can't get there from here". More precisely, when you add an update function to a property in a class, Blender massages that property at registration time, in such a way that the context argument to the update function becomes the window manager, and not the context you need to look up the property.
This is why the ...
It is not a bug. Floating point numbers are only accurate to about 8 decimals in Blender because it uses CPU single precision internally. Depending on what you mean by a lot you might want to investigate numpy which uses double precision internally.
Quaternion data-types need 4 float values while euler rotation data-types need only 3 values and the default size for FloatVectorProperty is 3 ; so together with subtype argument that should be set to QUATERNION we should also set the size argument to 4 and the field now holds a quaternion data-type.
It is because localUpdate is an instance method. localString is a class annotation adding a property to all instances but at the time is defined, instance methods are not yet registered in the class. (At least that's my guess)
So you have to move localUpdate out of the class definition :
This works :
from bpy.types import Operator, Panel
Although i am not the add-on-Pro....i think it is because you are showing the global variable field too. So it takes the value from that field. If you comment out
# col.prop(context.scene, "globalString", text="Global")
But i am sure batfinger can explain this better ;)
I was not satisifed with the way the field is dimmed and the value can't be accessed in a color field when it is read-only.
I added custom get and set methods to ensure the user can't modify it from the interface, while being able to click the field and copy the values inside the RGB widget.
bpy.types.Object.my_prop = bpy.props....
If you have many unused materials, you can also assign them a 'fake user' in the outliner.
In the Outliner, use the Orphan Data View, then in Materials, select what you want and either click on their 'shield' icons (on the right of the image below) or right click the material and choose 'Add fake user'.
Press on the shield icon in order to make sure that your material (or any other data) is safe. The name of the material will then be preceded by the letter "F" like "Fake User". As long as the name is preceded by "0" it means that the data has no user and that it will be lost when you'll close the file: