Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Part Quantity From Item Balloon Macro

Status
Not open for further replies.

Tobin1

Petroleum
Nov 9, 2007
176
Howdy All,

I've been attempting to write a macro that will get the number of components related to an Item Balloon. This is just a test macro to see if I can do it simply. I've attached the macro I've been working with, but I need help figuring out the details. Or maybe I'm totally going in the wrong direction with this. There is some information in the Sw API help, but I can't seem to put it together right.

Does anybody already know how to do this or able to help?

Thanks

Tobin Sparks
 
Replies continue below

Recommended for you

Here's the Quickie-Dickie, Cheating-Charlie way to do it:

Code:
Option Explicit
' Precondition: Pre-selected balloon on a SW Drawing

Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Dim swBall As SldWorks.Note
Dim theOldUpperStyle As Long
Dim theOldUpperText As Long
Dim theOldLowerStyle As String
Dim theOldLowerText As String

Sub main()

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set SelMgr = swDoc.SelectionManager

If (SelMgr.GetSelectedObjectCount <> 1) Or (SelMgr.GetSelectedObjectType3(1, -1) <> swSelNOTES) Then
    MsgBox "Please select one balloon and try again."
    Exit Sub
End If

Set swBall = SelMgr.GetSelectedObject6(1, -1)

theOldUpperStyle = swBall.GetBomBalloonTextStyle(True)
theOldLowerStyle = swBall.GetBomBalloonTextStyle(False)
theOldUpperText = swBall.GetBomBalloonText(True)
theOldLowerText = swBall.GetBomBalloonText(False)

swBall.SetBomBalloonText theOldUpperStyle, theOldUpperText, swDetailingNoteTextQuantity, ""
MsgBox swBall.GetBomBalloonText(False)
swBall.SetBomBalloonText theOldUpperStyle, theOldUpperText, theOldLowerStyle, theOldLowerText

End Sub

I say "Cheating-Charlie", but I don't really see anything wrong with this method... at least not yet. :) That way you very easily get the quantity that you would have gotten by adding a quantity balloon.

-handleman, CSWP (The new, easy test)
 
It's better than the "Quickie-Dickie" method....

Chris
SolidWorks/PDMWorks 08 3.1
AutoCAD 06/08
ctopher's home (updated Apr 30, 2008)
 
Handleman,
Thanks you for your valuable help.

Ctopher,
Not sure I'd really want to here about the <"Quickie-Dickie" method> :) .

Thank you both for your responses

Tobin Sparks
 
Tobin,
Is this the same file you emailed me last week for testing?

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2008 SP 3.1
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
Howdy Colin,
No - this is something different. I'm going to add a few things to the Balloon Note that I sent you. I'm just trying to figure out the details.

Thanks

Tobin Sparks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor