Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Section Curve by selected face collection and plane

Builder
Builder

Hello,

Something that I have early prepared is Block Form created by Block UI Styler. This form is pretty simple, it allows me to select a face(s), not body, and to try to make Section Curve by intesection with an plane.

On Solution Center, there are few similar examples but they work only if body is selected, not a sheet.

 

img678.PNG

What I have tried:

Face Collector is declared as:

Private face_select0 As NXOpen.BlockStyler.FaceCollector ' Block type: Face Collector

Plane is filtered by its name.

By following this example on Solution Center, I have tried to use function but this works only with body type.

 

' Create Section Curve if plane intersect selected face
Dim theIntersectCurves As Features.SectionCurve = createIntersectionCurves(face_select0, oPlane)

 

 

 

11 REPLIES

Re: Section Curve by selected face collection and plane

PLM World Member Legend PLM World Member Legend
PLM World Member Legend

Use the below function to create intersection curve using faces

 

Function CreateIntersectionCurve(ByVal faces() As Face, ByVal dtmPlane As DatumPlane) As Features.Feature

        Dim feat As Features.Feature = Nothing
        Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing
        Dim intersectionCurveBuilder1 As NXOpen.Features.IntersectionCurveBuilder = Nothing
        intersectionCurveBuilder1 = workPart.Features.CreateIntersectionCurveBuilder(nullNXOpen_Features_Feature)

        Try
            intersectionCurveBuilder1.CurveFitData.Tolerance = 0.01
            intersectionCurveBuilder1.CurveFitData.AngleTolerance = 0.5

            'Faces to create intersection curve
            Dim faceDumbRule1 As NXOpen.FaceDumbRule = Nothing
            faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces)

            Dim rules1(0) As NXOpen.SelectionIntentRule
            rules1(0) = faceDumbRule1
            intersectionCurveBuilder1.FirstFace.ReplaceRules(rules1, False)

            Dim objects1(faces.Length) As NXOpen.TaggedObject
            objects1 = faces
            Dim added1 As Boolean = Nothing
            added1 = intersectionCurveBuilder1.FirstSet.Add(objects1)

            'Datum to create intersection curve
            Dim datums(0) As NXOpen.DatumPlane
            datums(0) = dtmPlane
            Dim faceDumbRule5 As NXOpen.FaceDumbRule = Nothing
            faceDumbRule5 = workPart.ScRuleFactory.CreateRuleFaceDatum(datums)

            Dim rules2(0) As NXOpen.SelectionIntentRule
            rules2(0) = faceDumbRule5
            intersectionCurveBuilder1.SecondFace.ReplaceRules(rules2, False)

            Dim objs(0) As NXOpen.TaggedObject
            objs(0) = CType(dtmPlane, TaggedObject)
            Dim added4 As Boolean = Nothing
            added4 = intersectionCurveBuilder1.SecondSet.Add(objs)

            Dim nXObject1 As NXOpen.NXObject = Nothing
            nXObject1 = intersectionCurveBuilder1.Commit()
            feat = CType(nXObject1, Features.Feature)

            intersectionCurveBuilder1.Destroy()

        Catch ex As Exception
            '---- Enter your exception handling code here -----
            intersectionCurveBuilder1.Destroy()
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)

        End Try

        Return feat

    End Function

 

You need to type-cast the tagged objects to face which you are getting the face_select0 block like below.

Dim lstFace As New List(Of Face)
For Each obj As TaggedObject In face_select0.GetSelectedObjects() lstFace.Add(CType(obj, Face)) Next

'To create intersection curve
Dim theFeat As Features.Feature = CreateIntersectionCurve(lstFace.ToArray(), oPlane)

I have tested the above code. It's working as intended.

Re: Section Curve by selected face collection and plane

PLM World Member Legend PLM World Member Legend
PLM World Member Legend

Please find the attached method to create intersection curve.

 

To use that function, you need to TypeCase the TaggedObject into Face. Refer the below code:

Dim lstFace As New List(Of Face)
For Each obj As TaggedObject In face_select0.GetSelectedObjects()
   lstFace.Add(CType(obj, Face))
Next

'To create intersection curve
Dim theFeat As Features.Feature = CreateIntersectionCurve(lstFace.ToArray(), oPlane)

Re: Section Curve by selected face collection and plane

Builder
Builder

Hi @quest_mani,

You have provided gerat example and I have built the code in my apply callback.

Here is how it looks:

Public Function apply_cb() As Integer
        Dim errorCode as Integer = 0
        Try

            Dim theSession As Session = Session.GetSession()

            workPart = theSession.Parts.Work

            If IsNothing(theSession.Parts.Work) Then
                'active part required
                Return Nothing
            End If

            '---- Enter your callback code here -----
            Dim lstFace As New List(Of Face)
            For Each obj As TaggedObject In face_select0.GetSelectedObjects()
                lstFace.Add(CType(obj, Face))
            Next

            For Each tempDatum As DisplayableObject In theSession.Parts.Work.Datums
                If TypeOf (tempDatum) Is DatumPlane Then
                    If tempDatum.Name.Contains("ANGULAR") Then
                        'To create intersection curve
                        Dim theFeat As Features.Feature = CreateIntersectionCurve(lstFace.ToArray(), tempDatum)
                    End If
                End If
            Next


        Catch ex As Exception

            '---- Enter your exception handling code here -----
            errorCode = 1
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        apply_cb = errorCode
    End Function

In my model, I have an plane named "ANGULAR_..." which is patterned 20 times by using two different pattern techniques (Pattern Geometry and Pattern Feature).

 

Intersection between face and instances patterned using Pattern Geometry works perfect and section curves are ok. On the other side, the same process but using Pattern Feature option produce bad result. Process is recored in the attached video.

 

(view in My Videos)

Could someone explain me why this happens?

 

 

Re: Section Curve by selected face collection and plane

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

The second time through, when you use 'pattern feature', it appears that it picks up the existing pattern feature and tries to pattern both datum planes. The settings cause some of the copies to be outside of the sheet body, causing the "datum does not intersect" errors.

Re: Section Curve by selected face collection and plane

Builder
Builder

@cowski1 wrote:

The second time through, when you use 'pattern feature', it appears that it picks up the existing pattern feature and tries to pattern both datum planes. The settings cause some of the copies to be outside of the sheet body, causing the "datum does not intersect" errors.


Hi @cowski1,

That means there should be 40 planes instead of 20 which are shown. Why there are just 20?

Is it possible to pattern only specific instances of the pattern, not whole pattern? Do you suggest to continue with using Pattern Geometry instead of Pattern Feature?

Re: Section Curve by selected face collection and plane

PLM World Member Legend PLM World Member Legend
PLM World Member Legend

I would like to suggest to create the second datum using Datum Plane At Angle procedure instead of using cirucular pattern. I have tested the code it's working fine using pattern geometry as well as pattern feature.

 

Genrally the Patten Feature [Circular Pattern] (3) has two datum in it (1-Parent, 2-Child). So while you are pattern the pattern feature, It'll refer two datums and create 40 datums in the part. It casuses the error 'No intersection found'.

 

Is it possible to pattern only specific instances of the pattern, not whole pattern?

As I said, the above method is an workaround, need to look into feature level to create particular instance for pattern.

Re: Section Curve by selected face collection and plane

Builder
Builder

Hi @quest_mani,

 

I agree that first pattern has two planes (parrent and child) but second pattern only shows 20 planes not 40. That's why I supposed that only child of the first pattern has patterned, not whole pattern (parrent+child).

Is "Section Curve" feature covered with NX Open?

img01.png

 

Thank you!

 

Best,

Danijel

Re: Section Curve by selected face collection and plane

Builder
Builder

@quest_mani wrote:

I would like to suggest to create the second datum using Datum Plane At Angle procedure instead of using cirucular pattern. I have tested the code it's working fine using pattern geometry as well as pattern feature.

 



Hi @quest_mani,

(view in My Videos)

I have tested your method and it seems that I am getting the same result as before.

In the attached video, you will see that second datum is created by "At Angle" funciton, but still the same problem with intersection curves. There are some "imaginary" planes where some of them intersect surface but some of them don't intersect the surface, so the warning message is showing repeatedly.

Re: Section Curve by selected face collection and plane

PLM World Member Legend PLM World Member Legend
PLM World Member Legend

Hi @danijelVR

 

While your are creating circular pattern, you need to uncheck (Settings->Create Reference Pattern) in the dialog.

This will prevent the additinal reference datum creation and it solves your 'No intersection Found' issue.

I have tested in my system, it's working as I expected.