Message 1 of 1
FRONT AND FLAT PATTERNS IN SEPARATE SHEETS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I HAVE A CODE THAT CREATS ALL FLAT PATTERNS IN OF SM IN ASSEMBLY IN EACH SHEETS , I NEED THE FRONT AND SIDE VIEW ALSO ALONG WITH FLATPATTERN
"
Sub Main If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then MsgBox("An Assembly must be active for this rule to work. Exiting.", vbCritical, "iLogic") Exit Sub End If Dim oADoc As AssemblyDocument = ThisDoc.Document Dim sAsmPath As String = System.IO.Path.GetDirectoryName(oADoc.FullFileName) Dim sAsmName As String = System.IO.Path.GetFileNameWithoutExtension(oADoc.FullFileName) Dim sFolder As String = sAsmPath & "\" & sAsmName & " DXF Drawings\" If System.IO.Directory.Exists(sFolder) = False Then Try : System.IO.Directory.CreateDirectory(sFolder) Catch : Logger.Error("Could not create directory.") : End Try End If Dim oRefDocs As DocumentsEnumerator = oADoc.AllReferencedDocuments If oRefDocs.Count = 0 Then Exit Sub Dim sTemplate As String = "C:\Users\fcpl017\Desktop\standard.idw" Dim oDDoc As DrawingDocument = Nothing oDDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, sTemplate, False) Dim oSheets As Inventor.Sheets = oDDoc.Sheets Dim oFirstSheet As Inventor.Sheet = oDDoc.ActiveSheet For Each oRefDoc As Document In oRefDocs 'if this referenced document is not a Sheet Metal part, then skip to next one If oRefDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For 'Dim COUNT_BEND As Integer = oRefDoc.PropertySets.Item(4).Item("BEND_COUNT").Value 'If COUNT_BEND < 1 Then Continue For Dim sPN As String = oRefDoc.PropertySets.Item(3).Item("Part Number").Value 'Dim sCustomPropName As String = "PROJECT PARTNUMBER" 'Dim oCustomSet As Inventor.PropertySet = oRefDoc.PropertySets.Item(4) 'oCustomProp = oCustomSet.Item(sCustomPropName) 'oFileName = oCustomProp.Value Dim oSheet As Inventor.Sheet = Nothing If oFirstSheet.DrawingViews.Count = 0 Then oSheet = oFirstSheet Else oSheet = oSheets.Add() End If Try oSheet.Name = sPN 'oSheet.Name = oFileName Catch End Try Dim oPos As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width / 2, oSheet.Height / 2) Dim dScale As Double = 1 '<<<must compare model size to sheet size for accurate value>>> Dim oVO As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kFlatPivot180ViewOrientation Dim oDVS As DrawingViewStyleEnum = DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap oOptions.Add("SheetMetalFoldedModel", False) oSheet.DrawingViews.AddBaseView(oRefDoc, oPos, dScale, oVO, oDVS, , , oOptions) Next oDDoc.SaveAs(sFolder & "FlatPatterns.idw", False) MsgBox("Exported All FlatPatterns To Drawing Views.", vbInformation, "iLogic") End Sub"