AnsweredAssumed Answered

Keeping Current Prefix and Adding New One to Drawing Dimensions

Question asked by Jay Wagamon on Sep 24, 2014
Latest reply on Feb 3, 2015 by Lois Claracq

Hey Guys,

 

I am trying to make a macro that I select a drawing dimension and it keeps the current prefix and then adds a new prefix in front of the current prefix.  For example the dimension would be displayed as a diameter symbol and then the diameter.  I want to add a quantity in front of that diameter symbol without deleting the diameter symbol.  I am trying to modify my current macro that deletes the current prefix and am having problems getting the current prefix. Below is my current macro and snips of before and after for what I would like the macro to do.

 

Any help would be great!

before.JPG  after.JPG

'------------------------------------------------------

' This Macro will add 4 x in front of the dimension in a drawing

' and keep the original Dimension Prefix.

'

' Preconditions:

' 1. Open a drawing.

' 2. Select a dimension.

' -----------------------------------------------------

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swModelDocExt As SldWorks.ModelDocExtension

Dim boolstatus As Boolean

Dim swDispDim As SldWorks.DisplayDimension

Dim swDim As SldWorks.Dimension

Dim CurPrefix As System.String

 

 

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swModelDocExt = swModel.Extension

    Set CurPrefix = swDispDim.GetText(swDimensionTextPrefix)

    Set swDim = swDispDim.GetDimension

    boolstatus = swModelDocExt.EditDimensionProperties(0, 0, 0, "", "", True, 9, 2, True, 12, 12, "4 x CurPrefix ", "", True, "", "", False)

    swModel.ClearSelection2 True

End Sub

 

Thanks,

Jay

Outcomes