Inventor 宏代码:遍历零件并设置可见性,并显示错误数量
Sub visableAll() Dim doc As AssemblyDocument Set doc = ThisApplication.ActiveDocument Dim comp As ComponentOccurrence Dim errorCount As Integer ' 用于记录错误数量 errorCount = 0 ' 初始化错误数量为0 On Error Resume Next ' 忽略错误 For Each comp In doc.ComponentDefinition.Occurrences comp.Visible = True If Err.Number <> 0 Then ' 如果发生错误 errorCount = errorCount + 1 ' 错误数量加1 Err.Clear ' 清除错误 End If Next comp On Error GoTo 0 ' 恢复错误处理 MsgBox "错误数量: " & errorCount ' 弹出消息框显示错误数量 End Sub
原文地址: https://www.cveoy.top/t/topic/gDsh 著作权归作者所有。请勿转载和采集!