cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I need to be able to copy a drawing sheet into the same drawing

I need to be able to copy a drawing sheet into the same drawing

I have a sheet in a .idw that i want to copy into the same .idw.  That way I don't have to readd all the notes and symbols i have placed on the sheet. 

 

40 Comments
jason_bush
Enthusiast

One of our guys on staff tweaked a pretty slick piece of iLogic code to duplicate sheets. We are a curtainwall manufacturer. So we tend to duplicate a lot of sheets where our 3D frames will be identical, but differ just by notes on the drawings for glass types and such. Code starts with your selected sheet, then a window opens for you to select the same model from the sheet you want to duplicate. After selecting, the sheet dupes and keeps all existing annotations. At it's core, I think it is just doing a Replace Model Reference to create the dupe. Good luck!

 

Sub Main()
	'Set Number of Addresses for Unit in Overall Assembly
	Dim NumberOfUnits = 1

	'Check that we are in a drawing document.
    If ThisDoc.Document.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
        'Get a reference to the current drawing.
        Dim dwgDoc As DrawingDocument = ThisDoc.Document
        
        'Check that we have atleast one view on the sheet.
        If dwgDoc.ActiveSheet.DrawingViews.Count > 0 Then
            
            'Get a reference to the original model in the view.
			Dim compDoc As Document = dwgDoc.ActiveSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
            
            'Get the filename of the replacement model
            Dim newFileName As String = GetNewReference() 'Sub to show dialog and get file name.
            
            'Open the replacement model.
            Dim newFile As Document
            If Not String.IsNullOrEmpty(newFileName) Then
			'If Not String.IsNullOrEmpty(compDoc) Then
                Try
                    newFile = ThisApplication.Documents.Open(newFileName, False)
					'newFile = ThisApplication.Documents.Open(compDoc, False)
                Catch
                    MessageBox.Show("Could not open target file.")
                End Try
                
                'Check to see if we have valid documents to work with.
                If Not newFile Is Nothing Then
                    Dim okContinue As Boolean = True
                    If Not newFile.InternalName = compDoc.InternalName Then
                        'Display warning if inner names of models do not match.
                        msgResult = MessageBox.Show("Warning, files do not match." & vbCrLf & " Results can be unpredictable." & vbCrLf & _
                            "Do you want To Continue", "Copy/Replace Sheet", MessageBoxButtons.YesNo)
                        If Not msgResult = DialogResult.Yes Then
                            okContinue = False
                        End If
                    End If
                    If okContinue Then
                        Dim newDwg As DrawingDocument
                        Try
                            'Create the new drawing document.
                            newDwg = ThisApplication.Documents.Add(kDrawingDocumentObject, Nothing, False)
                            							
                            'Copy the active sheet to the new document.
                            Dim newSheet As Sheet = dwgDoc.ActiveSheet.CopyTo(newDwg)
                            
                            'Replace the model reference on the new sheet with the replacement reference
                            newSheet.DrawingViews(1).ReferencedDocumentDescriptor. _
                            ReferencedFileDescriptor.ReplaceReference(newFileName)
							
'							'rename Active Sheet to Unit Address
'							dwgDoc.ActiveSheet.Name = InputBox("Enter Unit Address", "Unit Address")
'							UpdateUnitAddress()
							
							Dim i As Long = 0
							For i = 1 To NumberOfUnits
	                            'Copy the sheet back to the original drawing.
	                            Dim copiedSheet As Sheet = newSheet.CopyTo(dwgDoc)
'								copiedSheet.Name = InputBox("Enter Unit Address", "Unit Address")
								copiedSheet.Activate()
'								UpdateUnitAddress()
							Next
	                        newDwg.Close(True)
                            'Activate the new sheet.
	                        'copiedSheet.Activate()
                            
							InventorVb.DocumentUpdate()
                        Catch
                            MessageBox.Show("Error occurred copying sheet.")
                        End Try
                    End If
                End If
            End If
        End If
    End If
'	iLogicVb.RunRule("ResetSectionViewCallout_Rule")
End Sub
 
'Function UpdateUnitAddress() As String
'	Dim dwgDoc As DrawingDocument = ThisDoc.Document
'	Dim oPromptEntry
'	Dim actSheet As Sheet = ThisApplication.ActiveDocument.ActiveSheet
'    ActiveSheet = ThisDrawing.Sheet(actSheet.Name)
'    oTitleBlock=actSheet.TitleBlock
'    oTextBoxes=oTitleBlock.Definition.Sketch.TextBoxes
'    For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
'			Select oTextBox.Text
'				Case "<Unit Address>":
'					oPromptEntry = dwgDoc.ActiveSheet.Name
'						Dim sSplit As String() = oPromptEntry.Split(New Char() {":"c})
'						'get the first member of array
'						oPromptEntry = sSplit(0)
'					Call oTitleBlock.SetPromptResultText(oTextBox, oPromptEntry)
'					'MessageBox.Show("Phase2.")
'			End Select
'    Next
'	InventorVb.DocumentUpdate()
'End Function

Function GetNewReference() As String
    ' Create a new FileDialog object.
    Dim oFileDlg As Inventor.FileDialog
    Call ThisApplication.CreateFileDialog(oFileDlg)

    ' Define the filter to select part and assembly files or any file.
    oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"

    ' Define the part and assembly files filter to be the default filter.
    oFileDlg.FilterIndex = 1

    ' Set the title for the dialog.
    oFileDlg.DialogTitle = "Copy/Replace Sheet - Select Replacement Model"

    ' Set the initial directory that will be displayed in the dialog.
    oFileDlg.InitialDirectory = ThisDoc.Path

    ' Set the flag so an error will be raised if the user clicks the Cancel button.
    oFileDlg.CancelError = True

    ' Show the open dialog.  The same procedure is also used for the Save dialog.
    ' The commented code can be used for the Save dialog.
    Try
        oFileDlg.ShowOpen
    Catch
        'MessageBox.Show("User cancelled out of dialog", "Replace Reference")
    Finally
        If Not oFileDlg.FileName = "" Then
            'MessageBox.Show("File " & oFileDlg.FileName & " was selected.", "Replace Reference")
            GetNewReference = oFileDlg.FileName
        End If
    End Try
End Function


Sorry can't mention names for the Kudos. He said he found the code posted somewhere, and just modified it for our assemblies. So if any of this code looks like your handiwork...post your name and I'll give the KUDOS!!! Great time-saver for us.

Jason

leowarren34
Mentor

@jason_bush 

That code looks brilliant, when I run it, I'll give my feedback...

BlueWater-Mesick
Explorer

Years ago, I also suggested this on the Augi Wish List 

AW-WIFO
Explorer

Add the function to Copy - Paste a sheet in same Drawing file

sarndahl
Contributor

I totally agree. In the meantime you can use the workaround and paste it to another drawing and then back.

Pate.MacKenna
Enthusiast

This idea is already on the board HERE.  I recommend that these be merged.

LSKELLY
Enthusiast

If you are familiar with creating iLogic rules, you can paste this code into an iLogic rule and run it. It should duplicate your drawing sheets.

 

Dim oDoc = ThisApplication.ActiveEditDocument
Dim oSheet = oDoc.ActiveSheet
Dim oNewDrawDoc As DrawingDocument

oNewDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, , False)
Dim oNewSheet = oSheet.CopyTo(oNewDrawDoc)
Dim oNewSheet2 = oNewSheet.CopyTo(oDoc)

 

- Lance 

DanielLutz
Autodesk

There are situations where you need a complete sheet with all views again, e.g. to create a different dimensioning or labeling for another manufacturing process. Unfortunately this is not possible in the current version. You have to create the views again on a new sheet.

benny_wellekens
Advocate

There is a workaround:

Right click on the sheet and choose "Copy".

Open a new drawing, right click in browser en choose "Paste".

Then Copy/Paste from the new drawing to the original one.

 

It would indead be easier if one could copy/paste sheets whitin the drawing itself as you suggested.

 

 

johnmondro4888
Advocate

Software like, oh - Coreldraw does this (and had since, um - it's inception.) But our high-end mechanical design software can't. Hmmm. One of those "two steps forward, one step back" Inventor things I guess.

 

Oh, and "copy, open another sheet, paste, copy, paste" is a workaround. A laughable, time-consuming workaround. @jason_bush , thanks for posting the iLogic here - will definitely give it a try. Our industry has the same challenges with similar (or identical) notes on multiple sheets.

stuartmp
Advocate
You can do it through VBA code no problem
AMN3161
Advocate

I would like to be able to copy and paste a sheet within the same drawing, rather than needing to open a separate drawing to copy to, then to copy from that new drawing back to the original. When i first realized this i assumed it was a bug but then the problem persisted for years

Tags (1)
frederikthorsted
Explorer

Hi

As a workaround you can use the macro linked here:

https://knowledge.autodesk.com/support/inventor/learn-explore/caas/sfdcarticles/sfdcarticles/How-to-...

 

Sub IDW_DuplicateSheet()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim tmpDoc As DrawingDocument
Set tmpDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, , True)


Dim newSheet As Sheet
Set newSheet = oDoc.ActiveSheet.CopyTo(tmpDoc)

Call newSheet.CopyTo(oDoc)

tmpDoc.Close (True)

End Sub

 

mcgyvr
Consultant
dan_szymanski
Autodesk
Status changed to: Accepted
 
dan_szymanski
Autodesk
Status changed to: Implemented

This idea has been implemented within Autodesk Inventor 2021.2. You can now copy a drawing sheet into the same drawing. A right click contextual copy & paste operation, as well as Ctrl+C & Ctrl+V shortcut operations, are both supported. Special thanks to everyone who cast a vote for it.

Pate.MacKenna
Enthusiast
Yee ha!
peter.kapitola
Advocate

There is a simple way to do it and it doesn't involve any code! But it's not obvious. Explanation here:  https://forums.autodesk.com/t5/inventor-forum/copy-and-pasting-a-sheet-in-a-2019-drawing/m-p/1181190...

davin_hayesRAAY5
Observer

10 years and still nothing?

dan_szymanski
Autodesk

@davin_hayesRAAY5 ,

Please see my comment added 4 years ago on 11-16-2020. This one has been addressed.

Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea