2
$\begingroup$

How to get existing custom transform orientation data (actually I look for names, ideally as a list)?

I made topic on Blender Artists python support - no any reply. Maybe here someone knows a solution.

I found only method do read currently selected transform orientation by bpy.data.scenes['Scene'].transform_orientation_slots[0].type

$\endgroup$
6
  • $\begingroup$ You were close : C.scene.transform_orientation_slots[0].custom_orientation.matrix. For detailed answer look here : blender.stackexchange.com/a/156437/115433 $\endgroup$
    – Reigen
    Commented Jul 18, 2021 at 19:11
  • 1
    $\begingroup$ You don't get me right probably. I seek not how create TO but how to read existing in scene. Issue is this bpy.context.scene.transform_orientation_slots looks more like some incompleted thing. If I print slots as a list (not just [0]) - it alwaus give 4 (no matter how many custom TO's exist) items. bpy.data.scenes['Scene'].transform_orientation_slots[0], [1], [2], [3]. Whre [0] one return currently selected TO data, others return 'DEFAULT' something useless. But I want to read data of all custom TO's from under the hood without selecting them manually in TO menu... $\endgroup$
    – IIIFGIII
    Commented Jul 18, 2021 at 20:14
  • 2
    $\begingroup$ Didn't understand your question properly before. I don't think there is proper way but there is a workaround : blender.stackexchange.com/a/196080/115433 Since you are mainly looking for name linked answer will suffice but you want to read TO's matrix then you need to set first set active TO to custom then read it's data then restore original TO $\endgroup$
    – Reigen
    Commented Jul 19, 2021 at 8:43
  • $\begingroup$ Unexpected "solution". To cause manual error > get error message > get list of names from error message. All this in case when just get list of names isn't possible... huhhhhh. But even this not work for me (( When I try to set this slots[0].type via console it works. But when I try do same via addon function (I will use to set enum fo addon UI) it not work. Said that "Writing to ID classes in this context is not allowed: Scene, Scene datablock, error setting TransformOrientationSlot.type" $\endgroup$
    – IIIFGIII
    Commented Jul 19, 2021 at 13:18
  • $\begingroup$ Edit - it work if I put try out of function. Now problem are - staying out of function it executes only once when I enable addon so it not refresh list of TO's. Any Ideas how to workaround this Writing to ID classes in this context is not allowed: Scene, Scene datablock, error setting TransformOrientationSlot.type limitation? $\endgroup$
    – IIIFGIII
    Commented Jul 19, 2021 at 16:39

0

You must log in to answer this question.

Browse other questions tagged .