Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IFRs on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program for generating XYZ & radius co-ordinate data in UG Nx 1

Status
Not open for further replies.

sundeep198

Mechanical
Aug 22, 2012
53
Hello,
I am using UG-Nx 7.5. I work mostly on tubings & hose. I was looking for any programs which will help in creating the co-ordinate table (XYZ & bend radius) for the tubes on drawing from model.
I currenlty I have "pipebend.grx" from GM toolkit, but it has a shortcoming. In that, we have to select a line & arc in sequence or else it indicates an error. So instead of selecting line & arc, would it be possible to select intersecting points & generate the table.
Attached sceen shot of the required coordinate table.

Regards,
Sundeep
 
Replies continue below

Recommended for you

Hi Sundeep,
Have you used BEND REPORT (Routing Mechanical)? Sorry i have not used it yet myself but it looks promising in your case.One thing i am unaware of is if you have created the pipes and bends using Routing or simply created it in Modeling
Best Regards
Kapil Sharma
 
Hi Kapil,
This is done by simple modelling. I currently donot have Routing Mechanical license.
Its just created using centreline & then sweep.
Regards,
Sundeep
 
If this is going to be a big part of your work, creating tubing and hoses, and these 'tables of data' are an important part of that work, then you should invest in the appropriate Routing applications. After all, why would we (Siemens PLM) be willing to help you develop FREE workarounds for functionality which we've already developed as part of a add-on module where we've invested our R&D resources?

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Here is another method for creating a tabnote. Please note the following restrictions.

1. It is developed for NX7.5

2. It requires that the "pipe/tubing" is created using the sweep method. That is a sweep feature is created using sweep along guide.

3. Based on annotation preferences Fit methods with auto size row on, auto size text on,
auto size column on and all other options off.

Note also that the first point is not included in the points list. Not sure if this was the requirement.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Features
Imports NXOpen.Utilities
Imports NXOpen.Annotations

Module TabNote

    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim workPart As Part = s.Parts.Work
    Dim ui As UI = ui.GetUI()
    Sub Main()
        Dim no_pts As Integer = Nothing
        Dim pos1 As Integer = Nothing
        Dim junk3(2) As Double
        Dim junk2(1) As Double
        Dim junk1 As Double
        Dim theSweep As Feature = Nothing
        Dim response1 As Selection.Response = Selection.Response.Cancel
        Dim message1 As String = "Select the sweep Feature"
start1:
        response1 = select_a_feature(message1, theSweep)
        If response1 = Selection.Response.Cancel Or response1 = Selection.Response.Back Then GoTo end1
        Dim name1 As String = Nothing
        name1 = theSweep.GetFeatureName.Substring(0, 5)
        If name1 <> "Sweep" Then
            MsgBox("Selected feature is not a Sweep along Guide feature")
            GoTo end1
        End If
        Dim pt1(2) As Double
        Dim pt2(2) As Double
        Dim line1 As Line
        Dim arc1 As Arc
        Dim noprofilecurves As Integer = Nothing
        Dim profilecurvetags(-1) As NXOpen.Tag
        Dim nosectioncurves As Integer = Nothing
        Dim sectioncurvetags(-1) As NXOpen.Tag
        ufs.Modl.AskSweepCurves(theSweep.Tag, nosectioncurves, sectioncurvetags, noprofilecurves, profilecurvetags)
        Dim obj1(noprofilecurves - 1) As NXObject
        Dim strpt(noprofilecurves - 1) As Point3d
        Dim endpt(noprofilecurves - 1) As Point3d
        Dim radii(noprofilecurves - 1) As Double
        Dim lengths(noprofilecurves - 1) As Double
        For i As Integer = 0 To noprofilecurves - 1
            obj1(i) = NXObjectManager.Get(profilecurvetags(i))
            ' get the end points, radius and length
            If (TypeOf obj1(i) Is Line) Then
                line1 = DirectCast(obj1(i), Line)
                strpt(i) = line1.StartPoint
                endpt(i) = line1.EndPoint
                radii(i) = 0.0
                lengths(i) = line1.GetLength()
            ElseIf (TypeOf obj1(i) Is Arc) Then
                arc1 = DirectCast(obj1(i), Arc)
                ufs.Modl.AskCurveProps(profilecurvetags(i), 0.0, pt1, junk3, junk3, junk3, junk1, junk1)
                ufs.Modl.AskCurveProps(profilecurvetags(i), 1.0, pt2, junk3, junk3, junk3, junk1, junk1)
                strpt(i) = New Point3d(pt1(0), pt1(1), pt1(2))
                endpt(i) = New Point3d(pt2(0), pt2(1), pt2(2))
                radii(i) = arc1.Radius
                lengths(i) = arc1.GetLength()
            Else
                MsgBox("Sweep guide curve is not a line or arc")
            End If
        Next
        ' order the points for tabnote
        Dim orderedpts(noprofilecurves) As Point3d
        Dim l1 As Double = 0.0
        l1 = Distancepoint3d(strpt(0), strpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = endpt(0)
            orderedpts(1) = strpt(1)
            orderedpts(2) = endpt(1)
            GoTo continue2
        End If
        l1 = Distancepoint3d(strpt(0), endpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = endpt(0)
            orderedpts(1) = endpt(1)
            orderedpts(2) = strpt(1)
            GoTo continue2
        End If
        l1 = Distancepoint3d(endpt(0), strpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = strpt(0)
            orderedpts(1) = strpt(1)
            orderedpts(2) = endpt(1)
            GoTo continue2
        End If
        l1 = Distancepoint3d(endpt(0), endpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = strpt(0)
            orderedpts(1) = endpt(1)
            orderedpts(2) = strpt(1)
            GoTo continue2
        End If
continue2:
        For i As Integer = 2 To noprofilecurves - 2
            l1 = Distancepoint3d(orderedpts(i), strpt(i + 1))
            If l1 = 0.0 Then
                orderedpts(i + 1) = endpt(i + 1)
                If i = noprofilecurves - 2 Then
                    orderedpts(i + 2) = strpt(i + 1)
                End If
            Else
                orderedpts(i + 1) = strpt(i + 1)
                If i = noprofilecurves - 2 Then
                    orderedpts(i + 2) = endpt(i + 1)
                End If
            End If
        Next
        ' select point for tabnote
        Dim dwgview As View = Nothing
        Dim cursor As Point3d
        Dim response As Selection.DialogResponse = SelectScreenPos(cursor, dwgview)
        If response <> Selection.DialogResponse.Pick Then
            Return
        End If
        ' Create the tabular note
        Dim n_new_columns As Integer = 5
        Dim tabnote As NXOpen.Tag = CreateTabnoteWithSize(0, n_new_columns, cursor)
        ' Get the column tags
        Dim columns(n_new_columns - 1) As NXOpen.Tag
        For ii As Integer = 0 To n_new_columns - 1
            ufs.Tabnot.AskNthColumn(tabnote, ii, columns(ii))
        Next
        Dim row As NXOpen.Tag
        Dim cell As NXOpen.Tag
        Dim cells(4) As NXOpen.Tag
        ' Add points Header Row
        Dim headerrow As NXOpen.Tag
        ufs.Tabnot.CreateRow(10, headerrow)
        ufs.Tabnot.AddRow(tabnote, headerrow, UFConstants.UF_TABNOT_APPEND)
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(0), cell)
        ufs.Tabnot.SetCellText(cell, "Point")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(1), cell)
        ufs.Tabnot.SetCellText(cell, "     X     ")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(2), cell)
        ufs.Tabnot.SetCellText(cell, "     Y     ")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(3), cell)
        ufs.Tabnot.SetCellText(cell, "     Z     ")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(4), cell)
        ufs.Tabnot.SetCellText(cell, "Radius")
        ' Add a row for each point leaving out the first point ???
        For i As Integer = 1 To orderedpts.Length - 1
            ufs.Tabnot.CreateRow(10, row)
            ufs.Tabnot.AddRow(tabnote, row, UFConstants.UF_TABNOT_APPEND)
            ufs.Tabnot.AskCellAtRowCol(row, columns(0), cell)
            ufs.Tabnot.SetCellText(cell, i.ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(1), cell)
            ufs.Tabnot.SetCellText(cell, FormatNumber(orderedpts(i).X, 1).ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(2), cell)
            ufs.Tabnot.SetCellText(cell, FormatNumber(orderedpts(i).Y, 1).ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(3), cell)
            ufs.Tabnot.SetCellText(cell, FormatNumber(orderedpts(i).Z, 1).ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(4), cell)
            ufs.Tabnot.SetCellText(cell, FormatNumber(radii(i - 1), 1).ToString())
        Next
        ' Developed Length
        Dim devlength As String = "Developed Length"
        Dim sum1 As Double = Nothing
        For i As Integer = 0 To noprofilecurves - 1
            sum1 = sum1 + lengths(i)
        Next
        ufs.Tabnot.CreateRow(10, row)
        ufs.Tabnot.AddRow(tabnote, row, UFConstants.UF_TABNOT_APPEND)
        For i As Integer = 0 To 4
            ufs.Tabnot.AskCellAtRowCol(row, columns(i), cells(i))
        Next
        ufs.Tabnot.MergeCells(cells(0), cells(3))
        ufs.Tabnot.SetCellText(cells(0), devlength)
        ufs.Tabnot.SetCellText(cells(4), FormatNumber(sum1, 1).ToString())
end1:
    End Sub

    Function select_a_feature(ByRef prompt As String, ByRef sweep1 As Feature) As Selection.Response
        Dim featurearray(-1) As Features.Feature
        Dim feattype As NXOpen.Selection.SelectionFeatureType = Selection.SelectionFeatureType.Browsable
        Dim response1 As Selection.Response = Selection.Response.Cancel
        response1 = ui.GetUI.SelectionManager.SelectFeatures(prompt, feattype, featurearray)
        sweep1 = featurearray(0)
        Return response1
    End Function
    Public Function SelectScreenPos(ByRef pos As Point3d, ByVal view As View) As Selection.DialogResponse
        Return (ui.SelectionManager.SelectScreenPosition("Select location for tabnote", view, pos))
    End Function
    Public Function CreateTabnoteWithSize( _
        ByVal nRows As Integer, ByVal nColumns As Integer, ByVal loc As Point3d) As NXOpen.Tag
        ' Create the tabular note.  Based on annotation preferences Fit methods with auto size row on, auto size text on, 
        ' auto size column on and all others off
        Dim secPrefs As UFTabnot.SectionPrefs
        ufs.Tabnot.AskDefaultSectionPrefs(secPrefs)
        Dim origin(2) As Double
        origin(0) = loc.X
        origin(1) = loc.Y
        origin(2) = loc.Z
        Dim tabnote As NXOpen.Tag
        ufs.Tabnot.Create(secPrefs, origin, tabnote)
        ' Delete all existing columns and rows (we create them as needed)
        Dim nmRows As Integer = 0
        ufs.Tabnot.AskNmRows(tabnote, nmRows)
        For ii As Integer = 0 To nmRows - 1
            Dim row As NXOpen.Tag
            ufs.Tabnot.AskNthRow(tabnote, 0, row)
            ufs.Tabnot.RemoveRow(row)
            ufs.Obj.DeleteObject(row)
        Next
        Dim nmColumns As Integer = 0
        ufs.Tabnot.AskNmColumns(tabnote, nmColumns)
        For ii As Integer = 0 To nmColumns - 1
            Dim column As NXOpen.Tag
            ufs.Tabnot.AskNthColumn(tabnote, 0, column)
            ufs.Tabnot.RemoveColumn(column)
            ufs.Obj.DeleteObject(column)
        Next
        ' Now add our columns as needed
        Dim columns(nColumns - 1) As NXOpen.Tag
        For ii As Integer = 0 To nColumns - 1
            '   ufs.Tabnot.SetColumnWidth(columns(ii), 10)
            ufs.Tabnot.CreateColumn(40, columns(ii))
            ufs.Tabnot.AddColumn(tabnote, columns(ii), UFConstants.UF_TABNOT_APPEND)
        Next
        ' Now add our rows as needed
        Dim rows(nRows - 1) As NXOpen.Tag
        For ii As Integer = 0 To nRows - 1
            ufs.Tabnot.CreateRow(40, rows(ii))
            ufs.Tabnot.AddRow(tabnote, rows(ii), UFConstants.UF_TABNOT_APPEND)
        Next
        Return tabnote
    End Function

    Public Function Distancepoint3d(ByVal pt1 As Point3d, ByVal pt2 As Point3d) As Double
        Dim l1 As Double = 0.0
        If Math.Abs(pt1.X - pt2.X) < 0.01 And _
            Math.Abs(pt1.Y - pt2.Y) < 0.01 And _
            Math.Abs(pt1.Z - pt2.Z) < 0.01 Then
            l1 = 0.0
        Else
            l1 = Math.Sqrt((pt2.X - pt1.X) * (pt2.X - pt1.X) + _
                                             (pt2.Y - pt1.Y) * (pt2.X - pt1.Y) + _
                                             (pt2.Z - pt1.Z) * (pt2.Z - pt1.Z))

        End If
        Return l1
    End Function
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function

End Module


Regards

Frank
 
Thank you Frank for your efforts in preparing this program.
But I think there are few more things to be needed.
Attached below is the example drawing for the tube.
I generated tube using sweep command & derived the coordinates using pipe-bend program & your program.
I found differences in the coordinates. The XYZ coordinates values should be for intersecting points as indicated. If you refer the isometric view, this has the required coordinates.

So can you kindly modify your program, so that I only have to pick the intersecting points (as required) and the program should prompt for entering the bend radius values in the after the points have been selected. So except the first & last point there would be radius value.


example drawing pdf file is also uploaded to :


Thanks in advance,
Sundeep Panchal
 
I am not sure why you want to select intersection points. If one did that it would not have any link to the radius value. I have adjusted the journal using the end points and the intersections determined from the sweep feature.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Features
Imports NXOpen.Utilities
Imports NXOpen.Annotations

Module TabNote

    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim workPart As Part = s.Parts.Work
    Dim ui As UI = ui.GetUI()
    Sub Main()
        Dim no_pts As Integer = Nothing
        Dim pos1 As Integer = Nothing
        Dim junk3(2) As Double
        Dim junk2(1) As Double
        Dim junk1 As Double
        Dim theSweep As Feature = Nothing
        Dim response1 As Selection.Response = Selection.Response.Cancel
        Dim message1 As String = "Select the sweep Feature"
start1:
        response1 = select_a_feature(message1, theSweep)
        If response1 = Selection.Response.Cancel Or response1 = Selection.Response.Back Then GoTo end1
        Dim name1 As String = Nothing
        name1 = theSweep.GetFeatureName.Substring(0, 5)
        If name1 <> "Sweep" Then
            MsgBox("Selected feature is not a Sweep along Guide feature")
            GoTo end1
        End If
        Dim pt1(2) As Double
        Dim pt2(2) As Double
        Dim line1 As Line
        Dim arc1 As Arc
        Dim noprofilecurves As Integer = Nothing
        Dim profilecurvetags(-1) As NXOpen.Tag
        Dim nosectioncurves As Integer = Nothing
        Dim sectioncurvetags(-1) As NXOpen.Tag
        ufs.Modl.AskSweepCurves(theSweep.Tag, nosectioncurves, sectioncurvetags, noprofilecurves, profilecurvetags)
        Dim obj1(noprofilecurves - 1) As NXObject
        Dim strpt(noprofilecurves - 1) As Point3d
        Dim endpt(noprofilecurves - 1) As Point3d
        Dim radii(noprofilecurves - 1) As Double
        Dim lengths(noprofilecurves - 1) As Double
        Dim angle1(noprofilecurves - 1) As Double
        Dim strangle As Double = Nothing
        Dim endangle As Double = Nothing
        Dim lengths2(noprofilecurves - 1) As Double
        For i As Integer = 0 To noprofilecurves - 1
            obj1(i) = NXObjectManager.Get(profilecurvetags(i))
            ' get the end points, radius and length
            If (TypeOf obj1(i) Is Line) Then
                line1 = DirectCast(obj1(i), Line)
                strpt(i) = line1.StartPoint
                endpt(i) = line1.EndPoint
                radii(i) = 0.0
                lengths(i) = line1.GetLength()
                angle1(i) = 0.0
                lengths2(i) = 0.0
            ElseIf (TypeOf obj1(i) Is Arc) Then
                arc1 = DirectCast(obj1(i), Arc)
                ufs.Modl.AskCurveProps(profilecurvetags(i), 0.0, pt1, junk3, junk3, junk3, junk1, junk1)
                ufs.Modl.AskCurveProps(profilecurvetags(i), 1.0, pt2, junk3, junk3, junk3, junk1, junk1)
                strpt(i) = New Point3d(pt1(0), pt1(1), pt1(2))
                endpt(i) = New Point3d(pt2(0), pt2(1), pt2(2))
                radii(i) = arc1.Radius
                lengths(i) = arc1.GetLength()
                strangle = arc1.StartAngle
                endangle = arc1.EndAngle
                angle1(i) = (endangle - strangle) / 2.0
                lengths2(i) = radii(i) * Math.Tan(angle1(i))
            Else
                MsgBox("Sweep guide curve is not a line or arc")
            End If
        Next
        ' order the points for tabnote
        Dim orderedpts(noprofilecurves) As Point3d
        Dim l1 As Double = 0.0
        l1 = Distancepoint3d(strpt(0), strpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = endpt(0)
            orderedpts(1) = strpt(1)
            orderedpts(2) = endpt(1)
            GoTo continue2
        End If
        l1 = Distancepoint3d(strpt(0), endpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = endpt(0)
            orderedpts(1) = endpt(1)
            orderedpts(2) = strpt(1)
            GoTo continue2
        End If
        l1 = Distancepoint3d(endpt(0), strpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = strpt(0)
            orderedpts(1) = strpt(1)
            orderedpts(2) = endpt(1)
            GoTo continue2
        End If
        l1 = Distancepoint3d(endpt(0), endpt(1))
        If l1 = 0.0 Then
            orderedpts(0) = strpt(0)
            orderedpts(1) = endpt(1)
            orderedpts(2) = strpt(1)
            GoTo continue2
        End If
continue2:
        For i As Integer = 2 To noprofilecurves - 2
            l1 = Distancepoint3d(orderedpts(i), strpt(i + 1))
            If l1 = 0.0 Then
                orderedpts(i + 1) = endpt(i + 1)
                If i = noprofilecurves - 2 Then
                    orderedpts(i + 2) = strpt(i + 1)
                End If
            Else
                orderedpts(i + 1) = strpt(i + 1)
                If i = noprofilecurves - 2 Then
                    orderedpts(i + 2) = endpt(i + 1)
                End If
            End If
        Next
        ' now determine the intersection points 
        Dim newnopoints As Integer = noprofilecurves - 3
        Dim newpoints(newnopoints - 1) As Point3d
        newpoints(0) = orderedpts(0)
        newpoints(newnopoints - 1) = orderedpts(noprofilecurves - 4)
        For i As Integer = 1 To newnopoints - 2
            newpoints(i) = calculateIntesectionPoint(orderedpts((i - 1) * 2), orderedpts((i - 1) * 2 + 1), lengths2(i * 2 - 1))
        Next
        ' select point for tabnote
        Dim dwgview As View = Nothing
        Dim cursor As Point3d
        Dim response As Selection.DialogResponse = SelectScreenPos(cursor, dwgview)
        If response <> Selection.DialogResponse.Pick Then
            Return
        End If
        ' Create the tabular note
        Dim n_new_columns As Integer = 5
        Dim tabnote As NXOpen.Tag = CreateTabnoteWithSize(0, n_new_columns, cursor)
        ' Get the column tags
        Dim columns(n_new_columns - 1) As NXOpen.Tag
        For ii As Integer = 0 To n_new_columns - 1
            ufs.Tabnot.AskNthColumn(tabnote, ii, columns(ii))
        Next
        Dim row As NXOpen.Tag
        Dim cell As NXOpen.Tag
        Dim cells(4) As NXOpen.Tag
        ' Add points Header Row
        Dim headerrow As NXOpen.Tag
        ufs.Tabnot.CreateRow(10, headerrow)
        ufs.Tabnot.AddRow(tabnote, headerrow, UFConstants.UF_TABNOT_APPEND)
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(0), cell)
        ufs.Tabnot.SetCellText(cell, "Point")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(1), cell)
        ufs.Tabnot.SetCellText(cell, "     X     ")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(2), cell)
        ufs.Tabnot.SetCellText(cell, "     Y     ")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(3), cell)
        ufs.Tabnot.SetCellText(cell, "     Z     ")
        ufs.Tabnot.AskCellAtRowCol(headerrow, columns(4), cell)
        ufs.Tabnot.SetCellText(cell, "Radius")
        ' Add a row for each point leaving out the first point ???
        For i As Integer = 0 To newpoints.Length - 1
            ufs.Tabnot.CreateRow(10, row)
            ufs.Tabnot.AddRow(tabnote, row, UFConstants.UF_TABNOT_APPEND)
            ufs.Tabnot.AskCellAtRowCol(row, columns(0), cell)
            ufs.Tabnot.SetCellText(cell, (i + 1).ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(1), cell)
            ufs.Tabnot.SetCellText(cell, FormatNumber(newpoints(i).X, 1).ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(2), cell)
            ufs.Tabnot.SetCellText(cell, FormatNumber(newpoints(i).Y, 1).ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(3), cell)
            ufs.Tabnot.SetCellText(cell, FormatNumber(newpoints(i).Z, 1).ToString())
            ufs.Tabnot.AskCellAtRowCol(row, columns(4), cell)
            If i = 0 Then
                ufs.Tabnot.SetCellText(cell, FormatNumber(radii(0), 1).ToString())
            ElseIf i = newpoints.Length - 1 Then
                ufs.Tabnot.SetCellText(cell, FormatNumber(radii(i * 2 - 2), 1).ToString())
            Else
                ufs.Tabnot.SetCellText(cell, FormatNumber(radii(i * 2 - 1), 1).ToString())
            End If
        Next
        ' Developed Length
        Dim devlength As String = "Developed Length"
        Dim sum1 As Double = Nothing
        For i As Integer = 0 To noprofilecurves - 1
            sum1 = sum1 + lengths(i)
        Next
        ufs.Tabnot.CreateRow(10, row)
        ufs.Tabnot.AddRow(tabnote, row, UFConstants.UF_TABNOT_APPEND)
        For i As Integer = 0 To 4
            ufs.Tabnot.AskCellAtRowCol(row, columns(i), cells(i))
        Next
        ufs.Tabnot.MergeCells(cells(0), cells(3))
        ufs.Tabnot.SetCellText(cells(0), devlength)
        ufs.Tabnot.SetCellText(cells(4), FormatNumber(sum1, 1).ToString())
end1:
    End Sub
    Function calculateIntesectionPoint(ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal l1 As Double) As Point3d
        Dim v1 As Vector3d
        v1.X = pt2.X - pt1.X
        v1.Y = pt2.Y - pt1.Y
        v1.Z = pt2.Z - pt1.Z
        ' unitize
        Dim u1 As Vector3d
        Dim sub1 As Double
        sub1 = Math.Sqrt(v1.X * v1.X + v1.Y * v1.Y + v1.Z * v1.Z)
        u1.X = v1.X / sub1
        u1.Y = v1.Y / sub1
        u1.Z = v1.Z / sub1
        Dim p3 As Point3d
        p3.X = pt2.X + u1.X * l1
        p3.Y = pt2.Y + u1.Y * l1
        p3.Z = pt2.Z + u1.Z * l1
        Return p3
    End Function

    Function select_a_feature(ByRef prompt As String, ByRef sweep1 As Feature) As Selection.Response
        Dim featurearray(-1) As Features.Feature
        Dim feattype As NXOpen.Selection.SelectionFeatureType = Selection.SelectionFeatureType.Browsable
        Dim response1 As Selection.Response = Selection.Response.Cancel
        response1 = ui.GetUI.SelectionManager.SelectFeatures(prompt, feattype, featurearray)
        sweep1 = featurearray(0)
        Return response1
    End Function
    Public Function SelectScreenPos(ByRef pos As Point3d, ByVal view As View) As Selection.DialogResponse
        Return (ui.SelectionManager.SelectScreenPosition("Select location for tabnote", view, pos))
    End Function
    Public Function CreateTabnoteWithSize( _
        ByVal nRows As Integer, ByVal nColumns As Integer, ByVal loc As Point3d) As NXOpen.Tag
        ' Create the tabular note.  Based on annotation preferences Fit methods with auto size row on, auto size text on, 
        ' auto size column on and all others off
        Dim secPrefs As UFTabnot.SectionPrefs
        ufs.Tabnot.AskDefaultSectionPrefs(secPrefs)
        Dim origin(2) As Double
        origin(0) = loc.X
        origin(1) = loc.Y
        origin(2) = loc.Z
        Dim tabnote As NXOpen.Tag
        ufs.Tabnot.Create(secPrefs, origin, tabnote)
        ' Delete all existing columns and rows (we create them as needed)
        Dim nmRows As Integer = 0
        ufs.Tabnot.AskNmRows(tabnote, nmRows)
        For ii As Integer = 0 To nmRows - 1
            Dim row As NXOpen.Tag
            ufs.Tabnot.AskNthRow(tabnote, 0, row)
            ufs.Tabnot.RemoveRow(row)
            ufs.Obj.DeleteObject(row)
        Next
        Dim nmColumns As Integer = 0
        ufs.Tabnot.AskNmColumns(tabnote, nmColumns)
        For ii As Integer = 0 To nmColumns - 1
            Dim column As NXOpen.Tag
            ufs.Tabnot.AskNthColumn(tabnote, 0, column)
            ufs.Tabnot.RemoveColumn(column)
            ufs.Obj.DeleteObject(column)
        Next
        ' Now add our columns as needed
        Dim columns(nColumns - 1) As NXOpen.Tag
        For ii As Integer = 0 To nColumns - 1
            '   ufs.Tabnot.SetColumnWidth(columns(ii), 10)
            ufs.Tabnot.CreateColumn(40, columns(ii))
            ufs.Tabnot.AddColumn(tabnote, columns(ii), UFConstants.UF_TABNOT_APPEND)
        Next
        ' Now add our rows as needed
        Dim rows(nRows - 1) As NXOpen.Tag
        For ii As Integer = 0 To nRows - 1
            ufs.Tabnot.CreateRow(40, rows(ii))
            ufs.Tabnot.AddRow(tabnote, rows(ii), UFConstants.UF_TABNOT_APPEND)
        Next
        Return tabnote
    End Function

    Public Function Distancepoint3d(ByVal pt1 As Point3d, ByVal pt2 As Point3d) As Double
        Dim l1 As Double = 0.0
        If Math.Abs(pt1.X - pt2.X) < 0.01 And _
            Math.Abs(pt1.Y - pt2.Y) < 0.01 And _
            Math.Abs(pt1.Z - pt2.Z) < 0.01 Then
            l1 = 0.0
        Else
            l1 = Math.Sqrt((pt2.X - pt1.X) * (pt2.X - pt1.X) + _
                                             (pt2.Y - pt1.Y) * (pt2.X - pt1.Y) + _
                                             (pt2.Z - pt1.Z) * (pt2.Z - pt1.Z))
        End If
        Return l1
    End Function
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
End Module

Regards

Frank Swinkels
 
Hello Frank,
Again Thanks, we are close.
The intersecting point chart is important as on XYZ & radius values, program is fed in to CNC tube bender & operations are carried out. Can you please look at the attached program which I have.

1.
In this program (point_chart.grx), everything is fine, except, it does not prompt for entering radius value, which is important for the product. (If needed, i can send you screen-grab how it prompts & works)
This will give you an idea so that you can modify your program or edit this program. In this pogram, its not necessary for the model to be sweep, as it derives the coordinate chart by just picking the intersecting points.

2.
I have also attached slide (just 2 pages) about prompting for picking the points, start point, radius & generates the required output on drawing (these coordinate chart is prepared in CATIA, I have similar program in place in CATIA which is in VB)

Attachments:


Thanks,
Sundeep
 
I cannot think that you want a program that not only requires one to actually pick the intersection points but also enter the radii. That is before this different program is executed you would need to create the intersection points. If that is so we have no link between the point and the radius. In the original post you indicated you were unhappy with the pipebend program so I thought (incorrectly) that I should look at a feature selection (it is possible to also do this with tubes). I think it most inappropriate to manually enter the radii unless you use only one radius? Even then should a user be allowed to enter any value?

The additional point ID input on the drawing can be done but I am not prepared to write the code using the point selection method you propose because it is not a good approach. Sorry.

Frank Swinkels
 
Not a Problem, Thanks for all your efforts.[smile]

Regards,
Sundeep Panchal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor