Im not sure what you exactly need but you can try this.
' Replace with your own path
Dim searchPath As String = "D:\forum\"
' Replace with your own path
' Make sure it exits
Dim writeDirectory As String = "D:\forum\output\"
' if the wrong template is used then provide the corect template path
Dim templateFileName As String = ThisApplication.FileManager.GetTemplateFile(
DocumentTypeEnum.kDrawingDocumentObject)
Dim oTg As TransientGeometry = ThisApplication.TransientGeometry
Dim searchDir As IO.DirectoryInfo = New IO.DirectoryInfo(searchPath)
Try
For Each fileInfo As IO.FileInfo In searchDir.GetFiles("*.iam")
Dim assembly As Document = ThisApplication.Documents.Open(fileInfo.FullName, True)
Dim doc As DrawingDocument = ThisApplication.Documents.Add(
DocumentTypeEnum.kDrawingDocumentObject, templateFileName)
Dim sheet As Sheet = doc.ActiveSheet
Dim center As Point2d = oTg.CreatePoint2d(sheet.Width / 2, sheet.Height / 2)
Dim view As DrawingView = sheet.DrawingViews.AddBaseView(
assembly,
oTg.CreatePoint2d(0, 0),
1,
ViewOrientationTypeEnum.kIsoTopLeftViewOrientation,
DrawingViewStyleEnum.kShadedDrawingViewStyle)
Dim scaleX = sheet.Width / view.Width
Dim scaleY = sheet.Height / view.Width
If (scaleX < scaleY) Then
view.Scale = scaleX
Else
view.Scale = scaleY
End If
view.Center = center
assembly.Close(True)
Dim newFileName As String = IO.Path.Combine(
writeDirectory, IO.Path.ChangeExtension(fileInfo.Name, "idw"))
doc.SaveAs(newFileName, True)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
ThisApplication.SilentOperation = False
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com