Sub 质心() '质心生成固定工作点
If ThisApplication.ActiveDocumentType <> kPartDocumentObject Then
Exit Sub
End If
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim fd As BrowserNodeDefinition
On Error Resume Next
Dim oCenterOfMass As Point
Set oCenterOfMass = oDoc.ComponentDefinition.MassProperties.CenterOfMass
Dim oWorkPoint As WorkPoint
Set oWorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("质心")
If Err.Number = 0 Then
Dim oFixedDef As FixedWorkPointDef
Set oFixedDef = oWorkPoint.Definition
oFixedDef.Point = oCenterOfMass
oDoc.Update
Else
Set oWorkPoint = oDoc.ComponentDefinition.WorkPoints.AddFixed(oCenterOfMass)
oWorkPoint.Name = "质心"
End If
End Sub