概要

エラー内容

PySideで作成したGUI内で選択しているオブジェクトを取得しようと以下のコマンドを実行したらエラーが出た。

selected_objects = bpy.context.selected_objects

dirでbpy.contexを調べるてみると、selected_objects アトリビュートが無いようだ。

Untitled

dirで contexを調べてみると selected_objectsが無い

Untitled

メインGUIから同じコードを実行した場合

Untitled

調べてみた

bpy.context.selected_objects: Context object has no attribute "selected_objects"

The context is dependent on quite a number of things, and not every context holds the scene's set of selected_objects. A safer and more consistent way to get the selected objects is this:

PySideの場合、アトリビュートが継承されない??