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.
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
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
(Not an Autodesk Employee)
With a couple of tweaks to suit my application your solution worked perfectly
Thank you.
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.
Sure. Which way would you prefer the rule to work:
Wesley Crihfield
(Not an Autodesk Employee)
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
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.