Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic - copy drawing sheet from one drawing to another

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
shaun59G6W
1763 Views, 6 Replies

Ilogic - copy drawing sheet from one drawing to another

Good Day,

 

Is there a way to copy a drawing sheet to a main drawing.

I would like my main drawing to be a machine GA,  but from this drawing I would like to run a rule to search for the shop detailing drawings and copy their relevant sheets to my main GA drawing to create an all in one drawing file.

 

Is there a way to do this silently (without visibly opening the the shop detail drawing)?

 

Thank you.

6 REPLIES 6
Message 2 of 7
WCrihfield
in reply to: shaun59G6W

Here's one way of doing it.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oOtherDocPath As String = "C:\Temp\MasterDrawing.idw"
Dim oOtherDrawing As DrawingDocument = ThisApplication.Documents.Open(oOtherDocPath,False)
For Each oSheet As Sheet In oDDoc.Sheets
	If oSheet.Name.Contains("Shop") Then
		oSheet.CopyTo(oOtherDrawing)
	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7
shaun59G6W
in reply to: WCrihfield

 

With a couple of tweaks to suit my application your solution worked perfectly

Thank you.

Message 4 of 7
denis.semeniuc
in reply to: WCrihfield

Hi, 

 

It is possible to change:

from: adresse  fixe

to: Open drawing

 

I like to copy sheets from tamplate withs notes and details to new drawing

Thanks.

 

Message 5 of 7
WCrihfield
in reply to: denis.semeniuc

Sure.  Which way would you prefer the rule to work:

  • The 'new' drawing will be the 'active' drawing when you run the rule, then you open the template drawing (using open dialog) and copy sheets from the template into the new/active drawing.
  • The template drawing will be the 'active' drawing when you run the rule, then you open the 'other' drawing (using open dialog), and copy the sheets from the template to the 'other' drawing.
  • The 'new' drawing will be the 'active' drawing when you run the rule, and the template file's full file name is hard coded into the rule (no open dialog needed), so it will invisibly open the template in the background, and copies the sheets to the active drawing.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7
denis.semeniuc
in reply to: WCrihfield

le chois #3 et prefereble.
Quand je suis dans nouv dessin et execut la regle, les pages nomée va apparetre sur mon nouv dessin.
Message 7 of 7
WCrihfield
in reply to: denis.semeniuc

Here is a similar iLogic rule that will either silently open the template drawing, without using an open file dialog, or can use the open file dialog, depending on which lines you leave commented out.  If not using the open file dialog, make sure the path and name of the template drawing are correct in the rule before running it.  Since I am not sure which 'named' sheets you want to copy over, I removed the 'filter' question, and the code will now try to copy all sheets over.  If you need it to be more specific, I would need to know how to filter for which sheets to copy.  If there is a list of specific sheet names, we could include them into the rule, as the filter.

 

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
		MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
		Exit Sub
	End If
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim sTemplatesPath As String = ThisApplication.DesignProjectManager.ActiveDesignProject.TemplatesPath
	Dim sTemplateFile As String = sTemplatesPath & "\Drawing.idw" '<<< EDIT THIS >>>>
	'Dim sTemplateFile As String = BrowseForDrawing 'calls the custom Function below
	'If sTemplateFile = "" Then Exit Sub
	Dim oTemplate As DrawingDocument = ThisApplication.Documents.Open(sTemplateFile, False)
	For Each oSheet As Sheet In oTemplate.Sheets
		oSheet.CopyTo(oDDoc)
	Next
	oDDoc.Update2(True)
End Sub

Function BrowseForDrawing() As String
	Dim oFileDialog As Inventor.FileDialog
	ThisApplication.CreateFileDialog(oFileDialog)
	oFileDialog.DialogTitle = "Select Source Template Drawing."
	oFileDialog.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
	oFileDialog.Filter = "Autodesk Inventor Drawings (*.dwg;*.idw) | *.dwg;*.idw"
	oFileDialog.MultiSelectEnabled = False
	oFileDialog.OptionsEnabled = False
	oFileDialog.CancelError = True
	oFileDialog.InsertMode = False
	Try
		oFileDialog.ShowOpen
	Catch
	End Try
	Return oFileDialog.FileName
End Function

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

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

Post to forums  

Autodesk Design & Make Report