I have developed a piece of CATVBA code to rename and coordinate points under a geometric set. Here the problem is, i can able to rename the points but the coordination is not working. I am able to get the coordinate value of each points under geometric set but set coordination is not working. Please check and let us know if any one has any solution. P.S:- I want to make coordinate of same point and don't want to create any new points with the coordinate values. Thanks.
Sub CATMain()
Dim MyObj As Object, pd1 As PartDocument, a As String
Dim Result As String
ReDim InputObjectType(0) As Variant
Dim MySelection As Object
If TypeName(CATIA.ActiveDocument) <> "PartDocument" Then
Message = MsgBox("This program only works on a CATPart.", vbDefaultButton1, "Error")
Exit Sub
End If
Set pd1 = CATIA.ActiveDocument
Set MySelection = pd1.Selection
ReDim InputObjectType(0)
InputObjectType(0) = "HybridBody"
MsgBox "Select a Geoset in which its elements needs to renamed."
Result = MySelection.SelectElement2(InputObjectType, "Select a Geoset in which its elements needs to renamed.", False)
If Result = "Normal" Then
Set MyObj = pd1.Selection.Item(1).Value
ElseIf Result = "Redo" Then
MsgBox "Redo is not an option for this program."
End
Else
End
End If
Call Dumb_Renumber(MyObj)
End Sub
Sub Dumb_Renumber(x As HybridBody)
Dim n As Double, i As Integer
Dim m As String
Dim PtString As String
Dim PtNumberOld As Integer, PtNumberNew As Integer
Dim ptName As String, NewPtName As String
Dim StartPos As Integer
m = InputBox("What would be your Prefix?", "Rename Input") 'get Prefix Input from user
n = InputBox("What number would you like to start with?", "Rename Input", "100") 'get suffix input from user
For i = 0 To x.HybridShapes.Count - 1
On Error Resume Next
Dim coord(2)
x.HybridShapes.Item(i + 1).GetCoordinates coord ' i am able to get Co ordinate value here
'MsgBox coord(0) & " " & coord(1) & " " & coord(2)
x.HybridShapes.Item(i + 1).SetCoordinates coord 'not able to set coordinate value
x.HybridShapes.Item(i + 1).Name = m & n + i 'this is to rename the elements under the selected geometric set
Next
End Sub