Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: Anonymous

So far I have this code which outputs all appearances found in a separate messagebox each (from parts in an assembly).

 

'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 faces
Dim oFaces As Faces
oFaces = docFile.ComponentDefinition.SurfaceBodies(1).Faces

'Loop through each face and store the appearance in the dictionary
Dim oFace As Face
For Each oFace In oFaces
Appearances(oFace.Appearance.DisplayName) = Appearances(oFace.Appearance.DisplayName)
Next

'Display the contents of the dictionary
For Each Item In Appearances
MessageBox.Show("Part: " & docFName & vbLf & "Appearance: " & Item)
Next
Next

However, I am not sure how to make a form where I can input an appearance name and then format the dictionary so it displays only the parts which contains that appearance.

 

Any ideas?