face selection with rules

Hi,
I have a question how to use selection rules for face / single -tangent-body-feature- etc.
I recorded a journalt - from offset face - want to reuse the selection in color faces.
The rules doesn't work, more
Is the a selection snippet with rules? -
thankyouinadvance

If I understand correctly, you want to use the faces selected in one part of the journal (that were selected with a selection intent rule) in a later part of the journal. If this is what you want, you can use the GetObjects method of the face collector to return those selected faces to an array.

Below is a snippet of a journal that I recorded (offset face operation with the body faces selection rule); the first 3 lines were created by the journal recorder, the last 3 lines were added by me. The selected faces are added to an array, you can do what you want with the array and its objects.

Dim rules1(0) As SelectionIntentRule
rules1(0) = faceBodyRule1
offsetFaceBuilder1.FaceCollector.ReplaceRules(rules1, False)

Dim mySelectedFaces() As TaggedObject
mySelectedFaces = offsetFaceBuilder1.FaceCollector.GetObjects
MsgBox("number of faces selected: " & mySelectedFaces.Length.ToString)

I thaught the rules where part of the selection,
I learned they are part of the specific function.
My attempt was it to add face rules to the object display / displayModification.*
or did I miss something?

My apologies, I misunderstood the original question.
Here is a quick example that highlights all the faces that are tangent to the one picked. The tangent faces are collected into a list so that you can do something interesting with them.

[vbnet]Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module1

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

Sub Main()

Dim pickFace As Face
Dim selectionFaces() As TaggedObject
Dim lstSelFaces As List(Of Face) = New List(Of Face)
SelectAFace("select a face", pickFace)

Dim scCollector1 As ScCollector = workPart.ScCollectors.CreateCollector
Dim boundaryFaces1(-1) As Face

Dim faceTangentRule1 As FaceTangentRule
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces1)

Dim rules1(0) As SelectionIntentRule
rules1(0) = faceTangentRule1

scCollector1.ReplaceRules(rules1, False)

selectionFaces = scCollector1.GetObjects
MsgBox("number selected: " & selectionFaces.Length.ToString)
For Each obj As TaggedObject In selectionFaces
'MsgBox("type: " & obj.GetType.ToString)
lstSelFaces.Add(obj)
Next
'lstSelFaces now contains all the selected faces
'do something with the objects...

'highlight all faces that are collected into the list
'these faces are not technically selected at this point in the journal
'the highlighting will stay until you use part cleanup to remove extraneous highlighting
For Each obj As Face In lstSelFaces
obj.Highlight()
Next

End Sub

Function SelectAFace(ByVal prompt As String, ByRef selObj As Face) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select a 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_ANY_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

Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------

End Function

End Module
[/vbnet]

Hello NXJournaling,
As in the post https://nxjournaling.com/comment/6592#comment-6592, I implemented this in the end: extruding->measure area ->delete extrusion.
See picture: https://drive.google.com/file/d/1MFi-ikkWcdx-focQtQ04XGkNzOKSwWiU/view?u...

I created an extruded body around the plate (not sheet body) by selecting the face of plate, and I tried the code above to find the tangent face which should be the extruded face on the selected face. However, when I measure the area of the tangent face, it’s always the same as the selected face’s…

As a result, I tried to access the tangent face by normal vectors. I measured all the normal vectors on every face, including the original plate. Then I save the faces whose normal vectors are contrary to the selected face (dispObj1) in the list “allBodyFaces”. There should be two this kind of faces, one on the plate, one on the extrusion. However, the area of the tangent face is still the same as the selected face’s…
Even if I measured the faces whose normal vectors are the same as the selected face, the areas are 0, instead of the complete square (2500mm^2).
Why is it so?

Thanks for your reply in advance and wish you a happy new year!
Sincerely,
Ray

'greifen die extrusion durch die tangente fläche zu / access the extrusion through the tangent face
Dim lstselfaces As list(Of face) = New list(Of face) 'to save the tangent faces of the only one selected face
Dim selectionfaces() As taggedobject
Dim sccollector1 As sccollector = workPart.sccollectors.createcollector
Dim boundaryfaces1(-1) As face

Dim facetangentrule1 As facetangentrule
facetangentrule1 = workPart.scrulefactory.createrulefacetangent(dispObj1, boundaryfaces1)

Dim rules1(0) As selectionintentrule
rules1(0) = facetangentrule1
sccollector1.replacerules(rules1, False)

selectionfaces = sccollector1.getobjects
msgbox("number selected: " & selectionfaces.length.tostring)
For Each obj As taggedobject In selectionfaces
'msgbox("type: " & obj.gettype.tostring)
lstselfaces.add(obj)
Next

' convert the list(of face) to an array of face
Dim arrlstselfaces() As face = lstselfaces.toarray()
'messe die tangente flächengröße der extrusion / measure the tagent face of the extrusion
Dim measurefaces2 As measurefaces
measurefaces2 = workPart.measuremanager.newfaceproperties(areaUnit, lengthUnit, 0.999, arrlstselfaces)
Dim x3, x4 As Double
x3 = measureFaces1.area
x4 = measureFaces1.perimeter
lw.writeline("flächengröße: " & x3)
lw.writeline("äußerer umfang der extrusion: " & x4)

'greifen die extrudierte fläche durch den normalvektor, der gegenseitigen von der ausgewählten fläche ist.
'/ access the extruded face by getting the opposite normal vector from the selected face
Dim partBodiesArray2() As Body
Dim theBody2 As Body
Dim partBodies2 As BodyCollection
partBodies2 = workPart.Bodies
partBodiesArray2 = partBodies2.ToArray()
Dim norm3(2) As Double
Dim allBodyFaces As New List(Of Face)()

For Each theBody2 In partBodiesArray2
For Each bodyFace As Face In theBody2.GetFaces()
theUfSession.Modl.AskFaceProps(bodyFace.Tag, param, pt, u1, v1, u2, v2, norm3, radii)

lw.WriteLine("Normalvektor X:" & formatnumber(norm3(0), 2).ToString & " Y:" &
formatnumber(norm3(1), 2).ToString & " Z:" &
formatnumber(norm3(2), 2).ToString)
If norm3(0) = norm(0) * -1 AndAlso norm3(1) = norm(1) * -1 AndAlso norm3(2) = norm(2) * -1 Then
allBodyFaces.Add(bodyFace)
End If

Next bodyFace
Next theBody2

Dim arrayAllBodyFaces() As Face = allBodyFaces.ToArray()
Dim targetExtrudedBodyFace() As Face = {arrayAllBodyFaces(1)}
Dim measureFaces3 As MeasureFaces
For Each tempFace As Face In arrayAllBodyFaces
If allBodyFaces.Count > 0 Then
'Messe die tangente Flächengröße der Extrusion / measure the tagent face of the extrusion

measureFaces3 = workPart.MeasureManager.NewFaceProperties(areaUnit, lengthUnit, 0.999, arrayAllBodyFaces)
Dim x5, x6 As Double
x5 = measureFaces1.Area
x6 = measureFaces1.Perimeter
lw.WriteLine("Flächengröße: " & x5)
lw.WriteLine("äußerer Umfang der Extrusion: " & x6)
Else
lw.WriteLine("No target extruded face found.")
End If
Next

"...and I tried the code above to find the tangent face which should be the extruded face on the selected face. However, when I measure the area of the tangent face, it’s always the same as the selected face’s..."

In your screenshot (a square body with a cylindrical hole in it), none of the body faces are tangent to each other. If you select a face with the tangent face rule, the only face in the resulting selection set will be the one you selected.

thanks on reply,
as I mentioned above I want the rules as part of the object display color modifications.
The face rules like in offsetFaceBuilder functions
hope its clearer
tia

The "selection intent rules" are part of the selection process, not a specific operation. The code above gives you a collection of tangent faces, you can now use that collection to do whatever you want - including object display changes.

thx on reply,
in your example I don't get the face rules inside the selection toolbar while selection
I want change face rule while seletion to feature faces body faces...

If the interactive function you are using doesn't activate the "face rules" option in the selection bar (as is the case with object display), I don't know of a way to force it to appear with journaling. But that's not to say it can't be done.

You may get a more definitive answer if you ask on the GTAC user forums (specifically the NX languages forum).

https://bbs.industrysoftware.automation.siemens.com/vbulletin/forumdisplay.php?f=187

Hi,
How can I make a modification to select Body Faces or Feature Faces.

I suggest recording a journal while using a function (such as "offset face") that allows you to select the desired face rule. The code returned will show you what is necessary to use the face rule.

I recorded a journal and offset face by selecting Feature Faces.
Where I need to modify,so it can be used for any workpart.

Thanks.

If you are modifying the code above, you would take out the "tangent face rule" and replace it with the code for the "feature face rule".

Are you mean replace the "tangent face rule" with "feature face rule".
I did it ,but got a error.
it works when I replace it with "adjacent face rule"
what is wrong about the "feature face rule"

Thanks

For the feature face rule to work, you will need to specify the feature that owns the faces you would like to use. One way to do this is to use the .AskFaceFeats method to determine which feature(s) the selected face belongs to, then use the returned feature as input to the feature face rule.

I'm very sorry.I'm not familiar with program.I'm learning.I found .Askfacefeats method in Net API reference,but I no idea how to use it.Can you give me a example about the .AskFaceFeats.

Thanks

The code below allows the user to select a face, then collects the feature faces that the selected face belongs to and reports the faces' area and perimeter.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "measure faces")

lw.Open()

Dim selectedFace As Face = Nothing
If SelectFace("select face", selectedFace) = Selection.Response.Cancel Then
Return
End If

'get feature that created the face
Dim faceFeat As Features.Feature
Dim faceFeatTags() As Tag = Nothing
theUfSession.Modl.AskFaceFeats(selectedFace.Tag, faceFeatTags)
faceFeat = Utilities.NXObjectManager.Get(faceFeatTags(0))
lw.WriteLine("feature: " & faceFeat.GetFeatureName)

'measure the feature faces
Dim nullNXObject As NXObject = Nothing

Dim measureFaceBuilder1 As MeasureFaceBuilder
measureFaceBuilder1 = theSession.Parts.Work.MeasureManager.CreateMeasureFaceBuilder(nullNXObject)

Dim faceFeatureRule1 As FaceFeatureRule
faceFeatureRule1 = theSession.Parts.Work.ScRuleFactory.CreateRuleFaceFeature({faceFeat})

Dim rules1(0) As SelectionIntentRule
rules1(0) = faceFeatureRule1
measureFaceBuilder1.FaceCollector.ReplaceRules(rules1, False)

Dim unit1 As Unit = CType(theSession.Parts.Work.UnitCollection.FindObject("SquareMilliMeter"), Unit)
Dim unit2 As Unit = CType(theSession.Parts.Work.UnitCollection.FindObject("MilliMeter"), Unit)

Dim measureFaces1 As MeasureFaces
measureFaces1 = theSession.Parts.Work.MeasureManager.NewFaceProperties(unit1, unit2, 0.99, measureFaceBuilder1.FaceCollector)

Dim measure1 As Measure
measure1 = measureFaces1.CreateFeature()

lw.WriteLine("journalidentifier :" & selectedFace.JournalIdentifier)
lw.WriteLine("color :" & selectedFace.Color)
lw.WriteLine("number of faces collected: " & measureFaceBuilder1.FaceCollector.GetObjects.Length.ToString)

Dim x1, x2 As Double
x1 = measureFaces1.Area
x2 = measureFaces1.Perimeter

lw.WriteLine("Area :" & x1)
lw.WriteLine("Perimeter :" & x2)

measureFaces1.Dispose()

measureFaceBuilder1.Destroy()

lw.Close()

End Sub

Function SelectFace(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

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

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

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(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

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

Thanks a lot.
Actually I would like to apply Feature Thicken on seleted Feature Faces.
I'll try to get it.

Create a simple model and record a journal while thickening faces with the "feature face" rule. It should return code that will be a good starting point for your project.

Following your advice,I tried it.
unbelievably,I got it.
It was my first journal.so I posted it, maybe the other people can get help from it.
And I'm sorry,I need you further advice.
I want to split a body using the created thichen body. How can I make it work.

' NX 10.0.0.24
' Journal created by finoa on Thu Nov 03 21:49:17 2016 東京 (標準時)
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

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 theUfSession As UFSession = UFSession.GetUFSession()

Dim displayPart As NXOpen.Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Insert->Offset/Scale->Thicken...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If

Dim thickenBuilder1 As NXOpen.Features.ThickenBuilder
thickenBuilder1 = workPart.Features.CreateThickenBuilder(nullNXOpen_Features_Feature)

thickenBuilder1.Tolerance = 0.01

thickenBuilder1.FirstOffset.RightHandSide = "0.01"

thickenBuilder1.SecondOffset.RightHandSide = "-0.01"

thickenBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create

Dim targetBodies1(0) As NXOpen.Body
Dim nullNXOpen_Body As NXOpen.Body = Nothing

targetBodies1(0) = nullNXOpen_Body
thickenBuilder1.BooleanOperation.SetTargetBodies(targetBodies1)

theSession.SetUndoMarkName(markId1, "Thicken Dialog")

thickenBuilder1.RegionToPierce.DistanceTolerance = 0.01

thickenBuilder1.RegionToPierce.ChainingTolerance = 0.0095

Dim features1(0) As NXOpen.Features.Feature

Dim selectedFace As Face = Nothing
If SelectFace("select face", selectedFace) = Selection.Response.Cancel Then
Return
End If

Dim faceFeat As Features.Feature
Dim faceFeatTags() As Tag = Nothing
theUfSession.Modl.AskFaceFeats(selectedFace.Tag, faceFeatTags)
faceFeat = Utilities.NXObjectManager.Get(faceFeatTags(0))

features1(0) = faceFeat
Dim faceFeatureRule1 As NXOpen.FaceFeatureRule
faceFeatureRule1 = workPart.ScRuleFactory.CreateRuleFaceFeature(features1)

Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = faceFeatureRule1
thickenBuilder1.FaceCollector.ReplaceRules(rules1, False)

Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Thicken")

theSession.DeleteUndoMark(markId2, Nothing)

Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Thicken")

Dim nXObject1 As NXOpen.NXObject
nXObject1 = thickenBuilder1.Commit()

theSession.DeleteUndoMark(markId3, Nothing)

theSession.SetUndoMarkName(markId1, "Thicken")

Dim expression1 As NXOpen.Expression = thickenBuilder1.SecondOffset

Dim expression2 As NXOpen.Expression = thickenBuilder1.FirstOffset

thickenBuilder1.Destroy()

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub

Function SelectFace(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

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

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

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(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

To split a body, you will need 1) a body to be split and 2) and object that completely intersects the body. Here again, you will probably learn a lot from the journal recorder. If you have items 1 and 2 ready to go, record a journal of the split body function and study the resulting code.

Hi,I record a journal and did some tweaks. It can be used on any workpart.
I created a solid to be split and a face (top face is open) to split the solid.
After split,I used the command of Offset Face to offset the split body.Then there is a gap (foreign faces and bottom face)between the two bodies.
Here I have a question. I just want there is a gap around the foreign faces.
How can I modify my code to do this.If I have to use UF_UI_SEL_FEATURE_FOREIGN_FACE.I posted my code.
I'm poor in English.I hope you can understand what I said.

' NX 10.0.2.6
' Journal created by SH00000747 on Fri Nov 04 13:20:55 2016
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

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 theUfSession As UFSession = UFSession.GetUFSession()

Dim displayPart As NXOpen.Part = theSession.Parts.Display

' ----------------------------------------------
' メニュー: 挿入(S)->トリム(T)->ボディの分割(P)...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "開始")

Dim nullNXOpen_Features_SplitBody As NXOpen.Features.SplitBody = Nothing

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If

Dim splitBodyBuilder1 As NXOpen.Features.SplitBodyBuilder
splitBodyBuilder1 = workPart.Features.CreateSplitBodyBuilderUsingCollector(nullNXOpen_Features_SplitBody)

Dim origin1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim normal1 As NXOpen.Vector3d = New NXOpen.Vector3d(0.0, 0.0, 1.0)
Dim plane1 As NXOpen.Plane
plane1 = workPart.Planes.CreatePlane(origin1, normal1, NXOpen.SmartObject.UpdateOption.WithinModeling)

splitBodyBuilder1.BooleanTool.FacePlaneTool.ToolPlane = plane1

Dim unit1 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)

Dim expression1 As NXOpen.Expression
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression2 As NXOpen.Expression
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

splitBodyBuilder1.BooleanTool.ExtrudeRevolveTool.ToolSection.PrepareMappingData()

theSession.SetUndoMarkName(markId1, "ボディの分割ダイアログ")

splitBodyBuilder1.BooleanTool.ExtrudeRevolveTool.ToolSection.DistanceTolerance = 0.01

splitBodyBuilder1.BooleanTool.ExtrudeRevolveTool.ToolSection.ChainingTolerance = 0.0095

Dim scCollector1 As NXOpen.ScCollector
scCollector1 = workPart.ScCollectors.CreateCollector()

Dim bodies1(0) As NXOpen.Body

Dim body1 As Body = SelectSolid()

bodies1(0) = body1
Dim bodyDumbRule1 As NXOpen.BodyDumbRule
bodyDumbRule1 = workPart.ScRuleFactory.CreateRuleBodyDumb(bodies1, True)

Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = bodyDumbRule1
scCollector1.ReplaceRules(rules1, False)

splitBodyBuilder1.TargetBodyCollector = scCollector1

Dim features1(0) As NXOpen.Features.Feature

Dim selectedFace As Face = Nothing
If SelectFace("select face", selectedFace) = Selection.Response.Cancel Then
Return
End If

Dim faceFeat As Features.Feature
Dim faceFeatTags() As Tag = Nothing
theUfSession.Modl.AskFaceFeats(selectedFace.Tag, faceFeatTags)
faceFeat = Utilities.NXObjectManager.Get(faceFeatTags(0))

features1(0) = faceFeat
Dim faceFeatureRule1 As NXOpen.FaceFeatureRule
faceFeatureRule1 = workPart.ScRuleFactory.CreateRuleFaceFeature(features1)

Dim rules2(0) As NXOpen.SelectionIntentRule
rules2(0) = faceFeatureRule1
splitBodyBuilder1.BooleanTool.FacePlaneTool.ToolFaces.FaceCollector.ReplaceRules(rules2, False)

Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "ボディの分割")

theSession.DeleteUndoMark(markId2, Nothing)

Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "ボディの分割")

Dim nXObject1 As NXOpen.NXObject
nXObject1 = splitBodyBuilder1.Commit()

theSession.DeleteUndoMark(markId3, Nothing)

theSession.SetUndoMarkName(markId1, "ボディの分割")

splitBodyBuilder1.BooleanTool.ExtrudeRevolveTool.ToolSection.CleanMappingData()

splitBodyBuilder1.Destroy()

Try
' 式はまだ使用中です
workPart.Expressions.Delete(expression2)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

Try
' 式はまだ使用中です
workPart.Expressions.Delete(expression1)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

plane1.DestroyPlane()

' ----------------------------------------------
' メニュー: 挿入(S)->オフセット/スケール(O)->オフセットフェース(F)...
' ----------------------------------------------
Dim markId4 As NXOpen.Session.UndoMarkId
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "開始")

Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing

Dim offsetFaceBuilder1 As NXOpen.Features.OffsetFaceBuilder
offsetFaceBuilder1 = workPart.Features.CreateOffsetFaceBuilder(nullNXOpen_Features_Feature)

offsetFaceBuilder1.Distance.RightHandSide = "0.01"

theSession.SetUndoMarkName(markId4, "オフセットフェースダイアログ")

Dim features2(0) As NXOpen.Features.Feature
Dim splitBody1 As NXOpen.Features.SplitBody = CType(nXObject1, NXOpen.Features.SplitBody)

features2(0) = splitBody1
Dim faceFeatureRule2 As NXOpen.FaceFeatureRule
faceFeatureRule2 = workPart.ScRuleFactory.CreateRuleFaceFeature(features2)

Dim rules3(0) As NXOpen.SelectionIntentRule
rules3(0) = faceFeatureRule2
offsetFaceBuilder1.FaceCollector.ReplaceRules(rules3, False)

offsetFaceBuilder1.Direction = True

Dim markId5 As NXOpen.Session.UndoMarkId
markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "オフセットフェース")

theSession.DeleteUndoMark(markId5, Nothing)

Dim markId6 As NXOpen.Session.UndoMarkId
markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "オフセットフェース")

Dim nXObject2 As NXOpen.NXObject
nXObject2 = offsetFaceBuilder1.Commit()

theSession.DeleteUndoMark(markId6, Nothing)

theSession.SetUndoMarkName(markId4, "オフセットフェース")

Dim expression3 As NXOpen.Expression = offsetFaceBuilder1.Distance

offsetFaceBuilder1.Destroy()

End Sub

' ----------------------------------------------
' メニュー: ツール(T)->ジャーナル(J)->記録を停止(S)
' ----------------------------------------------

Function SelectSolid() As Body

Dim ui As UI = ui.GetUI
Dim message As String = "Select solid body"
Dim title As String = "Selection"

Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim keepHighlighted As Boolean = False
Dim includeFeatures As Boolean = True

Dim selectionAction As Selection.SelectionAction = _
Selection.SelectionAction.ClearAndEnableSpecific

Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
End With

Dim selectedObject As NXObject = Nothing
Dim cursor As Point3d

ui.SelectionManager.SelectObject(message, title, scope, _
selectionAction, includeFeatures, _
keepHighlighted, selectionMask_array, _
selectedObject, cursor)

Dim solid As Body = CType(selectedObject, Body)

If solid Is Nothing Then
Return Nothing
End If

Return solid

End Function

Function SelectFace(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

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

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

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(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 understand that you split the body then offset the faces to create a gap between the two resulting bodies; but I don't understand what you mean by:

"I just want there is a gap around the foreign faces."

I know there is a "foreign face" type in NXOpen, but I'm not sure if it applies in this case. I've worked with a lot of imported geometry, but I've never actually seen a face reported as the "foreign face" type; in my experience, they always show up as planar, cylindrical, B-surface, etc.

Can you email me some screenshots, or better yet, part files that illustrate the result you want? They can be sent to: info@nxjournaling.com

i am so satisfacted.my english is poor, sorry :). thx for approving my user greetings wally