I'm trying to add the prefix '2X' to a slot dimension using the API. I have been able to add the text successfully but when I do the slot dimensions no longer update if the slot changes size. To fix the problem I can cut the text out of the PropertyManager and paste it back in. Has anyone successfully added a prefix to a slot dimension using the API?
Here is my code that updates the slot dimension;
Const strInc As String = "X "
Const strSlotCallout As String = "
Dim strDimensionTextCalloutAboveDefinition As String = swDisplayDimension.GetText(swDimensionTextParts_e.swDimensionTextCalloutAboveDefinition)
Dim strDimensionTextPrefixDefinition As String = swDisplayDimension.GetText(swDimensionTextParts_e.swDimensionTextPrefixDefinition)
If strDimensionTextCalloutAboveDefinition.Contains(strSlotCallout) Or strDimensionTextPrefixDefinition.Contains(strSlotCallout) Then
intNumValue = Val(strDimensionTextPrefixDefinition)
If intNumValue = 0 Then intNumValue = 1
If strDimensionTextPrefixDefinition.Contains(strInc) Then strDimensionTextPrefixDefinition = strDimensionTextPrefixDefinition.Replace(Format(intNumValue) & strInc, "")
intNumValue = intNumValue + x
If strDimensionTextPrefixDefinition.Contains(strSlotCallout) Then
strDimensionTextPrefixDefinition = strDimensionTextPrefixDefinition.Replace(strSlotCallout, "")
End If
If intNumValue > 1 Then
swDisplayDimension.SetText(swDimensionTextParts_e.swDimensionTextPrefixDefinition, Format(intNumValue) & strInc & strDimensionTextPrefixDefinition & strSlotCallout)
Else
swDisplayDimension.SetText(swDimensionTextParts_e.swDimensionTextPrefixDefinition, strDimensionTextPrefixDefinition & strSlotCallout)
End If
End If
SolidworksApi macros