Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
bwang-tecoustics
341 Views, 1 Reply

Copy View from a file

I was able to use view.copyto to copy views from a file to another file when I have the source drawing open in inventor. But when I try to copy views from an ApprenticeServerDocument, I can read view names and locations but can not copy the views. Is this because ApprenticeServerDocument can only provide access to the drawing's properties but can't use the methods of the objects? Any one can help me on this?

 

        Dim dwgDoc As DrawingDocument
        dwgDoc = _invApp.ActiveDocument

        Dim dwgSheet As Sheet
        dwgSheet = dwgDoc.ActiveSheet


        Dim oApprentice As ApprenticeServerComponent

        oApprentice = New ApprenticeServerComponent

        Dim oADoc As ApprenticeServerDocument

        oADoc = oApprentice.Open("D:\Drawing1.idw")

        MsgBox(oADoc.DocumentType.ToString)

        Dim oASheets As Sheets
        oASheets = oADoc.Sheets

        For Each sht As Sheet In oASheets
            MsgBox(sht.Name)

            Dim oADViews As DrawingViews
            oADViews = sht.DrawingViews

            For Each oVw As DrawingView In oADViews
                MsgBox(oVw.Name & " is " & oVw.ViewType.ToString & ", at " & oVw.Position.X.ToString & ", " & oVw.Position.Y.ToString)
                Try
                    oVw.CopyTo(dwgSheet)
                Catch ex As Exception
                    MsgBox("Copy Faled.")
                End Try
                
            Next

        Next


        oADoc.Close()
        oApprentice.Close()