Orient an existing 3D view in a Revit project to an isometric direction

Hello all,

I would like to orient an existing 3D view in a Revit project to an isometric southeast direction, for example, as the Home Orientation of the view cube of a 3D view.


It looks simple in Revit but I don’t find the way to do it using Dynamo.

If found the custom node “3DView Set Orientation” in the Package geniusloci, it works but I have to use an existing view as a reference to replicate the same orientation to a list of different 3D views. That means that I have to edit manually the orientation of one 3D view in Revit to make it work.

How can I set from Dynamo the orientation of a 3D view as the available in Revit: Orient to Direction, Orient to View, Orient to Plane…?

This node says it is based of the Ben Osborne script:

#From Ben Osborne
#http://dynamobim.org/forums/topic/view-orientation-and-python-script-refresh/

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import 

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitAPI")
import Autodesk

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

The entries made in this node are stored as a list in the IN variables.
doc = DocumentManager.Instance.CurrentDBDocument

def ProcessList(_func, _list):
    return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )

def Unwrap(item):
    return UnwrapElement(item)

if isinstance(IN[0], list):
    controlview = ProcessList(Unwrap, IN[0])
else:
    controlview = [Unwrap(IN[0])]

if isinstance(IN[1], list):
    views = ProcessList(Unwrap, IN[1])
else:
    views = [Unwrap(IN[1])]

TransactionManager.Instance.EnsureInTransaction(doc)
for control in controlview:
	control.Unlock()
	viewSetting = control.GetOrientation()
	control.SaveOrientationAndLock()
for view in views:
	view.Unlock()
	view.SetOrientation(viewSetting)
	view.SaveOrientationAndLock()
TransactionManager.Instance.TransactionTaskDone()

#Assign the output to the OUT variable.
OUT = (controlview,views)

If somebody knows the solution it would be very helpful.

Thanks

https://www.revitapidocs.com/2019/882f774b-b290-14b8-2664-8f86ec42f458.htm

use the Revit lookup add-in to see what the parameters are for the :
XYZ eyePosition,
XYZ upDirection,
XYZ forwardDirection

Create a ViewOrientation3D with these parameters, set them to the view you desire.
Adjust accordingly. The control cube option will automatically adjust the distance to accommodate for the object (building) size, at least it did in my tests.

1 Like

This may be what you need

1 Like

Can you share your Dynamo file?
I also tried to do this but didn’t work.

Hi,
can anyone help me regarding the same script. I see that the python script contains "viewSetting = control.GetOrientation() " transaction however I´m not sure how to utilize that function alone in a script so that the output would just show current status of the 3d view´s orientation? I need to ensure first whether the orientation is A or B (northeast or southeast) and then use if statement to flip the view 180 degrees in case the orientation currently is for example A.

BR,
Sten

Hi!
I was in the same situation (to get the 3D view orientation). So I made some modifications in the code above from @RubenVivancos. Now it returns the Eye position, Forward Direction and UpDirection (as vectors).

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import*

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitAPI")
import Autodesk
clr.AddReference("RevitServices")



#The entries made in this node are stored as a list in the IN variables.

def Unwrap(item):
    return UnwrapElement(item)

if isinstance(IN[0], list):
    controlview = Unwrap(IN[0])
else:
    controlview = [Unwrap(IN[0])]

for control in controlview:
	viewSetting = control.GetOrientation()
	eyeposition=viewSetting.EyePosition
	forwarddirection=viewSetting.ForwardDirection
	updirection=viewSetting.UpDirection

#Assign the output to the OUT variable.
OUT = (eyeposition, forwarddirection, updirection)
1 Like