- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Guys,
I have this code (under picture), I got from @FINET_Laurent , which creates PDF and DXF of my drawings and place them in the right folders. It's working fine.
But I would like to have the sheet metal parts created from the "save copy as", as in the picture below.
I found a code that could do exactly this, (last code).
I would like to have these codes merged somehow, so when I use the rule it shall generate PDF and DXF as it already does, but if there's sheet metal parts in the drawing, then they should be generated as shown in the picture. And place them in the correct folders, like in the first code.
I hope it makes sence 😊
Dim actDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument Dim file As String = actDoc.FullFileName 'full drawing path Dim name As String = actDoc.DisplayName 'drawing name Dim dir As String = "03. Native" Dim targetDir As String = "01. PDF" Dim s As String = Left(file, file.Length - (dir.Length + (name.Length + 4)) -1) '-1 for \ Dim pdfname As String = name & ".pdf" Dim pdfdoc As String = s & targetDir & "\" & pdfname ThisDoc.Launch(pdfdoc)
Dim oDoc As Document = ThisApplication.ActiveDocument 'Get active document
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub 'Drawings only
For Each oModel As Document In oDoc.ReferencedDocuments 'Loop through all referenced documents
'Sheet metal parts only
If oModel.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
Dim oSMCD As SheetMetalComponentDefinition = oModel.ComponentDefinition
If Not oSMCD.HasFlatPattern Then 'If it doesn't have a flat patter, create one (unfold the model)
oSMCD.Unfold()
oSMCD.FlatPattern.ExitEdit()
End If
Dim FName As String = oModel.FullFileName 'Get the document's path and name
FName = Microsoft.VisualBasic.Left(FName, Len(FName) - 4) & ".dxf"
Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=R12" 'Export settings
Try
oSMCD.DataIO.WriteDataToFile(sOut, FName) 'Export
Catch
End Try
Next
Solved! Go to Solution.