ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
TSTony Szuta27/05/2008
I am traversing through the assembly tree. I am looking at the children in the assembly. If the child component is an assembly, I would like to perform a certain procedure. If it is a part, then I need it to do something else. I tried to apply typical logic to this and I just can't get it to work. I am trying to get the file type of the child.

For this line (swChildComp.GetType = swDocPART) I am getting the following error.
Operator '=' is not defined for types 'System.Type' and 'Integer'.

In my program I have tried everything. Here is what I have so far:

VB.NET CODE

 


Public Class Editor

Public Enum swDocumentTypes_e
swDocNONE = 0 ' Used to be TYPE_NONE
swDocPART = 1 ' Used to be TYPE_PART
swDocASSEMBLY = 2 ' Used to be TYPE_ASSEMBLY
swDocDRAWING = 3 ' Used to be TYPE_DRAWING
End Enum

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssy As SldWorks.AssemblyDoc
Dim swConf As SldWorks.Configuration
Dim swRootComp As SldWorks.Component2
Dim bRet As Boolean
Dim swChildComp As SldWorks.Component2
Dim swCompConfig As SldWorks.Configuration
Dim sPadStr As String
Dim mo As Integer
Dim ModDoc As Object

Sub TraverseComponent(ByVal swComp As SldWorks.Component2, ByVal nLevel As Long)

Dim vChildCompArr As Object
Dim vChildComp As Object
Dim swChildComp As SldWorks.Component2
Dim SupState As Long

ProgramStatus.Text = "Adding Components"
StatusStrip1.Refresh()
vChildCompArr = swComp.GetChildren
For Each vChildComp In vChildCompArr
swChildComp = vChildComp
ModDoc = swChildComp.GetModelDoc
SupState = swChildComp.GetSuppression


If (swChildComp.GetType = swDocASSEMBLY) then 'Process Assemblies
'Do Something Here
End If
If (swChildComp.GetType = swDocPART) then 'Process Parts Only
'Do Something Else Here
End If

DataGridView1.Refresh()
TraverseComponent(swChildComp, nLevel + 1)
Next

End Sub
End Class

Any help is appreciated.