Message 1 of 6
Export - Directory Not Found Exception
Not applicable
01-26-2010
02:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to use the export method to export a view to dwg, but it keeps throwing a directory not found exception. Can someone please tell me what I am doing wrong? Here is my class:
Imports System.IO
Imports Autodesk.Revit
Public Class rvtExport
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Export View to 2007 DWG
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Shared Function exportViewDWG(ByVal rvtapp As Autodesk.Revit.Application) As String
Dim str As String = Nothing
Dim viewSet As Autodesk.Revit.Elements.ViewSet = rvtapp.Create.NewViewSet
Dim expOpt As DWGExportOptions = rvtapp.Create.NewDWGExportOptions
Dim pathName As String = rvtapp.ActiveDocument.PathName
Dim folderName As String = Path.GetDirectoryName(pathName)
Dim fileName As String = "Test"
'select view
viewSet.Insert(rvtapp.ActiveDocument.ActiveView)
'set options
expOpt.ExportingAreas = False
expOpt.FileVersion = Enums.ACADVersion.Default
expOpt.ExportOfSolids = Enums.SolidGeometry.ACIS
expOpt.MergedViews = True
expOpt.SharedCoords = False
expOpt.TargetUnit = Autodesk.Revit.Enums.ExportUnit.Inch
Try
If rvtapp.ActiveDocument.Export(folderName, fileName, viewSet, expOpt) Then
str = "Exported " & folderName & fileName & vbCr
Else
str = "Failed to export " & folderName & fileName & vbCr
End If
Catch ex As System.IO.DirectoryNotFoundException
str = "Directory not found: " & ex.Message
End Try
Return str
End Function
End Class
Imports System.IO
Imports Autodesk.Revit
Public Class rvtExport
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Export View to 2007 DWG
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Shared Function exportViewDWG(ByVal rvtapp As Autodesk.Revit.Application) As String
Dim str As String = Nothing
Dim viewSet As Autodesk.Revit.Elements.ViewSet = rvtapp.Create.NewViewSet
Dim expOpt As DWGExportOptions = rvtapp.Create.NewDWGExportOptions
Dim pathName As String = rvtapp.ActiveDocument.PathName
Dim folderName As String = Path.GetDirectoryName(pathName)
Dim fileName As String = "Test"
'select view
viewSet.Insert(rvtapp.ActiveDocument.ActiveView)
'set options
expOpt.ExportingAreas = False
expOpt.FileVersion = Enums.ACADVersion.Default
expOpt.ExportOfSolids = Enums.SolidGeometry.ACIS
expOpt.MergedViews = True
expOpt.SharedCoords = False
expOpt.TargetUnit = Autodesk.Revit.Enums.ExportUnit.Inch
Try
If rvtapp.ActiveDocument.Export(folderName, fileName, viewSet, expOpt) Then
str = "Exported " & folderName & fileName & vbCr
Else
str = "Failed to export " & folderName & fileName & vbCr
End If
Catch ex As System.IO.DirectoryNotFoundException
str = "Directory not found: " & ex.Message
End Try
Return str
End Function
End Class