Skip to main content
added 199 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context.camera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or for the context object

cam = context.objectactive_object.data

and in the poll method make sure 'context.scene`scene` and or context.scene.camera are not None, and if using the latter that context.objectactive_object is not None and context.object.type (or context context.active_object.type) is 'CAMERA'

example poll

    @classmethod
    def poll(cls, context):
        if context.active_object is None:
            return False
        return context.active_object.type == 'CAMERA'

The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context.camera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or for the context object

cam = context.object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.object is not None and context.object.type (or context.active_object.type) is 'CAMERA'

The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context.camera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or for the context object

cam = context.active_object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.active_object is not None and context.active_object.type is 'CAMERA'

example poll

    @classmethod
    def poll(cls, context):
        if context.active_object is None:
            return False
        return context.active_object.type == 'CAMERA'
deleted 62 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

I put a note in another of your questions re context.lamp. The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context.camera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or for the context object

cam = context.object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.object is not None and context.object.type (or context.active_object.type) is 'CAMERA'

I put a note in another of your questions re context.lamp. The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context.camera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or for the context object

cam = context.object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.object is not None and context.object.type (or context.active_object.type) is 'CAMERA'

The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context.camera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or for the context object

cam = context.object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.object is not None and context.object.type (or context.active_object.type) is 'CAMERA'

added 2 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

I put a note in another of your questions re context.lamp. The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context. Thiscamera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or cam = for the context.object.data object

cam = context.object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.object is not None and context.object.type (or context.active_object.type) is 'CAMERA'

I put a note in another of your questions re context.lamp. The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object. This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

or cam = context.object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.object.type (or context.active_object.type) is 'CAMERA'

I put a note in another of your questions re context.lamp. The properties panel has some of its own context members that only work in the property panel space. The "context" attribute of the space is shown in the icons across the top which change for what type of object is active, eg a camera icon for the data part of a camera object, in which case context.camera resolves to the data part of the active object, similarly for context.lamp and context.speaker for those types of object.

This is something to look out for when refactoring code from space_properties to, for instance, the 3D toolshelf. Anyhoo a good workaround here is

cam = context.scene.camera.data

the "active camera", ie the one that renders the scene, or for the context object

cam = context.object.data

and in the poll method make sure 'context.scene` and or context.scene.camera are not None, and if using the latter that context.object is not None and context.object.type (or context.active_object.type) is 'CAMERA'

Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244
Loading