I have to store the current region 3d for an object in a Python addon.


But I have to create a copy of this, I dont want to store a reference, is this possible?

I need the location and rotation of the viewport when this object is created, so that I can manipulate it with the data of this, even when the user changes the current view zoom or rotation.


1 Answer 1


Ok, got it, just copied the required info I needed

class ViewContext():

    def __init__(self, context):
        rv3d           = context.space_data.region_3d
        self._view_rot = rv3d.view_rotation.copy()
        self._view_mat = rv3d.view_matrix.copy()
        self._pers_mat = rv3d.perspective_matrix.copy()
        self._view_pers = rv3d.view_perspective
        self._is_perspective = rv3d.is_perspective
        self._region = ViewRegion(context.region)

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.