AnsweredAssumed Answered

Prepending Hole Callout Macro Help

Question asked by Adam Doerr on Jan 16, 2019

I'm trying to create a simple macro that works as follows:

Prereqs - A drawing file is open that already has a customized hole callout inserted (ex: Dimension Text = <hw-fstsze>mm DR. THRU, actual text on the drawing = Ø8.0mm DR. THRU)

 

1. Select the hole callout on the drawing

2. Run the macro

3. The callout now shows the hole quantity in parenthesis before the previous code (Dimension Text code = (<NUM_INST>) <hw-fstsze>mm DR. THRU, actual text shown on drawing = (3) Ø8.0mm DR. THRU)

 

 

Here's my current macro code (I started from a very old macro we use for a similar process though that macro does not use any Solidworks callout variables):

Dim swApp As Object

Dim Part As Object

Dim Gtol As Object

Dim FeatureData As Object

Dim Feature As Object

Dim ENTERDATA As String

Dim CURRENT As String

Dim Component As Object

Dim OC As Variant

Dim SELOBJ As Object

Sub main()

Set swApp = CreateObject("SldWorks.Application")

Set Part = swApp.ActiveDoc

 

Set SELMGR = Part.SelectionManager

 

OC = SELMGR.GetSelectedObjectCount

 

If OC = 0 Then

MsgBox "PLEASE SELECT AN OBJECT OR OBJECTS!"

End If

 

For OI = 1 To OC Step 1

Set SELOBJ = SELMGR.GetSelectedObject3(OI)

CURRENT = SELOBJ.GetText(1)

ENTERDATA = "(<NUM_INST>) " & CURRENT

SELOBJ.SetText 1, ENTERDATA

 

Next

 

Part.WindowRedraw

End Sub

_____________________________________________________________________

 

The problem is that it gets rid of the <hw-fstsze> callout variable and replaces it with the assessed text, thereby partially eliminating the parametric capability of the callout (ie; the callout becomes (<NUM_INST>) Ø8.0mm DR. THRU). Can anyone help me keep the callout fully parametric?

 

To help illustrate the callouts here are some screenshots:

 

Pre-macro

 

Desired post-macro

 

Current post-macro

Outcomes