Cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Edge Blend and 2 unite cylinder

Siemens Phenom Siemens Phenom
Siemens Phenom
Yes, I know where your problem is.

You can’t use an index to decide which edge to blend. The index values are meaningless, as you have discovered.

Do as I suggested: get the center points of the two circular edges, and use those two points to decide which of the two edges is the one you want to blend.
山田
yamada

Re: Edge Blend and 2 unite cylinder

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

The following code (from GTAC) will show you how to get the center point and radius of a circular edge (and other info).

 

Sample NX Open .NET Visual Basic program : report selected circular edge info

Option Strict Off

Imports System

Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.UF

Module report_circular_edge_info

    Dim theSession As Session = Session.GetSession()
    Dim theUFSession As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = theSession.ListingWindow
    Dim DEGRA As Double = 0.017453292519943282

    Sub Main()

        Dim edge As NXOpen.Tag

        While select_circular_edge(edge) = Selection.Response.Ok

            Dim arc_evaluator As System.IntPtr
            Dim arc_data As NXOpen.UF.UFEval.Arc
            Dim start_angle As Double = 0
            Dim end_angle As Double = 0

            lw.Open()
            lw.WriteLine(" ")
            lw.WriteLine("Edge Tag:" & edge.ToString())
            theUFSession.Eval.Initialize(edge, arc_evaluator)
            theUFSession.Eval.AskArc(arc_evaluator, arc_data)

            lw.WriteLine("Periodic? " & arc_data.is_periodic.ToString)
            lw.WriteLine("Radius:   " & arc_data.radius.ToString)
            lw.WriteLine("Orientation: ")
            lw.WriteLine("X Axis:  " & arc_data.x_axis(0).ToString & _
                                    "  " & arc_data.x_axis(1).ToString & _
                                    "  " & arc_data.x_axis(2).ToString)
            lw.WriteLine("Y Axis:  " & arc_data.y_axis(0).ToString & _
                                    "  " & arc_data.y_axis(1).ToString & _
                                    "  " & arc_data.y_axis(2).ToString)
            lw.WriteLine("Location: ")
            lw.WriteLine("Center:   " & arc_data.center(0).ToString & "  " & _
                                        arc_data.center(1).ToString & "  " & _
                                        arc_data.center(2).ToString)
            lw.WriteLine("Limits: (Radians)")
            lw.WriteLine("Start:    " & arc_data.limits(0).ToString)
            lw.WriteLine("End:    " & arc_data.limits(1).ToString)
            lw.WriteLine("Limits: (Degrees)")
            start_angle = arc_data.limits(0) / DEGRA
            end_angle = arc_data.limits(1) / DEGRA

            lw.WriteLine("Start:    " & start_angle.tostring)
            lw.WriteLine("End:    " & end_angle.ToString)

            theUFSession.UF.Free(arc_evaluator)

            theUFSession.Disp.SetHighlight(edge, 0)

        End While

    End Sub

    Function select_circular_edge(ByRef edge As NXOpen.Tag) As Selection.Response

        Dim message As String = "Circular Edge:"
        Dim title As String = "Select a CIRCULAR EDGE"
        Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
        Dim response As Integer
        Dim view As NXOpen.Tag
        Dim cursor(2) As Double
        Dim mask_edge As UFUi.SelInitFnT = AddressOf mask_for_edges

        theUFSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

        Try
            theUFSession.Ui.SelectWithSingleDialog(message, title, scope, mask_edge, _
                         Nothing, response, edge, cursor, view)
        Finally
            theUFSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
        End Try

        If response <> UFConstants.UF_UI_OBJECT_SELECTED And _
           response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then
            Return Selection.Response.Cancel
        Else
            Return Selection.Response.Ok
        End If

    End Function

    Function mask_for_edges(ByVal select_ As IntPtr, _
                           ByVal userdata As IntPtr) As Integer

        Dim num_triples As Integer = 1
        Dim mask_triples(0) As UFUi.Mask
        mask_triples(0).object_type = UFConstants.UF_solid_type
        mask_triples(0).object_subtype = UFConstants.UF_solid_edge_subtype
        mask_triples(0).solid_type = UFConstants.UF_UI_SEL_FEATURE_CIRCULAR_EDGE

        theUFSession.Ui.SetSelMask(select_, _
                           UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
                           num_triples, mask_triples)
        Return UFConstants.UF_UI_SEL_SUCCESS

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY

    End Function

End Module

Re: Edge Blend and 2 unite cylinder

Builder
Builder
Thanks Both of you.
@Yamada
thanks sir, your logic was correct, I could also imagine that.
@cowski1
thanks sir
And your code really help me in order to put that logic in my code.

Thank Again to both of you.

Re: Edge Blend and 2 unite cylinder

Builder
Builder
Hello Sir,
I am using following logic to get edge and It working well for above two united cylinder.
But I am getting while I am using that same logic for multiple cylinder united together.
How to solve this problem?


Cylinder cyl4 = (Cylinder)cylinder4V1;
foreach (Edge objEdge in cyl4.GetEdges())
{
IntPtr arc_evaluator;
ufs.Eval.Initialize(objEdge.Tag, out arc_evaluator);
UFEval.Arc arc_data;
ufs.Eval.AskArc(arc_evaluator, out arc_data);
double radius1 = diameter / 2;

if (arc_data.radius == radius1 && arc_data.center[0] == distx3V1)
{
Cylinder4EdgeBlendV1(objEdge);

}
}

Re: Edge Blend and 2 unite cylinder

Siemens Phenom Siemens Phenom
Siemens Phenom

Where several cylinders intersect, there might be several edges, and some of them might not even be circular. If you need to work with edges that are not circular, then obviously any reasoning that's based on radii will not work. 

 

The first step is for you to decide clearly which of the edges you want to blend. If you can describe your decision-making process in words, then we can help you convert this into code.

 

Saying it another way ... the logic has to come first, then the code comes second. 

山田
yamada

Re: Edge Blend and 2 unite cylinder

Builder
Builder
@Yamada
Hello Sir,
As You have seen that there are two cylinder united together so like that I have a part which has been modeled by uniting 4 to 5 cylinder together.
So, I want to blend only front edge of some of the cylinders in +ve X-direction.
Just like that first image as shown above.

Re: Edge Blend and 2 unite cylinder

Siemens Phenom Siemens Phenom
Siemens Phenom

OK.So get the x-coordinates of the centers of the circular edges, and use these to decide which edges to blend.

山田
yamada

Re: Edge Blend and 2 unite cylinder

Builder
Builder
Hello Sir,
Are these X coordinates as shown in above code in VB?
arc_data.x_axis(0)
arc_data.x_axis(1)
arc_data.x_axis(2)

Or Is there any other method?

Re: Edge Blend and 2 unite cylinder

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

To get the center point of the circle use:

  • arc_data.center(0) => X coordinate
  • arc_data.center(1) => Y coordinate
  • arc_data.center(2) => Z coordinate

 

The .x_axis and .y_axis define the plane that the circle exists on (the X and Y vectors of the plane).

Re: Edge Blend and 2 unite cylinder

Siemens Phenom Siemens Phenom
Siemens Phenom

Things shouldn't be this difficult. Maybe you don't have the right tools to get your job done.

 

Do you have NX/Open documentation? If you do, then it tells you that the arc_data structure has a field called "center". This center is an array of 3 numbers which are the 3 coordinates of the center point.

 

Do you have a good code editor that provides "intellisense"?  You can get a free version of Visual Studio, for example. In a good editor, as soon as you type the dot after arc_data, a list of members will appear that will include "center". 

山田
yamada