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

时间:2015-02-23 08:05:23

标签: vba catia

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

3 个答案:

答案 0 :(得分:0)

很抱歉,存储在零件或产品中的测量值不会在API中公开。

答案 1 :(得分:0)

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

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!

You can also find here a method to get distance value between two parts,但需要知道您希望与

保持距离的部分

答案 2 :(得分:0)

想象最简单的情况:

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。