Get Component by Name (VB.NET)
This examples shows how to get a component by name and to determine
if that component is fixed or floating.
'-------------------------------------------
' Preconditions: Open:
' <SolidWorks_install_dir>\samples\tutorial\EDraw\claw\claw-mechanism.sldasm
'
' Postconditions: None.
'-------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics
Partial Class SolidWorksMacro
Dim
swModel As ModelDoc2
Dim
swAssy As AssemblyDoc
Dim
swComp As Component2
Public
Sub main()
swModel
= swApp.ActiveDoc
swAssy
= swModel
Dim
CompName As String
CompName
= "center-1"
swComp
= swAssy.GetComponentByName(CompName)
Debug.Print("Is
component fixed: " & swComp.IsFixed)
End
Sub
'''
<summary>
'''
The SldWorks swApp variable is pre-assigned for you.
'''
</summary>
Public
swApp As SldWorks
End Class