So what Im trying to do is count how many xrefs are in my drawing. That part is simple
Here is that code
Public Sub PMS_Xref_Extract()
Dim ss As AcadSelectionSet, intType(0 To 1) As Integer, varData(0 To 1) As Variant
Dim objBlkXref As AcadExternalReference, strAssemblyName As String
Erase SN
Erase CNT
ACADSelSet ss, "AssemblyCount"
intType(0) = 0: varData(0) = "INSERT"
intType(1) = 2: varData(1) = "SC-*"
ss.Select Mode:=acSelectionSetAll, filtertype:=intType, filterdata:=varData
For Each objBlkXref In ss
If objBlkXref.Layer = "3D-CONSTRUCTION" Then
strAssemblyName = objBlkXref.EffectiveName
IncrimentCount strAssemblyName
End If
Next
Dim fso, fl, fln, s
Dim j As Integer
fln = "M:\PARTS-LIST\PMS.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(fln) Then
fso.DeleteFile fln
End If
Set fl = fso.CreateTextFile(fln)
For j = 1 To UBound(SN)
s = CNT(j) & vbTab & SN(j)
fl.WriteLine s
Next
fl.Close
End Sub
The problem is I need to count an xref inside of the first one found. I think this should be able to be done, but I have no clue. I know it has to do with nested blocks, but I dont know anything beyond that.
So I have a drawing named SC-04589-1211-162.dwg, which is a long name for a switch. Inside that dwg is another xref, SC-09020.dwg, which I have used twice. What I would like to have happen is when the above code is run, it returns (1) SC-04589-1211-162.dwg, and (2) instances of SC-09020.dwg