Hallo ,
Ich möchte Fläche automatisch berechnen und als Parameter in Part eingetragen.
Das ist zuerst alles gut . Wenn ich aber neue  Body  erzeuge wird er nicht berechnet,
nur PartBody.
Wie kann ich die andere Body ( Body.2 ,Body.3 ...)ansprechen ?. Wie kann ich durch Makro mir die Anzahl von Body zeigen lassen .
----------------------------------------
Sub CATMain()
  
  Dim objPart As Part
  Dim objBody As Body
  Dim objMeasreable As Measurable
  Set objPart = CATIA.ActiveDocument.Part
  Set objBody = objPart.Mainbody
  Set objMeasreable = GetBodyMeasureable(objPart, objBody)
  
  Dim oParameter  As Parameter
  Dim Wert As String
  Set ProductDocument = CATIA.ActiveDocument
  
If Not (objMeasreable Is Nothing) Then
    Wert = objMeasreable.Area
    set oParameter = ProductDocument.Product.Parameters.item("Flaeche")
    oParameter.Value = Wert
Else
    MsgBox "The Measureable could not be retrieved!"
End If
End Sub
Function GetBodyMeasureable(ByRef iPart As Part, ByRef iBody As Body) As Measurable
  'If successful, this function will return an measreable object
  Dim objSPAWorkbench As Workbench
  Dim objMeasreable As Measurable
  Dim reference1 As Reference
  'On Error Resume Next
  Set objSPAWorkbench = iPart.Parent.GetWorkbench("SPAWorkbench")
  Set reference1 = iPart.CreateReferenceFromObject(iBody)
  Set objMeasreable = objSPAWorkbench.GetMeasurable(reference1)
  If Err.Number = 0 Then
    Set GetBodyMeasureable = objMeasreable
  Else
    Set GetBodyMeasureable = Nothing
  End If
End Function  
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP