Insert multiple assemblies to idw top left isometric view

Insert multiple assemblies to idw top left isometric view

Anonymous
Not applicable
323 Views
1 Reply
Message 1 of 2

Insert multiple assemblies to idw top left isometric view

Anonymous
Not applicable

Thanks in advance for reading

 

I have to make alot of quick views for our catalogue.

From dozens of assemblies I should have a topleft isometric view (idw).

 

Drag-and-drop from explorer to idw isnt possible... do I have to open all assemblies and place views one by one?

0 Likes
324 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor

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.

EESignature


Blog: hjalte.nl - github.com

0 Likes