OK, here's my example of what I'm trying to understand if anybody wants to chime-in on it. I annotated it the way I understand what's going on, but I may be WRONG and also there's things I don't understand:
'Export all flatpatterns out to disk as DXF into the local folder specified below
'START WITH ASSEMBLY FILE
'Define 'oDoc' variable as assembly component
Dim oDoc As AssemblyDocument
'Assign to 'oDoc' variable the open iam file
oDoc = ThisApplication.ActiveDocument
'VERIFY THAT AN ASSEMBLY FILE IS OPEN
'Check that the active document is an assembly file, and if not, then notify the user to open an assembly file
If oDoc.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If
'USER INPUT
'Verify user wants to run macro or terminate it
RUsure = MessageBox.Show ( _
"This will create a DXF file for all of the asembly components that are sheet metal." _
& vbLf & "This rule expects that the part file is saved." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DXF for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output DXFs ", MessageBoxButtons.YesNo)
If RUsure <> vbYes Then Exit Sub
'GET THE NAME OF THE OPENED ASSEMBLY FILE AND ITS DIRECTORY SO IT CAN BE USED IN THE SUB-DIRECTORY NAME AND DXF FILE NAMES
'Define 'oAsmName' variable as text string & assign to 'oAsmName' variable the open iam filename minus the last 4 characters on the r.h. end
Dim oAsmName As String = Left(oDoc.DisplayName, Len(oDoc.DisplayName) - 4)
'Define 'oPath' variable as text string & assign to 'oPath' variable the open iam file's full path name
Dim oPath As String = ThisDoc.Path
'Define 'oFolder' variable as text string & assign to 'oFolder' variable the path name below ("oPath\oAsmName DXF Files")
Dim oFolder As String = oPath & "\" & oAsmName & " DXF Files"
'Check for the existence of the DXF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'- - - - - - - - - - - - - BEGIN WORKING AT THE PART LEVEL - - - - - - - - - - - -
'USE THE ASSEMBLY'S BOM TO TO GET THE PART INFORMATION
'Define 'oBOM' variable as BOM component
Dim oBOM As BOM
'Assign to 'oBOM' variable the opened iam BOM ???????????????
oBOM = oDoc.ComponentDefinition.BOM
'What does the "." mean in the above word (oDoc.ComponentDefinition.BOM) ????????????????????
'Look at BOM as a Structured BOM ???????????????????????????
oBOM.StructuredViewEnabled = True
'START FILTERING OUT THE PARTS LISTED IN THE BOM TO ONLY SHEETMETAL PARTS
'Define 'oBOMView' variable as BOMView component ?????????????????? and assign to 'oBOMView' variable the BOM Item# ????????????????
Dim oBOMView As BOMView = oBOM.BOMViews.Item(oBOM.BOMViews.Count)
'Begin process of recursing BOM records (rows) from beginning to end
For Each oRow As BOMRow In oBOMView.BOMRows
Try
'Define 'oCD' variable as ipt and assign to 'oCD' variable the model tree name shown in the BOM Item#
Dim oCD As ComponentDefinition = oRow.ComponentDefinitions.Item(1)
'Define 'iDoc' variable as Iventor document and assign to 'iDoc' variable the BOM Item#
Dim iDoc As Document = oCD.Document
'Filter out all but sheetmetal parts in the recursive BOM procedure above
If iDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
'Where did you get that sheetmetal file i.d. number ??????????????????
'Define 'iName' variable to a text string and assign to 'iName' variable the part's BOM Item# full filename
Dim iName As String = iDoc.FullFileName
'Check that model is saved and has a filename ???????????????????
If iName = vbNullString Then Continue For
'Assign to 'iDoc' variable the open ipt file
iDoc = ThisApplication.Documents.Open(iName)
'Assign to 'oCD' variable the open ipt file's "ComponentDefnintion" ?????????
oCD = iDoc.ComponentDefinition
'Define 'oMARK' variable as a text string and assign to 'oMARK' variable the open ipt file's BOM Item#
Dim oMARK As String = oRow.ItemNumber
'MessageBox.Show("oMark: " & oMARK)
'Test that file to see if it has a flatpattern already created
Try
'If that file does NOT have a flatpattern already created, then create one
If Not oCD.HasFlatPattern Then
oCD.Unfold()
Else
'But if the open file already has a flatpattern, then start editing it
oCD.FlatPattern.Edit()
End If
'Define 'sOut' variable as a text string and assign to 'sOut' variable the below name/string ("FLAT PATTERN DXF + ??????????????") What's "?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PROFILE" mean ??????????????
Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PROFILE" 'What is the PURPOSE of this name/string ???????????????
'Create DXF file from the open part's flatpattern file to the below named filename ("oFolder\oAsmName - MARK oMARK.dxf") I also want to add the thickness followed by " THK".
oCD.DataIO.WriteDataToFile(sOut, oFolder & "\" & oAsmName & " - MARK " & oMARK & ".dxf")
'Exit editing of flatpattern
oCD.FlatPattern.ExitEdit()
'What is this? What does it do ???????????????????????????
Catch ex As Exception
MsgBox(ex.Message)
'End Test of all files and creation of flatpattern DXF files
End Try
'Close the open file
iDoc.Close(True)
Catch
End Try
'Open the next ipt sheetmetal file in the BOM and process it like before
Next
I believe I got that code from 'Owner' in another link. Thanx buddy!
I tried a number of things to get the Stock Number iProperty to replace the Item Number BOM iProperty, but it always used only the assembly Stock Number, not the individual files Stock Number. So that's one thing I need: How do I get the Stock Number from the individual files into their DXF filename?
Very frustrated! I spent 2 whole days trying things, and looking on the Internet for answers, but no success. This programming is a MEGA PITA due to the total and complete lack of structured information for NOOBIES like me. I have 2 feet of books on my shelf behind me that I used to use for AutoLISTP and DIESEL. So whenever I needed to look up a command I forgot, or a function I couldn't remember, or the syntax of something, or DXF codes OR WHATEVER, I had those references at my fingertips. And I rarely had any problems ferreting out code.
But with this iLogic scheme, I don't have even one book to help me like that. Moreover, and all the so-called references on the Autodesk Help site are very difficult to find information in. It's like trying to get answers out of the damned IRS, for God's sake!
Anyways, if someone can find it in their heart of hearts to either tell me how to do this b.s. AND show me where the REAL reference books are for all this code nonsense, or just steer me to those reference books, I'd appreciate it.
Thanx ...
... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator