Sheet.CopyTo Method

Sheet.CopyTo Method

Anonymous
Not applicable
995 Views
5 Replies
Message 1 of 6

Sheet.CopyTo Method

Anonymous
Not applicable
Hi,
 
I'm trying to use the method Sheet.CopyTo to export each sheet of an Inventor DWG multi-page, but I can not. Error messages are displayed in the annex. At first I thought that this method is only compatible with non-DWG IDW and Inventor. But, I tested the code below into a file IDW and not succeeded.
  
Any suggestions?
  
Public Sub ExportSheets()
 
    Dim oSourceDocument As DrawingDocument
    Set oSourceDocument = ThisApplication.ActiveDocument
   
    Dim oNewDocument As DrawingDocument
    Dim sNewDocument As String
    Dim sNewDocumentPath As String
    Dim sDrawingTemplateFile As String
    sDrawingTemplateFile = "C:\Arquivos de programas\Autodesk\Inventor 2010\Templates\Standard.dwg"
    sNewDocumentPath = "C:\Arquivos de programas\Autodesk\Inventor 2010\Samples\Models\Assemblies\Suspension\"
   
    Dim oSheet As Sheet
    Dim sSheetName As String
    Dim vSheetNameParts As Variant
    For Each oSheet In oSourceDocument.Sheets
        sSheetName = oSheet.Name
        vSheetNameParts = Split(sSheetName, ":")
        sSheetName = vSheetNameParts(0) & "_" & vSheetNameParts(1)
       
        'Criação de novo documento DWG
        sNewDocument = sNewDocumentPath & sSheetName & ".dwg"
  
        'Details: I found that there is an enumerator for Inventor DWG files, just to IDW.
        Set oNewDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, sDrawingTemplateFile, False)


        Call oNewDocument.SaveAs(sNewDocument, False)
        'oNewDocument.Close
        
       'Copy the active sheet - When you run the line under the mistakes happen.
        Call oSheet.CopyTo(oNewDocument)
    Next
   
    MsgBox "Folhas exportadas com sucesso!", vbInformation, "Exportação de Folhas"
End Sub
Thanks,
Ari Monteiro
Dharma Sistemas
0 Likes
996 Views
5 Replies
Replies (5)
Message 2 of 6

YuhanZhang
Autodesk
Autodesk

Does the first Sheet in the oSourceDrawing have AutoCAD Blocks? Note that this is not supported to copy a Sheet with AutoCAD Blocks to another drawing document even via UI operations. You can add a check for the AutoCAD Blocks before copy the sheet to another drawing document.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi,

 

I don't have AutoCAD Blocks in the oSourceDrawing. My DWG files were created fully in Inventor. So, if the problems are AutoCAD Blocks, why this method does't work in IDW files?

 

Thanks,

Ari Monteiro

Skynet

 

 

0 Likes
Message 4 of 6

YuhanZhang
Autodesk
Autodesk

Can you supply a sample document, or snapshot of the sheet?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 6

cburton72
Contributor
Contributor

Have you activated the sheet?

sheet.Activate()

0 Likes
Message 6 of 6

k14348
Advocate
Advocate

Hi,

     When u save copy as multipage idw to acad file it will be saved  each sheet basis only. then y we need this. ex. 

 

-Karth

0 Likes