Hi @austin.massey6W6WX . I've added a Try-Catch method to each line so that in the event of an error, it will show you a problem message.
Dim oDDoc As DrawingDocument
Try
oDDoc = ThisDoc.Document
Catch
MessageBox.Show("Active document is not drawing document", "Error 1!",MessageBoxButtons.OK,MessageBoxIcon.Error)
End Try
Dim oUnits As UserParameter
Try
oUnits = oDDoc.Parameters.UserParameters("Model_Units")
Catch
MessageBox.Show("Failed to get parameter 'Model_Units'", "Error 2!",MessageBoxButtons.OK,MessageBoxIcon.Error)
End Try
Dim oDStyle As DimensionStyle
Try
oDStyle = oDDoc.StylesManager.DimensionStyles("Default-in[mm] (ANSI)")
Catch
MessageBox.Show("Failed to get DimensionStyle", "Error 3!",MessageBoxButtons.OK,MessageBoxIcon.Error)
End Try
Try
If oUnits.Value = "Imperial (Standard)" Then
oDStyle.LinearUnits = UnitsTypeEnum.kInchLengthUnits
oDStyle.AlternateLinearUnits = UnitsTypeEnum.kMillimeterLengthUnits
Else
oDStyle.LinearUnits = UnitsTypeEnum.kMillimeterLengthUnits
oDStyle.AlternateLinearUnits = UnitsTypeEnum.kInchLengthUnits
End If
Catch
MessageBox.Show("Failed to change dimension", "Error 4!",MessageBoxButtons.OK,MessageBoxIcon.Error)
End Try