【问题标题】:extracting measurements from .catpart in CATIA V5在 CATIA V5 中从 .catpart 中提取测量值
【发布时间】:2015-02-23 08:05:23
【问题描述】:

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

【问题讨论】:

    标签: vba catia


    【解决方案1】:

    抱歉,存储在部件或产品中的度量值不会暴露在 API 中。

    【讨论】:

      【解决方案2】:

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

      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,但它需要知道你想从中获得距离的部分

      【讨论】:

        【解决方案3】:

        想象最简单的情况:

        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
            • 长度=10mm
          • MeasureEdge.2
            • 长度=100mm

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

        【讨论】:

          猜你喜欢
          • 2014-05-14
          • 1970-01-01
          • 2012-07-03
          • 2019-07-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多