Add and Offset Dimension Extension Lines Jogs (VBA)
This example shows how to jog the selected dimension's extension lines
and to then offset the jogs.
'----------------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDisplayDim As SldWorks.DisplayDimension
Dim swModelView as SldWorks.ModelView
Dim boolstatus As Boolean
Dim index As Integer
Dim jogged As Boolean
Dim offset1 As Double, offset2 As Double, offset1to2 As
Double
Dim rect as Variant
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelView = swModel.ActiveView
Set swSelMgr = swModel.SelectionManager
Set swModelDocExt = swModel.Extension
boolstatus = swModel.ActivateView("Drawing
View1")
Stop
' Interactively select a linear or ordinate dimension
' Programmatically get the dimension
Set swDisplayDim = swSelMgr.GetSelectedObject6(1,
-1)
' Add jogs to the dimension's extension lines
boolstatus = swModelDocExt.JogDimension(True,
0)
boolstatus = swModelDocExt.JogDimension(True,
1)
' Offset the jogs
index = 0
boolstatus = swDisplayDim.GetJogParameters(index,
jogged, offset1, offset2, offset1to2)
offset1 = offset1 + offset1 * 0.1
offset2 = offset2 + offset2 * 0.2
offset1to2 = offset1to2 + offset1 * 0.2
boolstatus = swDisplayDim.SetJogParameters(index,
jogged, offset1, offset2, offset1to2)
index = 1
boolstatus = swDisplayDim.GetJogParameters(index,
jogged, offset1, offset2, offset1to2)
offset1 = offset1 + offset1 * 0.1
offset2 = offset2 + offset2 * 0.2
offset1to2 = offset1to2 + offset1 * 0.2
boolstatus = swDisplayDim.SetJogParameters(index,
jogged, offset1, offset2, offset1to2)
swModelView.GraphicsRedraw ((rect))
End Sub