Open model in background and change view

Sorry I sent you to the wrong path. There are at least three issues here:

  • ActiveView property of the document that you open is get only. Unless you activate the document and get the ActiveView property from the UIDocument which is get and set. There is a method for opening and activating the document called OpenAndActivateDocument() which returns the UIDocument. However, as Dynamo is using the idling event Revit doesn’t allow to activate another document. Therefore you can’t set the ActiveView with this method as well. I don’t know of any method to set the ActiveView for a document that is open in the background at the moment using Dynamo. Although you can get the OpenAndActivateDocument method to work with a macro for instance. However if you want to stick to Dynamo:

  • There’s another way you can try, which might give you what you want. In Revit API we have another class called StartingViewSettings you can get the starting view of the document by calling its get method in this way:

startingViewSettings = GetStartingViewSettings(doc)

then set the ViewId property this way:

startingViewSettings.ViewId = view

then if you save & close the document and open it again you should get ActiveView of the doc to the view which you have set previously.

1 Like