Multi selection and Body selection

Hi

Please help me. How can i use multi face selecting? I probe your codes, but not working. (http://www.nxjournaling.com/?q=content/adding-interactive-selection-rout...)
When i select KF_BOUNDBOX() the journal write this error: System.InvalidCastException:

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim trimSolidBuilder1 As Tooling.TrimSolidBuilder
trimSolidBuilder1 = workPart.ToolingManager.TrimSolid.CreateTrimSolidBuilder()

trimSolidBuilder1.Clearance.RightHandSide = "0.1"

theSession.SetUndoMarkName(markId1, "Trim Solid Dialog")

Dim type1 As Tooling.TrimSolidBuilder.Types
type1 = trimSolidBuilder1.Type

Dim type2 As Tooling.TrimSolidBuilder.Types
type2 = trimSolidBuilder1.Type

Dim faces1(0) As Face
Dim face1 As Face

If SelectPlanarFace("", face1) = Selection.Response.Cancel Then
Exit Sub
End If

faces1(0) = face1
Dim faceDumbRule1 As FaceDumbRule
faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces1)

Dim rules1(0) As SelectionIntentRule
rules1(0) = faceDumbRule1
trimSolidBuilder1.RegionFaces.ReplaceRules(rules1, False)

trimSolidBuilder1.CreateBoundBox()

Dim body1 As Body
If SelectAnObject("", body1) = Selection.Response.Cancel Then
Exit Sub
End If

Dim body2 As Body = CType(workPart.Bodies.FindObject("KF_BOUNDBOX(5)"), Body)

trimSolidBuilder1.SelectBoundBox.Value = body2

Dim objects1(0) As NXObject
objects1(0) = body1
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)

Dim id1 As Session.UndoMarkId
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.AnyVisibility)

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(id1)

Dim nullBody As Body = Nothing

trimSolidBuilder1.SetBoundBox(nullBody)

trimSolidBuilder1.SetManualBody(body2)

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Trim Solid")

Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Create Interference Solid")

theSession.UndoToMarkWithStatus(markId3, Nothing)

theSession.DeleteUndoMarksUpToMark(markId3, Nothing, False)

Dim nXObject1 As NXObject
nXObject1 = trimSolidBuilder1.Commit()

theSession.DeleteUndoMark(markId2, Nothing)

theSession.SetUndoMarkName(id1, "Trim Solid")

trimSolidBuilder1.Destroy()

End Sub

Function SelectAnObject(prompt As String, _
ByRef selObj As NXObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All, _
Selection.SelectionType.Faces, _
Selection.SelectionType.Edges, _
Selection.SelectionType.Features}

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
prompt, "Válassz egy elemet", _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)

If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Function SelectPlanarFace(ByVal prompt As String, ByRef selObj As NXObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Válassz felületet"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(1) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_PLANAR_FACE
End With

With selectionMask_array(1)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_CYLINDRICAL_FACE
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

End Module

I'm not familiar with a KF_BOUNDBOX feature; I assume this is a custom Knowledge Fusion object? This may be the cause of the problem...

Can you email me a sample file that contains one of these objects?
info@nxjournaling.com