繁体   English   中英

在CATIA V5中从.catpart提取测量值

[英]extracting measurements from .catpart in CATIA V5

我有.CATPART,并且已经手动完成了测量。 我想使用CAT VBA创建宏,并从.CATPART中提取测量值并将其导出到excel。

抱歉,API中未公开零件或产品中存储的度量。

我从来没有找到解决方案,但是这里的代码允许从用户选择中获取测量结果。 您无法解析所有度量,但是可以选择它们并解析选择(此示例仅适用于所选的一个度量,如果可能的话,您必须适应许多度量):

Set oSelection = CATIA.ActiveDocument.Selection
On Error Resume Next
sName = oSelection.Item2(1).Value.Name
On Error Goto 0
'selection should be named with "catiabase"
If InStr(LCase(sName), "catiabase") = 0 Then Exit Function
'Get Name
'PROBLEM: This search will empty the selection if no measurement is selected
oSelection.Search "Name=Length,sel"
'No Length, no measurement (here i need only 1 selection)
If oSelection.Count2 <> 1 Then Exit Function

'Get name of measurement
sName = oSelection.Item2(1).Value.Name 'not the same as previous!

您还可以在此处找到一种获取两个零件之间的距离值的方法 ,但是它需要知道您要从中获取距离的零件

想象最简单的情况:

Sub CATMain()

''Get ActiveDocument
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

''Get Part
Dim part1 As Part
Set part1 = partDocument1.Part

''Get list of parameter of part
Dim oParams As Parameters
Set oParams = part1.Parameters

Dim PatternFind As String
PatternFind = "Measure"

''MsgBox all values of the parameter that contains 'Measure'
For Each item In oParams
    If InStr(item.Name, PatternFind) <> 0 Then
        MsgBox (item.Name & " = " & item.value)
    End If
Next

End Sub

[树状视图]

  • 第1部分
  • 措施
    • MeasureEdge.1
      • 长度=10毫米
    • MeasureEdge.2
      • 长度为100mm

您应该进行必要的修改才能导出到Excel。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM