Custom Exporter with created inactive 3D View

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey guys,
I try to export a scene in revit using a custom exporter. I would like to export the scene without forcing the user to click on the 3D view button. In order to do this I create my own 3D view and send it to the exporter but then revit crashes somewhere by trying to access an invalid location: "Unhandled exception at 0x00007ffcb9b0a814 in Revit.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff."
In all the tutorials I could only find code which uses the active view of the document. So my question is: Can I do this without the active view but with my own "offline view" to fake the user 3D mode? I mean the view should be just a view projection matrix with some additional bounding box calculations etc. for optimization isn't it?
Here is the way I create the 3D view:
System::Collections::Generic::IList<Autodesk::Revit::DB::ViewFamilyType^>^ viewFamilyTypes = gcnew System::Collections::Generic::List<Autodesk::Revit::DB::ViewFamilyType^>(); FilteredElementCollector^ elementCollector = gcnew FilteredElementCollector(this->doc); for each(Autodesk::Revit::DB::Element^ type in elementCollector->OfClass(Autodesk::Revit::DB::ViewFamilyType::typeid)) { if (((Autodesk::Revit::DB::ViewFamilyType^)type)->ViewFamily == Autodesk::Revit::DB::ViewFamily::ThreeDimensional) { viewFamilyTypes->Add((Autodesk::Revit::DB::ViewFamilyType^)type); } } try { offlineView3D = Autodesk::Revit::DB::View3D::CreateIsometric(this->doc, viewFamilyTypes[0]->Id); } catch (Exception^ e) { } if (nullptr != offlineView3D) { XYZ^ eye = gcnew XYZ(-23.04f, 27.42f, 23.12f); XYZ^ forward = (gcnew XYZ(-0.344f, -0.776f, -0.528f))->Normalize(); XYZ^ up = gcnew XYZ(-0.214f, -0.483f, 0.85f); offlineView3D->SetOrientation(gcnew ViewOrientation3D(eye, up, forward)); Autodesk::Revit::DB::Parameter^ farClip = offlineView3D->LookupParameter("Far Clip Active"); farClip->Set(0); }
And then later on the document changed event I'm using the view like this:
MyOwnExportContext^ exportContext; Autodesk::Revit::DB::CustomExporter^ exporter; if (View3D^ view3D = dynamic_cast<View3D^>(view)) { exporter->Export(view3D); }