Anonymous
in reply to:
Anonymous
10-19-2016
04:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-19-2016
04:15 AM
Ok, it kind of made it work. The code below just shows one messagebox with all parts which contain one or more of the appearance provided. You can change the appearance name at the first line. Not too user friendly but at least it is easier to install and distribute then a form. If you have a better idea, please do let me know.
Dim appearanceToFind As String = "Default"
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'Create a dictionary which will be used to store the appearances
Dim Appearances As Object
Appearances = CreateObject("Scripting.Dictionary")
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
'format file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
'Get the part face
Dim oFaces As Faces
oFaces = docFile.ComponentDefinition.SurfaceBodies(1).Faces
'Loop through each face and store the part in the dictionary if the appearance matches
Dim oFace As Face
For Each oFace In oFaces
If appearanceToFind = oFace.Appearance.DisplayName Then
Appearances(docFName) = Appearances(docFName)
End If
Next
Next
Dim partList As String
'Display the contents of the dictionary
For Each Item In Appearances
partList += Item + vbLf
Next
MessageBox.Show("Parts found with appearance " & appearanceToFind & ":" & vbLf & partList)