0
我開發了一段CATVBA代碼來重命名和協調幾何集合下的點。這裏的問題是,我可以重新命名點,但協調不起作用。我能夠在幾何設置下獲得每個點的座標值,但設置協調不起作用。請檢查並告訴我們是否有任何解決方案。 P.S: - 我想做同一點的座標,不想用座標值創建任何新的點。謝謝。Point使用CATVBA重命名和協調
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
「x.HybridShapes.Item第(i + 1)設置座標座標「這是我用於座標點的地方,它不起作用 – Abdul
您確定所有座標點都是HybridShapePointCoord類型嗎? SetCoordinate方法僅適用於該類型的點。還有什麼點讀取座標,然後立即再次設置它們。 –
是的。在設置座標之前,我有「x.HybridShapes.Item(i + 1).GetCoordinates座標」,它給了我確切的座標值。 – Abdul