This example shows how to automatically insert center marks in multiple drawing
views.
'----------------------------------------------------------------------------
' Preconditions: Open:
' install_dir\samples\tutorial\advdrawings\foodprocessor.slddrw
'
' Postconditions:
' 1.
Sheet3 is activated, and center marks are inserted in three of
' the sheet's views.
' 2. Center marks are inserted in three views of the sheet's views.
' 3. Drawing View7 is suppressed and unsuppressed.
'
' NOTE: Because the model is used elsewhere,
' do not save changes when closing it.
'
---------------------------------------------------------------------------
Imports
SolidWorks.Interop.sldworks
Imports
SolidWorks.Interop.swconst
Imports
System.Runtime.InteropServices
Imports
System
Partial
Class
SolidWorksMacro
Dim
Part As
ModelDoc2
Dim
Draw As
DrawingDoc
Dim
swModelDocExt as ModelDocExtension
Dim
swActiveView As
View
Dim
boolstatus As
Boolean
Sub
main()
Part = swApp.ActiveDoc
Draw = Part
swModelDocExt = Part.Extension
Draw.ActivateSheet("Sheet3")
' Insert center marks for all
holes, fillets, and slots in the specified views
boolstatus = Draw.ActivateView("Drawing
View7")
swActiveView = Draw.ActiveDrawingView
boolstatus = swActiveView.AutoInsertCenterMarks(7, _
11, _
True, _
True, _
True, _
0.0025, _
True, _
True, _
0)
' Suppress Drawing View7
boolstatus = swModelDocExt.SelectByID2("Drawing
View7", "DRAWINGVIEW",
0, 0, 0, False,
0, Nothing,
0)
Draw.SuppressView()
boolstatus = Draw.ActivateView("Drawing
View9")
swActiveView = Draw.ActiveDrawingView
boolstatus = swActiveView.AutoInsertCenterMarks(7, _
11, _
True, _
True, _
True, _
0.0025, _
True, _
True, _
0)
boolstatus = Draw.ActivateView("Drawing
View11")
swActiveView = Draw.ActiveDrawingView
boolstatus = swActiveView.AutoInsertCenterMarks(7, _
11, _
True, _
True, _
False, _
0.005, _
False, _
False, _
0)
Part.ClearSelection2(True)
' Unsuppress Drawing View7
boolstatus = Part.ActivateView("Drawing
View7")
boolstatus = swModelDocExt.SelectByID2("Drawing
View7", "DRAWINGVIEW",
0, 0, 0, False,
0, Nothing,
0)
Draw.UnsuppressView()
End
Sub
Public
swApp As
SldWorks
End
Class