2

I am working on a task where I need to accept a template file (.rte) as input and save the resultant revit file in 3d view.

I understand that to activate 3d view, we need UIDocument which is not available when we work in DesignAutomation API.

In an addin project in the past I had implemented it in the following way:

FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(View3D));

foreach (View3D v in collector)
{
    if (!v.IsTemplate)
    {
        uiApp.ActiveUIDocument.ActiveView = v;
    }
}

So is there any other way to do this in DesignAutomation API.

Rahul Bhobe
  • 4,165
  • 4
  • 17
  • 32
JPais
  • 115
  • 2
  • 14

1 Answers1

1

You definitely have no access whatsoever to the UIDocument in the Design Automation API. It does not even exist. I suggest you just go ahead and generate your Revit model as before and then see what view ends up being saved. Quite possibly it is the 3D view anyway.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
  • Thank you for your reply. its the top view that is generated as output and not 3d view – JPais Aug 26 '20 at 15:46
  • Aha. Well, the 3D view exists, generally. It is normally named `{3D}`, I believe. You can activate it using... oops... [Document.Active.View is read-only](https://www.revitapidocs.com/2020/043960ac-dde4-0f45-249f-8161646a4362.htm)... `UIDocument` is not available... don't know. Why do you care what view is active? It doesn't really matter, does it? – Jeremy Tammik Aug 27 '20 at 16:46
  • Actually, the scenario is that I am drawing a ceiling, but when I download the file as output from forge api, the ceiling is drawn but it can't be seen in the default view that is opened. Hence I am asked to save in a 3d view – JPais Sep 07 '20 at 06:19
  • Here is an interesting discussion on [setting the preview image](https://thebuildingcoder.typepad.com/blog/2011/05/set-preview-image.html) from which you may be able to glean some hints. – Jeremy Tammik Sep 08 '20 at 07:35