iLogic Rule for BOM

iLogic Rule for BOM

Anonymous
Not applicable
847 Views
2 Replies
Message 1 of 3

iLogic Rule for BOM

Anonymous
Not applicable

Hi,

 

i'm new to ilogic but have been trying to write a couple of rules to improve productivity to create custom BOMs based on Excel template. I have been piecing together code and so it's working okay. I am however stuck on extracting bend counts of sheetmetal parts in my assembly. Whilst there are snippets to get number of bends, I cant find a snippet to get this info on parts from within an assembly. Below is a modified version from Clint Browns code that I've been trying to adapt for my purposes.  o7 is my new variable to hold bend counts.

Can anyone help me with this ?

 

' Acknowledgement to Clint Brown for the original ilogic snippet

Dim doc = ThisDoc.Document 
If doc.DocumentType = kAssemblyDocumentObject Then
Else
Return
End If

'Create Text file BOM of current open assembly
oWrite = IO.File.CreateText(ThisDoc.PathAndFileName(False) & ".txt")
oWrite.WriteLine("----------------------------------- Bill of Materials ----------------------------------------")
oWrite.WriteLine("")
oWrite.Close()

SheetMetalCheckGUID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" ' This is the Sheet Metal unique identifier
'Iterate through the Assembly to find Sheet Metal parts

Dim oAssyDoc As AssemblyDocument
Dim oCompOccEnum As ComponentOccurrencesEnumerator
Dim oCompOcc As ComponentOccurrence
oAssyDoc = ThisApplication.ActiveDocument
oCompOccEnum = oAssyDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oAssyDoc.ComponentDefinition)

For Each oCompOcc In oCompOccEnum
	If oCompOcc.Definition.Document.SubType = SheetMetalCheckGUID Then 'Check for Sheet Metal parts
		Try
			'Set up properties To Write To the BOM
			o1 = oCompOcc.Name & " : " & iProperties.MaterialOfComponent(oCompOcc.Name)
			o2 = " -- Part Number: " & iProperties.Value(oCompOcc.Name, "Project", "Part Number")
			o3 = " -- Mass: " & iProperties.MassOfComponent(oCompOcc.Name)
			o4 = " -- Material: " & iProperties.MaterialOfComponent(oCompOcc.Name)
			o5 = " -- Thickness: " & Parameter(oCompOcc.Name, "Thickness")
			o6 = "--" & iProperties.MaterialOfComponent(oCompOcc.Name)
			'Dim o7 As SheetMetalComponentDefinition 
			'o7 = "-- Bends in (if sheetmetal) part" & oCompOcc.FlatPattern.FlatBendResults 			
			'MessageBox.Show(oAssyDoc.Bends.Count)
			
			oInfo = o1 & o2 & o3 & o4 & o5 & o7
			
			Dim oAppend As System.IO.StreamWriter 'Update Txt BoM
			oAppend = IO.File.AppendText(ThisDoc.PathAndFileName(False) & ".txt")
			oAppend.WriteLine(oInfo)
			oAppend.Flush()
			oAppend.Close()			
		Catch
			MessageBox.Show("Oh Snap!", "@ClintBrown3D")
						
		End Try
		
	End If

Next

ThisApplication.StatusBarText = "Unoffical Inventor - Sheet Metal BoM Export Successful"
i = MessageBox.Show("Would you like to see the Parts List?", "Unofficial Inventor", MessageBoxButtons.YesNo)
If i = vbYes Then 
	ThisDoc.Launch(ThisDoc.PathAndFileName(False) & ".txt")	
	Else 
		Return 
		End If

 

 

0 Likes
Accepted solutions (1)
848 Views
2 Replies
Replies (2)
Message 2 of 3

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

If oCompOcc.Definition.HasFlatPattern=True Then
o7 = "-- Bends in (if sheetmetal) part" & oCompOcc.Definition.FlatPattern.FlatBendResults.Count
End If

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you Krieg.

That worked a treat. 

0 Likes