Box Select a Sketch Example (VB.NET)
This example shows how to box select all of the entities in a sketch
block.
'---------------------------------------
' Preconditions: <SolidWorks_install_dir>\samples\tutorial\blocks\piston_mechanism.sldblk
' is
open.
'
' Postconditions:
' (1)
Notice the list of selected entities
' in
the PropertyManager page.
' (2)
Interactively quit the sketch without
' saving
any changes.
' (3)
Close the document.
'--------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Partial Class SolidWorksMacros
Public
Sub main()
Dim
swModel As ModelDoc2
Dim
swModelDocExt As ModelDocExtension
Dim
boolstatus As Boolean
swModel
= swApp.ActiveDoc
swModelDocExt
= swModel.Extension
'
Select the sketch and open it
boolstatus
= swModelDocExt.SelectByID2("Sketch1",
"SKETCH", 0, 0, 0, False, 0, Nothing, 0)
swModel.EditSketch()
swModel.ViewZoomtofit2()
'
Box select the sketch
boolstatus
= swModelDocExt.SketchBoxSelect("-0.034327",
"1.423590", "0.000000", "0.212609", "0.692279",
"0.000000")
End
Sub
'''
<summary>
'''
The SldWorks swApp variable is pre-assigned for you.
'''
</summary>
Public
swApp As SldWorks
End Class