Hallo.
Brauche eure Hilfe
Irgendwie schaffe ich es nicht das doppelte Umbenennen zu verhindern.(siehe Bilder)
Steher_40x40_1, Steher_40x40_1 und Steher_40x40_1 sind Gleichteile.
würde gerne so unbennant haben:
Steher_40x40_1
GT_zu_Steher_40x40_1
GT_zu_Steher_40x40_1
...
...
...
'-------------------------------ANFANG--------------------------------------------------------
Sub CatMain()
Dim objPart As Part
Dim objBody As Body
Dim objInertia As Inertia
Dim Selection1 As Selection
Set Selection1 = CATIA.ActiveDocument.Selection
Set objPart = CATIA.ActiveDocument.Part
selection1.clear
selection1.Search "CATPrtSearch.BodyFeature.Name=STEHER_40x40_*,all"
Dim Value(2)
Dim Value1(2)
Dim Text
Dim Text3
Dim Text4
Imax = Selection1.count
'-------------------------------------------------------------------------------------------
For J = 1 to Selection1.count
Set objBody1 = Selection1.item2(J).Value
MsgBox objBody1.Name
'--------------------------------------------------------------------------------------------
'Do while Imax
Text=objBody1.Name ' Zeichenfolge definieren
Text3 = Left(Text,2) ' liefert GT_zu_
Text4 = "GT"
'If Text3=Text4 then y=x+1
'If NOT(Text3=Text4) then x=x+1
'If Text3=Text4 then Set objBody1 = Selection1.item2(y).Value
'If NOT(Text3=Text4) then Set objBody1 = Selection1.item2(x).Value
'loop
'--------------------------------------------------------------------------------------------
Set objBody1 = Selection1.item2(J).Value
Set objInertia = GetBodyInertia(objPart, objBody1)
objInertia.GetPrincipalMoments Value
'V1 = Value(0)
'V2 = Value(1)
'V3 = Value(2)
V1=round(Value(0),9)*10000000
V2=round(Value(1),9)*10000000
V3=round(Value(2),9)*10000000
'MsgBox "REFERENZ____"& objBody1.Name & vbNewLine & "M1=" & V1 & vbNewLine & "M2=" & V2 & vbNewLine & "M2=" & V3 '----------------------------------
'------------------------------------------------------------------------------------------
For K = J+1 to Imax
Set body2 = Selection1.Item2(K).Value
Set objInertia = GetBodyInertia(objPart, body2)
objInertia.GetPrincipalMoments Value1
'V11 = Value1(0)
'V21 = Value1(1)
'V31 = Value1(2)
V11=round(Value1(0),9)*10000000
V21=round(Value1(1),9)*10000000
V31=round(Value1(2),9)*10000000
'MsgBox "UNTERKOERPER__"& body2.Name & vbNewLine & "M1=" & V11 & vbNewLine & "M2=" & V21 & vbNewLine & "M2=" & V31 '----------------------------------
IF (V11=V1) and (V21=V2) and (V31=V3) then body2.Name = "GT_zu_" & objBody1.Name
'-------------------------------------------------------------------------------------------
Next
Next
MsgBox "FERTIG"
End Sub
'----------------------------------------------------------------------------------------
Function GetBodyInertia(ByRef iPart As Part, ByRef iBody As Body) As Inertia
Dim objSPAWorkbench As Workbench
Dim objInertia As PrincipalMoments
On Error Resume Next
Set objSPAWorkbench = iPart.Parent.GetWorkbench("SPAWorkbench")
Set objInertia = objSPAWorkbench.Inertias.Add(iBody)
If Err.Number = 0 Then
Set GetBodyInertia = objInertia
Else
Set GetBodyInertia = Nothing
End If
'-------------------------------------------------------------------------------------
End Function
'-------------------------------ENDE--------------------------------------------------
------------------
Ich will es gar nicht wissen, aber ich muss.....Das Leben verlangt es.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP