Created
January 26, 2009 19:16
-
-
Save listrophy/52923 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' MACRO NAME: | |
' AddQuantity | |
' AUTHOR: | |
' Bradley Grzesiak | |
' FUNCTION: | |
' Increments the quantity of one or many dimensions in a drawing | |
' INSTALL: | |
' Create a "New Macro Button" via Tools->Customize->Commands->Macro in a toolbar. | |
' It is highly recommended that you assign a keystroke to this macro. I use "q" | |
' COMPATIBILITY: | |
' SolidWorks 2009. | |
' Minor changes in selectionManager code may make this somewhat backwards compatible | |
Dim swApp As SldWorks.SldWorks | |
Dim swModel As ModelDoc2 | |
Dim swSelMgr As SelectionMgr | |
Dim swDim As DisplayDimension | |
Dim theText As String | |
Dim firstChar As String | |
Dim nextChar As String | |
Dim newNum As Integer | |
Dim newText As String | |
Sub main() | |
Set swApp = Application.SldWorks | |
Set swModel = swApp.ActiveDoc | |
Set swSelMgr = swModel.SelectionManager | |
For i = 1 To swSelMgr.GetSelectedObjectCount2(-1) | |
Set swDim = swSelMgr.GetSelectedObject6(i, -1) | |
ChangeDim swDim | |
Next i | |
swModel.GraphicsRedraw2 | |
End Sub | |
Sub ChangeDim(swDim) | |
theText = swDim.GetText(swDimensionTextPrefix) | |
firstChar = Left(theText, 1) | |
If firstChar <= "9" And firstChar > "0" Then | |
nextChar = Mid(theText, 2, 1) | |
If nextChar <= "9" And nextChar >= "0" Then | |
newNum = Int(firstChar - "0") * 10 + Int(nextChar - "0") + 1 | |
newText = newNum & Mid(theText, 3) | |
Else | |
newNum = Int(firstChar - "0") + 1 | |
newText = newNum & Mid(theText, 2) | |
End If | |
Else | |
newText = "2X " & theText | |
End If | |
swDim.SetText swDimensionTextPrefix, newText | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment