获取焊接的重量

无论是装配或零件都有MassProperties属性,其中包含了重量。焊接是基于装配多出来的部分。在用户界面可以看到这个信息。





API里是如何做呢?其实焊接也是一个组件(Occurrence)。能访问到其MassProperties。请看如下代码:


Sub getWeldMass()


    Dim oAssDoc As AssemblyDocument
    Set oAssDoc = ThisApplication.ActiveDocument
    
    Dim cd As ComponentDefinition
    Set cd = oAssDoc.ComponentDefinition
    
    ' 通常第一个Occurrence是焊接
     Dim oO As ComponentOccurrence
     Set oO = cd.Occurrences(1)
    
    If TypeOf oO.Definition Is WeldsComponentDefinition Then
        
        '总重,API里是千克
        Dim oTotalWeldsMass As Double
        oTotalWeldsMass = oO.MassProperties.Mass
         
         '转换为文档所用的单位制数据
         Dim oMassValueOfDocUnit As String
         oMassValueOfDocUnit = oAssDoc.UnitsOfMeasure.GetStringFromValue(oO.MassProperties.Mass, oAssDoc.UnitsOfMeasure.MassUnits)
        
        MsgBox ("重量是: " & oMassValueOfDocUnit)
       
    Else
       MsgBox ("有错误!")
     
    End If
    
End Sub



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值