Insert Explode Line Sketch and Route Line Example (VB.NET)
This example shows how to insert a route line in an explode line sketch.
'
---------------------------------------------------------------------------
' Preconditions: Open
' <SOLIDWORKS_install_dir>\samples\tutorial\cosmosfloxpress\ball
valve\ball_valve.sldasm
'
' Postconditions:
' (1)
An exploded view of the assembly is created.
' (2)
A route line, which is a type of explode line, is added.
' (3)
3DExplode1, the explode line sketch,
is located on the
' ConfigurationManager
tab. Click the ConfigurationManager
' tab
and expand default and ExplView1.
'
' NOTE: Because
this assembly is used in a SOLIDWORKS
' online
tutorial, do not save any changes when
' you
close the document.
'
---------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics
Partial Class SolidWorksMacro
Dim
swModel As ModelDoc2
Dim
swAssembly As AssemblyDoc
Dim
swModelDocExt As ModelDocExtension
Dim
swSelMgr As SelectionMgr
Dim
swSketch As Sketch
Dim
swSketchMgr As SketchManager
Dim
swEdge As Edge
Dim
edgesIn(1) As Edge
Dim
itemsToConnect As Object
Dim
itemsReverse(1) As Object
Dim
itemsPath(1) As Object
Dim
alongXYZ(1) As Object
Dim
boolstatus As Boolean
Sub
main()
swModel
= swApp.ActiveDoc
swAssembly
= swModel
swSelMgr
= swModel.SelectionManager
swModelDocExt
= swModel.Extension
swSketchMgr
= swModel.SketchManager
'
Explode the assembly
swAssembly.AutoExplode()
swModel.EditRebuild3()
swModel.ViewZoomtofit2()
'
Insert an explode line sketch
swSketchMgr.InsertExplodeLineSketch()
'
Select two edges for the route line
boolstatus
= swModelDocExt.SelectByID2("",
"EDGE", -0.006286592037611, 0.01346036693855, 0.001030754120677,
False, 0, Nothing, 0)
swEdge
= swSelMgr.GetSelectedObject6(1,
-1)
edgesIn(0)
= swEdge
swModel.ClearSelection2(True)
boolstatus
= swModelDocExt.SelectByID2("",
"EDGE", 0.005570973324609, 0.01354160258214, 0.1620508231301,
False, 0, Nothing, 0)
swEdge
= swSelMgr.GetSelectedObject6(1,
-1)
edgesIn(1)
= swEdge
swModel.ClearSelection2(True)
itemsToConnect
= edgesIn
itemsReverse(0)
= False
itemsReverse(1)
= False
itemsPath(0)
= True
itemsPath(1)
= False
alongXYZ(0)
= True
alongXYZ(1)
= False
'
Insert the route line in the explode line sketch
swSketch
= swModel.GetActiveSketch2
Debug.Print("Route
line inserted in explode line sketch? " & swSketch.InsertRouteLine(itemsToConnect,
itemsReverse, itemsPath, alongXYZ))
'
Close the explode line sketch
swSketchMgr.InsertExplodeLineSketch()
End
Sub
'''
<summary>
'''
The SldWorks swApp variable is pre-assigned for you.
'''
</summary>
Public
swApp As SldWorks
End Class