Public Sub WorkPointAtMassCenter()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
' 获取重心.
Dim oCenterOfMass As Point
Set oCenterOfMass = oDoc.ComponentDefinition.MassProperties.CenterOfMass
On Error Resume Next
Dim oWorkPoint As WorkPoint
Set oWorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("Center Of Mass")
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 = "Center Of Mass"
End If
End Sub效果图:
装配图及普通零件的重心标记(VBA)
未经允许不得转载:酷居科技 » 装配图及普通零件的重心标记(VBA)
很好的分享!
默默的学习怎么做。