1
$\begingroup$

enter image description here Object C has copy rotation constraint and is copying rotation from A and B

When i rotate objects A and B target object C rotates but the Transform does not show the resultant rotation values.

Q1: Where dose the resultant rotation values are show?

Q2: Can they be accessed through python?

$\endgroup$
1
$\begingroup$

On Q2 target_object.matrix_world.to_euler() will give you the resulting euler rot, which could be used in a panel to ans Q1 part.

Example script using the panel template.

import bpy
from math import degrees

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the object context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "OBJECT_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def draw(self, context):
        layout = self.layout
        obj = context.active_object
        col = layout.column()
        mw = obj.matrix_world
        euler_rot = mw.to_euler()
        for axis in "xyz":
            col.label("%c : %7.4f" % (axis, degrees(getattr(euler_rot, axis, 0))))

def register():
    bpy.utils.register_class(LayoutDemoPanel)

def unregister():
    bpy.utils.unregister_class(LayoutDemoPanel)

if __name__ == "__main__":
    register()
$\endgroup$
0
$\begingroup$

@ batFINGER Thank you

I wanted it to know bone constraints resultant value and with a bit fidgeting batFINGER code i got this.

If some one can generalize this code to work for any object, bone etc that wold be awesome. But my problem is solved.

import bpy
from math import degrees

## changed class name to avoid duplicate class
class LayoutDemoPanelBone(bpy.types.Panel):
    """Creates a Panel in the object context of the properties editor"""
    bl_label = "Layout Demo Bone"
    bl_idname = "OBJECT_PT_layout_Bone"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "bone" ## changed here

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def draw(self, context):
        layout = self.layout
        obj = context.selected_pose_bones[0] ## changed here i don't know if there is active pose bone method
        col = layout.column()
        mw = obj.matrix ## changed here
        euler_rot = mw.to_euler()
        for axis in "xyz":
            col.label("%c : %7.4f" % (axis, degrees(getattr(euler_rot, axis, 0))))

def register():
    bpy.utils.register_class(LayoutDemoPanelBone)

def unregister():
    bpy.utils.unregister_class(LayoutDemoPanelBone)

if __name__ == "__main__":
    register()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.