Is it possible to set the scene view rotation pivot through code?

I know one can set it in the editor by selecting an object and pressing F. I would like however to do that through C# scripting …

You need use “SceneView” class from UnityEditor namespace.

If you want to change the sceneview position you have to set a new position to the pivot of the scene view

void UpdateSceneView ()
    {

	_scene = SceneView.lastActiveSceneView;
	Vector3 newPos = _scene.pivot;
	newPos.x = 0;
	newPos.y = (_2dMode) ? 0 : 40;
	newPos.z = (_2dMode) ? 40 : 0;
	_scene.pivot = newPos;

	_scene.Repaint ();

}

You could also just load a game object and just pass the gameobject.transform to the sceneview

_scene.AlignViewToObject (_camera.transform);