trim / sort object names

Hello everyone,
I have below questions:

1> I have a list of points named as A1,B1,C1,D1... for some instances i want to remove the numbers from the end of the name...

2> also i have a point list with names such as A1 to A3, B1 to B3, C1 to C3 and so on... while sorting the list i get the result as A1,A2,A3,B1,B2,B3... but i want my result to be A1,B1,C1 / A2,B2,C2 / A3,B3,C3...

could someone help me with the above issues...

Thanks

1) You can use the point's .Name property to get the current name, then use .net's string functions to modify it, and use the point's .SetName method to give it the new name.

2) The A1, A2, A3, B1, etc order is the normal alphabetical sort. If you want a different order, you will need to code your own sort algorithm. This is a general programming question and not related to the NXOpen API specifically; you might get good answers at a site such as stack overflow (your question may already be answered there). Alternatively, you might consider using groups in NX and group your points (A1, B1, C1...) (A2, B2, C2...). That way you could sort them alphabetically per group.

hi, thanks for your reply... i have found how to remove the number from the point name from the site you have mentioned... thanks again...
used the below expression in my code to remove numbers...

Dim answer As Integer = theUI.NXMessageBox.Show("Keep / Remove Numbers",
NXOpen.NXMessageBox.DialogType.Question, "Remove numbers from Point Names?")

If answer = 1 Then
For i As Integer = 0 to ptsPoints.Count -1
ptsCount += 1
ptsNames.Item(i) = Regex.Replace(ptsNames.Item(i), "[\d-]", String.Empty)
ptsNames.Add(ptsNames.Item(i))
Next
End If

Balaji

hi, i have managed to make a custom sort for my requirement.
my approach was like this:
1) Reverse the name using StrReverse

For Each tempObj As Point in ptsPoints
tempName = tempObj.Name
Dim revName As String = StrReverse(tempName)
Next

2) Then sort the String using,

ptsNames.Sort(AddressOf ComparePointNames)

Private Function ComparePointNames(ByVal x As String, ByVal y As String) As Integer

'case-insensitive sort
Dim myStringComp As StringComparer = StringComparer.CurrentCultureIgnoreCase
Return myStringComp.Compare(x, y)

3) While i tried to make a reverse of the sorted string again, i was not getting through. So, instead of making the reverse of the strings immediately after the sort, i have reversed the string just before entering the name in the tabular note... this was it is working. Is there a good way of doing this sort. Any ideas to make the journal better..??

theUfSession.Tabnot.SetCellText(cell, StrReverse(ptsNames.item(i)))

Thanks, B

Balaji