Below is the recorded journal with added function for Selecteion of multiple edges, but can't figure out how the user selected edges will be linked to the delete face command. Can anyone help? Thanks in advanced...
Imports System
Imports NXOpen
Imports System.Collections.Generic
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
Dim mySelectedObjects As NXObject()
Dim theUI As UI = UI.GetUI()
If SelectmultiObjects("Hey, select multiple somethings", mySelectedObjects) = Selection.Response.Ok Then
End If
Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing
Dim deleteFaceBuilder1 As NXOpen.Features.DeleteFaceBuilder = Nothing
deleteFaceBuilder1 = workPart.Features.CreateDeleteFaceBuilder(nullNXOpen_Features_Feature)
Dim faces1(0) As NXOpen.Face
Dim bodyFeature1 As NXOpen.Features.BodyFeature = CType(workPart.Features.FindObject("SB_MIGRATED_GROUND_PANEL(104)"), NXOpen.Features.BodyFeature)
Dim face1 As NXOpen.Face = CType(bodyFeature1.FindObject("FACE 60 {(9.875,13.9,-0.06) SB_MIGRATED_GROUND_PANEL(104)}"), NXOpen.Face)
faces1(0) = face1
Dim faceDumbRule1 As NXOpen.FaceDumbRule = Nothing
faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces1)
Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = faceDumbRule1
deleteFaceBuilder1.FaceCollector.ReplaceRules(rules1, False)
Dim faces2(1) As NXOpen.Face
faces2(0) = face1
Dim face2 As NXOpen.Face = CType(bodyFeature1.FindObject("FACE 59 {(11.9932915,12.3997989154561,-0.06) SB_MIGRATED_GROUND_PANEL(104)}"), NXOpen.Face)
faces2(1) = face2
Dim faceDumbRule2 As NXOpen.FaceDumbRule = Nothing
faceDumbRule2 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces2)
Dim rules2(0) As NXOpen.SelectionIntentRule
rules2(0) = faceDumbRule2
deleteFaceBuilder1.FaceCollector.ReplaceRules(rules2, False)
deleteFaceBuilder1.Type = NXOpen.Features.DeleteFaceBuilder.SelectTypes.Face
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = deleteFaceBuilder1.Commit()
deleteFaceBuilder1.Destroy()
End Sub
Function SelectmultiObjects(prompt As String,
ByRef selObj As NXObject()) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim typeArray() As Selection.SelectionType =
{Selection.SelectionType.All,
Selection.SelectionType.Faces,
Selection.SelectionType.Edges,
Selection.SelectionType.Features}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects(
prompt, "Selection",
Selection.SelectionScope.AnyInAssembly,
False, typeArray, selObj)
If resp = Selection.Response.ObjectSelected Or
resp = Selection.Response.ObjectSelectedByName Or
resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
End Module
re: delete face
The delete face command only takes faces as input. I'd suggest limiting the selection to faces, unless you have a good reason to allow selection of edges as well.
I did limited the selection
I did limited the selection to only faces. But my problem is different... I didn't find a way to call all the faces in a bucket in the below code
deleteFaceBuilder1.FaceCollector.
Regards,
MFJ
re: delete faces
Recording a journal is a great way to learn the required syntax. I created a simple test file and recorded a journal while deleting a few faces (I used the "single face" selection rule). The relevant code is below:
faces1(0) = face1
Dim faceDumbRule1 As NXOpen.FaceDumbRule = Nothing
faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces1)
Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = faceDumbRule1
deleteFaceBuilder1.FaceCollector.ReplaceRules(rules1, False)
Where faces1 is an array of face objects; replace it with your array.