Option Explicit Dim Classfac As SwDMClassFactory Dim swDocMgr As SwDMApplication Sub main() Const swFileName As String = "C:\Assem1.SLDASM" Dim swDoc As SwDocumentMgr.SwDMDocument5 Dim swDMSearchOp As SwDocumentMgr.SwDMSearchOption Dim varRef As Variant Dim brokenRefVar As Variant Dim swCfgMgr As SwDocumentMgr.SwDMConfigurationMgr Dim vCfgNameArr As Variant Dim vCfgName As Variant Dim swConfig As SwDocumentMgr.SwDMConfiguration2 Dim nDocType As Long Dim nRetVal As Long Set Classfac = CreateObject("SwDocumentMgr.SwDMClassFactory") Set swDocMgr = Classfac.GetApplication("") If Not InStr(LCase(swFileName), "sldasm") > 0 Then Exit Sub End If nDocType = swDmDocumentAssembly Set swDoc = swDocMgr.GetDocument(swFileName, nDocType, False, nRetVal): Debug.Assert swDmDocumentOpenErrorNone = nRetVal Set swDMSearchOp = swDocMgr.GetSearchOptionObject varRef = swDoc.GetAllExternalReferences2(swDMSearchOp, brokenRefVar) Set swCfgMgr = swDoc.ConfigurationManager vCfgNameArr = swCfgMgr.GetConfigurationNames For Each vCfgName In vCfgNameArr Debug.Print "ルートコンフィグレーション = "; vCfgName Set swConfig = swCfgMgr.GetConfigurationByName(vCfgName) swTraverseComp swConfig.GetComponents, varRef, 0 Next End Sub Private Sub swGetCompStatus(ByVal nComp As SwDocumentMgr.SwDMComponent2, ByVal nLevel As Long) Dim swXform As Variant Dim vTest As Variant Dim swPadStr As String Dim i As Long For i = 0 To nLevel swPadStr = swPadStr + " " Next i swXform = nComp.Transform Debug.Print swPadStr & "構成部品名 = "; nComp.Name Debug.Print swPadStr & "コンフィギュレーション = "; nComp.ConfigurationName If nComp.IsHidden Then Debug.Print swPadStr & "表示状態 = 非表示" Else Debug.Print swPadStr & "表示状態 = 表示" End If If nComp.IsSuppressed Then Debug.Print swPadStr & "抑制状態 = 抑制" Else Debug.Print swPadStr & "抑制状態 = 抑制解除" End If End Sub Private Sub swTraverseSubAssy(ByVal nAssyName As String, ByVal nAssyCfg As String, ByVal nLevel As Long) Dim swSubDoc As SwDocumentMgr.SwDMDocument5 Dim swSubDMSearchOp As SwDocumentMgr.SwDMSearchOption Dim swSubCfgMgr As SwDocumentMgr.SwDMConfigurationMgr Dim swSubConfig As SwDocumentMgr.SwDMConfiguration2 Dim varSubRef As Variant Dim brokenSubRefVar As Variant Dim nRetVal As Long Set swSubDoc = swDocMgr.GetDocument(nAssyName, swDmDocumentAssembly, False, nRetVal): Debug.Assert swDmDocumentOpenErrorNone = nRetVal Set swSubDMSearchOp = swDocMgr.GetSearchOptionObject varSubRef = swSubDoc.GetAllExternalReferences2(swSubDMSearchOp, brokenSubRefVar) Set swSubCfgMgr = swSubDoc.ConfigurationManager If nAssyCfg = "" Then nAssyCfg = swSubCfgMgr.GetConfigurationNames(0) End If Set swSubConfig = swSubCfgMgr.GetConfigurationByName(nAssyCfg) swTraverseComp swSubConfig.GetComponents, varSubRef, nLevel + 1 End Sub Private Sub swTraverseComp(ByVal nCompArr As Variant, ByVal nvarRef As Variant, ByVal nLevel As Long) Dim vComp As SwDocumentMgr.SwDMComponent2 Dim vFileName As String Dim nRetVal As Long Dim i, j As Long For i = 0 To UBound(nCompArr) swGetCompStatus nCompArr(i), nLevel Set vComp = nCompArr(i) If vComp.DocumentType = swDmDocumentAssembly Then For j = 0 To UBound(nvarRef) vFileName = swGetFileName(nvarRef(j)) If LCase(vComp.Name) + ".sldasm" = LCase(vFileName) Then swTraverseSubAssy nvarRef(j), vComp.ConfigurationName, nLevel End If Next j End If Next i End Sub Private Function swGetFileName(ByVal nFileName As String) As String Dim SplitName As Variant SplitName = Split(nFileName, "\") swGetFileName = SplitName(UBound(SplitName)) End Function