酷居科技

每个人都有属于自己的世界

装配图及普通零件的重心标记(VBA)

作者:ikuju 发布:2017/8/19 分类:科技 阅读: 次 2条评论

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

效果图:

SVIN[4G0_6]N4NR9W443ZYR

除非注明,本站所有文章均为 ikuju 原创,转载请注明出处! 标签:Inventor  VBA  
« 上一篇下一篇 »

装配图及普通零件的重心标记(VBA):目前有2条评论

发表留言:

快捷回复: Ctrl+Enter