This is a work in progress. It might give you some insight. Since I can't post .swp files you will have to do your best to recreate the form.
In a module paste the following:
Sub main()
Load ListFeatures ListFeatures.Show 0
End Sub
In a form paste the following after creating a form with a Userform called ListFeatures, two command buttons labled CommandButton1 and 2, a label named Label1, a treeview named TreeView1 and a textbox labeled TextBox1. You must have Microsoft TreeView Control 6.0 checked in the tool pallete. Arrange the tools as you see fit but make sure both the text box and treeview can scroll.
'
****************************************************************************** ' C:\DOCUME~1\KELLNERP\LOCALS~1\Temp\swx332\Macro1.swb - macro recorded on 07/13/05 by kellnerp '
****************************************************************************** Dim swApp As Object Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim FeatureData As Object Dim Feature As Object Dim Component As Object Dim swFeat, swChildFeat As SldWorks.Feature Dim vChildArr As Variant Dim FeatNum As Long
Private Sub CommandButton1_Click()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Label1.Caption = Part.GetPathName
Set Feature = Part.FirstFeature
TreeView1.Nodes.Clear
FeatNum = 1 Do While Not Feature Is Nothing Fname = Feature.Name TreeView1.Nodes.Add , , Fname, Fname 'TreeView1.Nodes.Add Feature.Name, tvwChild, Feature.Name, Feature.Name 'TreeView1.Nodes.Add "root", tvwChild, "child2_root", "Child2 of Root" 'TreeView1.Nodes.Add "child1_root", tvwChild, "child1_child1", "Child1 of Child1"
TextBox1.Text = TextBox1.Text & Chr(13) & Format(FeatNum, "00000") & "==============" & Chr(13) TextBox1.Text = TextBox1.Text & "Name = " & Feature.Name & " [" & Feature.GetTypeName & "]" & Chr(13) TextBox1.Text = TextBox1.Text & "Created By = " & Feature.CreatedBy & Chr(13) TextBox1.Text = TextBox1.Text & "Created Date = " & Feature.DateCreated & Chr(13) TextBox1.Text = TextBox1.Text & "Modified Date = " & Feature.DateModified & Chr(13)
vChildArr = Feature.GetParents If Not IsEmpty(vChildArr) Then
TextBox1.Text = TextBox1.Text & " Parents:"
For Each vChild In vChildArr
Set swChildFeat = vChild
TextBox1.Text = TextBox1.Text & " " + swChildFeat.Name
- " [" + swChildFeat.GetTypeName + "]" & Chr(13)
Next vChild Set swChildFeat = vChildArr(0) Cname = swChildFeat.Name TreeView1.Nodes.Remove (Fname)
Debug.Print TreeView1.Nodes.Item(Cname) TreeView1.Nodes.Add Cname, tvwChild, Fname, Fname ''TreeView1.Nodes.Add Fname, tvwChild, , swChildFeat.Name
'Debug.Print TreeView1.Nodes.Item(Fname) End If
TreeView1.Nodes(TreeView1.Nodes.Count).EnsureVisible
Set Feature = Feature.GetNextFeature() FeatNum = FeatNum + 1 Loop
End Sub
Private Sub CommandButton2_Click() End End Sub
Private Sub UserForm_Click()
End Sub