Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Copy View from a file

bwang-tecoustics
Collaborator

Copy View from a file

bwang-tecoustics
Collaborator
Collaborator

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()
0 Likes
Reply
Accepted solutions (1)
342 Views
1 Reply
Reply (1)

NachitoMax
Advisor
Advisor
Accepted solution

Hi

 

As far as I know, Apprentice doesn't contain any UI capabilities so objects like Drawing Views may not be accessible. You could try opening the drawing instead as invisible

 

Dim InvApplication As Inventor.Application =
    ' System.Runtime.InteropServices.Marshal.
    '  GetActiveObject("Inventor.Application")

Dim sPath As String = "C:/My Folder/ MyDrawing.idw"

Dim oIDW As Inventor.DrawingDocument = InvApplication.Documents.Open(sPath, False)

don't forget to close it after

oIDW.Close
oIDW = nothing

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes