Nevermind I found the issue. This line is supposed to be a comment:
Check For derived part parent To Get features
Should be:
'Check For derived part parent To Get features
That should be all you need, but here is the SM Bundle Sub:
Sub SM_Bundle(PassDoc As PartDocument)
'local sheet metal part rule. No document type or subtype checking checking
Dim oDoc As PartDocument = PassDoc
Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
'Update to pick up derived part changes
oDoc.Update
'define the property set
Dim userParams As UserParameters = oDoc.ComponentDefinition.Parameters.UserParameters
Try
BendRadius_Parm = oDoc.ComponentDefinition.Parameters("BendRadius_Ilogic")
Catch
Dim newParam As UserParameter = userParams.AddByExpression("BendRadius_Ilogic", 1, "mm")
End Try
'Set Object to collect values to names
Dim PropList As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
PropList.Add("Lengte", 20.5)
PropList.Add("Breedte", 10.5)
PropList.Add("Thickness", 1.5)
PropList.Add("Profile", "Empty String")
Logger.Debug("Setup NameValueMap 1")
'Fill values based on whether or not there is a derived part
If oCompDef.HasFlatPattern = True
Logger.Debug("HasFlatPattern")
PropList.Value("Lengte") = (Round(oCompDef.FlatPattern.Length*10,0))
PropList.Value("Breedte") = (Round(oCompDef.FlatPattern.Width*10, 0))
PropList.Value("Thickness") = oCompDef.Parameters("Thickness").Value*10
PropList.Value("Profile") = "SM " & PropList.Value("Lengte") & "x" & PropList.Value("Breedte") & "x" & PropList.Value("Thickness")
Logger.Debug("existing FlatPattern Values: " & PropList.Value("Profile"))
Else
Logger.Debug("Not HasFlatPattern")
oCompDef.Unfold
Logger.Debug("Open Part is Unfolded")
oDoc.Update
Logger.Debug("Open Part is Updated")
'oDoc.Save
'Logger.Debug("Open Part is Saved")
PropList.Value("Lengte") = (Round(oCompDef.FlatPattern.Length*10, 0))'FindMax(oCompDef.RangeBox, "L")
PropList.Value("Breedte") = (Round(oCompDef.FlatPattern.Width*10, 0))'FindMax(oCompDef.RangeBox, "W")
PropList.Value("Thickness") = oCompDef.Parameters("Thickness").Value*10
PropList.Value("Profile") = "SM " & PropList.Value("Lengte") & "x" & PropList.Value("Breedte") & "x" & PropList.Value("Thickness")
Logger.Debug("local-new FlatPattern Values: " & PropList.Value("Profile"))
oCompDef.FlatPattern.ExitEdit
Logger.Debug("Open Part is Refolded")
End If
'Set iProperties
Dim CustProps As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
For i = 1 To PropList.Count
Try
CustProps.Item(PropList.Name(i)).Expression = PropList.Value(PropList.Name(i))
Catch
CustProps.Add(PropList.Value(PropList.Name(i)), PropList.Name(i))
End Try
Next
'Check For derived part parent To Get features
If oCompDef.ReferenceComponents.DerivedPartComponents.Count > 0
Logger.Debug("DerivedPartComponents Count > 0")
Dim ParentDef As SheetMetalComponentDefinition = Nothing
For Each RefDoc As Document In oDoc.ReferencedDocuments
Logger.Debug("DerivedPartComponent Loop")
If RefDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
Logger.Debug("Derived Comp Is SM")
ParentDef = RefDoc.ComponentDefinition
Exit For
End If
Next
'I'm running the Passed sheet metal document by itself now since none of the derived components were sheetmetal parts
If IsNothing(ParentDef)
Logger.Debug("No Derived Part was a Sheet Metal Part")
Call SheetMetal_Hole(oDoc, oDoc)
Logger.Debug("Completed SheetMetal_Hole on open document")
Call Events(oDoc)
Exit Sub
End If
Call SheetMetal_Hole(ParentDef.Document, oDoc)
Logger.Debug("Completed SheetMetal_Hole on parent document")
Else
Logger.Debug("DerivedPartComponents Count <= 0")
Call SheetMetal_Hole(oDoc, oDoc)
Logger.Debug("Completed SheetMetal_Hole on open document")
End If
Call Events(oDoc)
End Sub
Let me know how that goes