Face selection problem in NX11 Nxopen

Below code is just for converting solid to sheetmetal by letting user select the face to do the operation. Having the following error on my code. Using NX11 with TC11

Error 1 Overload resolution failed because no accessible 'SelectObject' accepts this number of arguments.

I tried to replace 'SelectObject' with 'SelectTaggedObject' but still don't work. Please suggest what can I do?


Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display
theSession.ApplicationSwitchImmediate("UG_APP_SBSM")

Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Enter Sheet Metal")
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing

Dim convertToSheetmetalBuilder1 As NXOpen.Features.SheetMetal.ConvertToSheetmetalBuilder = Nothing
convertToSheetmetalBuilder1 = workPart.Features.SheetmetalManager.CreateConvertToSheetmetalFeatureBuilder(nullNXOpen_Features_Feature)

convertToSheetmetalBuilder1.SetApplicationContext(NXOpen.Features.SheetMetal.ApplicationContext.NxSheetMetal)

Dim expression1 As NXOpen.Expression = Nothing
expression1 = workPart.Preferences.PartSheetmetal.GetBendReliefDepth()

Dim expression2 As NXOpen.Expression = Nothing
expression2 = workPart.Preferences.PartSheetmetal.GetBendReliefWidth()

Dim nullNXOpen_Features_SketchFeature As NXOpen.Features.SketchFeature = Nothing

convertToSheetmetalBuilder1.Sketch = nullNXOpen_Features_SketchFeature

Dim nullNXOpen_Face As NXOpen.Face = Nothing

convertToSheetmetalBuilder1.BaseFace = nullNXOpen_Face

Dim nullNXOpen_Section As NXOpen.Section = Nothing

convertToSheetmetalBuilder1.RipSection = nullNXOpen_Section

Dim scCollector1 As NXOpen.ScCollector = Nothing
scCollector1 = convertToSheetmetalBuilder1.AdditionalFacesToConvert

Dim expression3 As NXOpen.Expression = Nothing
expression3 = workPart.Preferences.PartSheetmetal.GetBendReliefDepth()

Dim expression4 As NXOpen.Expression = Nothing
expression4 = workPart.Preferences.PartSheetmetal.GetBendReliefWidth()

convertToSheetmetalBuilder1.BendReliefType = NXOpen.Features.SheetMetal.ConvertToSheetmetalBuilder.BendReliefTypeOptions.None

Dim expression5 As NXOpen.Expression = Nothing
expression5 = convertToSheetmetalBuilder1.BendReliefDepth

Dim expression6 As NXOpen.Expression = Nothing
expression6 = workPart.Preferences.PartSheetmetal.GetBendReliefDepth()

Dim name1 As String = Nothing
name1 = expression6.Name

expression5.RightHandSide = name1

Dim expression7 As NXOpen.Expression = Nothing
expression7 = convertToSheetmetalBuilder1.BendReliefWidth

Dim expression8 As NXOpen.Expression = Nothing
expression8 = workPart.Preferences.PartSheetmetal.GetBendReliefWidth()

Dim name2 As String = Nothing
name2 = expression8.Name

expression7.RightHandSide = name2

convertToSheetmetalBuilder1.MaintainZeroBendRadius = False

theSession.SetUndoMarkName(markId2, "Convert to Sheet Metal Dialog")

Dim section1 As NXOpen.Section = Nothing
section1 = workPart.Sections.CreateSection(0.00095, 0.001, 0.01)

Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Convert to Sheet Metal")

theSession.DeleteUndoMark(markId3, Nothing)

Dim markId4 As NXOpen.Session.UndoMarkId = Nothing
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Convert to Sheet Metal")

'Dim brep1 As NXOpen.Features.Brep = CType(workPart.Features.FindObject("UNPARAMETERIZED_FEATURE(14)"), NXOpen.Features.Brep)

'Dim face1 As NXOpen.Face = CType(brep1.FindObject("FACE 3 {(0.75,17.65125,8.6937488451453) UNPARAMETERIZED_FEATURE(14)}"), NXOpen.Face)
Dim face1 As NXopen.face = SelectPlanarFace()

convertToSheetmetalBuilder1.BaseFace = face1

Dim ripEdges1(-1) As NXOpen.Edge
convertToSheetmetalBuilder1.SetRipEdges(ripEdges1)

convertToSheetmetalBuilder1.Sketch = nullNXOpen_Features_SketchFeature

convertToSheetmetalBuilder1.RipSection = section1

convertToSheetmetalBuilder1.MaintainZeroBendRadius = False

Dim builderDataValidity1 As Integer = Nothing
builderDataValidity1 = convertToSheetmetalBuilder1.ValidateBuilderData()

Dim feature1 As NXOpen.Features.Feature = Nothing
feature1 = convertToSheetmetalBuilder1.CommitFeature()

theSession.DeleteUndoMark(markId4, Nothing)

theSession.SetUndoMarkName(markId2, "Convert to Sheet Metal")

convertToSheetmetalBuilder1.Destroy()

section1.Destroy()

End Sub

Function SelectPlanarFace() As Face

Dim ui As UI = ui.GetUI
Dim title As String = "Select a planar face"
Dim message As String = "Selection"
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.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

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

'Problem in this line below

Dim resp As Face = ui.SelectionManager.SelectObject(message, title, scope, selAction, includeFeatures, keepHighlighted, selectionMask_array, cursor)

If resp Is Nothing Then
Return Nothing
End If

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module

I think trying to cast the selection response to face in this line causes the problem. It should be selection response and the response by reference it will be planar face.

Dim resp As Face = ui.SelectionManager.SelectObject(message, title, scope, selAction, includeFeatures, keepHighlighted, selectionMask_array, cursor)

I didn't tested since I don't have NX 11, Hope this works

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI

Module NXJournal

Sub Main(ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display
theSession.ApplicationSwitchImmediate("UG_APP_SBSM")

Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Enter Sheet Metal")
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing

Dim convertToSheetmetalBuilder1 As NXOpen.Features.SheetMetal.ConvertToSheetmetalBuilder = Nothing
convertToSheetmetalBuilder1 = workPart.Features.SheetmetalManager.CreateConvertToSheetmetalFeatureBuilder(nullNXOpen_Features_Feature)

convertToSheetmetalBuilder1.SetApplicationContext(NXOpen.Features.SheetMetal.ApplicationContext.NxSheetMetal)

Dim expression1 As NXOpen.Expression = Nothing
expression1 = workPart.Preferences.PartSheetmetal.GetBendReliefDepth()

Dim expression2 As NXOpen.Expression = Nothing
expression2 = workPart.Preferences.PartSheetmetal.GetBendReliefWidth()

Dim nullNXOpen_Features_SketchFeature As NXOpen.Features.SketchFeature = Nothing

convertToSheetmetalBuilder1.Sketch = nullNXOpen_Features_SketchFeature

Dim nullNXOpen_Face As NXOpen.Face = Nothing

convertToSheetmetalBuilder1.BaseFace = nullNXOpen_Face

Dim nullNXOpen_Section As NXOpen.Section = Nothing

convertToSheetmetalBuilder1.RipSection = nullNXOpen_Section

Dim scCollector1 As NXOpen.ScCollector = Nothing
scCollector1 = convertToSheetmetalBuilder1.AdditionalFacesToConvert

Dim expression3 As NXOpen.Expression = Nothing
expression3 = workPart.Preferences.PartSheetmetal.GetBendReliefDepth()

Dim expression4 As NXOpen.Expression = Nothing
expression4 = workPart.Preferences.PartSheetmetal.GetBendReliefWidth()

convertToSheetmetalBuilder1.BendReliefType = NXOpen.Features.SheetMetal.ConvertToSheetmetalBuilder.BendReliefTypeOptions.None

Dim expression5 As NXOpen.Expression = Nothing
expression5 = convertToSheetmetalBuilder1.BendReliefDepth

Dim expression6 As NXOpen.Expression = Nothing
expression6 = workPart.Preferences.PartSheetmetal.GetBendReliefDepth()

Dim name1 As String = Nothing
name1 = expression6.Name

expression5.RightHandSide = name1

Dim expression7 As NXOpen.Expression = Nothing
expression7 = convertToSheetmetalBuilder1.BendReliefWidth

Dim expression8 As NXOpen.Expression = Nothing
expression8 = workPart.Preferences.PartSheetmetal.GetBendReliefWidth()

Dim name2 As String = Nothing
name2 = expression8.Name

expression7.RightHandSide = name2

convertToSheetmetalBuilder1.MaintainZeroBendRadius = False

theSession.SetUndoMarkName(markId2, "Convert to Sheet Metal Dialog")

Dim section1 As NXOpen.Section = Nothing
section1 = workPart.Sections.CreateSection(0.00095, 0.001, 0.01)

Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Convert to Sheet Metal")

theSession.DeleteUndoMark(markId3, Nothing)

Dim markId4 As NXOpen.Session.UndoMarkId = Nothing
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Convert to Sheet Metal")

'Dim brep1 As NXOpen.Features.Brep = CType(workPart.Features.FindObject("UNPARAMETERIZED_FEATURE(14)"), NXOpen.Features.Brep)

'Dim face1 As NXOpen.Face = CType(brep1.FindObject("FACE 3 {(0.75,17.65125,8.6937488451453) UNPARAMETERIZED_FEATURE(14)}"), NXOpen.Face)
Dim face1 As NXOpen.Face = Nothing

SelectFace("Select Planar Face", face1)

convertToSheetmetalBuilder1.BaseFace = face1

Dim ripEdges1(-1) As NXOpen.Edge
convertToSheetmetalBuilder1.SetRipEdges(ripEdges1)

convertToSheetmetalBuilder1.Sketch = nullNXOpen_Features_SketchFeature

convertToSheetmetalBuilder1.RipSection = section1

convertToSheetmetalBuilder1.MaintainZeroBendRadius = False

Dim builderDataValidity1 As Integer = Nothing
builderDataValidity1 = convertToSheetmetalBuilder1.ValidateBuilderData()

Dim feature1 As NXOpen.Features.Feature = Nothing
feature1 = convertToSheetmetalBuilder1.CommitFeature()

theSession.DeleteUndoMark(markId4, Nothing)

theSession.SetUndoMarkName(markId2, "Convert to Sheet Metal")

convertToSheetmetalBuilder1.Destroy()

section1.Destroy()

End Sub

Function SelectFace(ByVal prompt As String, ByRef SelFace As Face) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select Planar Face"
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(0) As Selection.MaskTriple

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

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt,
title, scope, selAction,
includeFeatures, keepHighlighted, selectionMask_array,
SelFace, 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

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module

Regards,

Joe

Thanks a lot Joe. It really worked!

Best Regards,

Fathmi

Regards,
MFJ