Example 4 - chg_dim.swb
' ******************************************************************************
' 10/6/99 - chg_dim.swb
' Macro that will prompt for a data file and import dimensional values
' format of data file should be TAB delimeted Dimension name and value
' D1@Sketch1 3
' D2@Sketch1 3.22
' D1@BaseExtrude 2.5
' ******************************************************************************
Dim swApp As Object
Dim modelDoc As Object
Dim datastr As String
Dim DimName As String
Dim DimValue As Double
Sub main()
Set swApp = GetObject (,"SldWorks.Application")
Set modelDoc = swApp.ActiveDoc
FileName = "data.dat"
FileName = InputBox("Enter File to Open","File Open",FileName)
Open FileName For Input As #1
Do While Not EOF(1)
Line Input #1, datastr
DimName = Left(datastr,Instr(datastr,Chr(9))-1)
DimValue = Val(Right(datastr,Len(datastr)-Instr(datastr,Chr(9))))
retval = modelDoc.Parameter(DimName).SetValue2(DimValue, 1)
Loop
modelDoc.EditRebuild
modelDoc.GraphicsRedraw2
Close #1
End Sub