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!

Help with Macro Syntax 1

Status
Not open for further replies.

Tobin1

Petroleum
Nov 9, 2007
176
Howdy All!

I probably didn't write a "good" question the last time :) . I hope this is better.
I'm having trouble understanding the "SolidWorks and Add-Ins API Help" concerning the syntax for the GetBalloonInfo method.

I'm just doing an experiment to see if I can get and display in the MessageBox the coordinates of a SW Balloon.

Attached is a file with a snapshot of the SW Help and my attempt to interpret the help.

Can anybody show me how to do this?

Thanks

Tobin Sparks
 
Replies continue below

Recommended for you

No wonder you are having trouble. The function is void, meaning it has no arguments. You need something like:

dim myArr as variant

myArr = swNote.getballooninfo

Then you can get values out of myArr, which is an array of doubles.

Also, is most of the code from your actual macro removed? If not, you need a bunch more code to tell SW what note swNote refers to. Simply pre-selecting one prior to running the macro isn't enough. You have to use the selection manager to get a pointer to the selected note.

-handleman, CSWP (The new, easy test)
 
Try this:

Code:
Option Explicit

' Precondition: Select a balloon on a SW Drawing

Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swNote As SldWorks.Note
Dim SelMgr As SldWorks.SelectionMgr
Dim retval As Variant
Dim sMsg 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 swNote = SelMgr.GetSelectedObject6(1, -1)

retval = swNote.GetBalloonInfo

sMsg = "Balloon Center:" & vbCrLf & "X: " & retval(0) & _
        vbCrLf & "Y: " & retval(1) & vbCrLf & _
        "Z: " & retval(2) & vbCrLf & vbCrLf & "Arc Point:" & _
        vbCrLf & "X: " & retval(3) & vbCrLf & "Y: " & retval(4) _
        & vbCrLf & "Z: " & retval(5)
        
MsgBox sMsg

End Sub

-handleman, CSWP (The new, easy test)
 
handleman,

Thanks for your response. You seem to be the one that is always very helpful to me. I was wondering about the selection manager thing. I'll have to see what I can do since trying to "record" something like that doesn't seem to cause a reaction.

Thanks Again


Tobin Sparks
 
handleman,
You responded a second time before I could thank you for the first one :) . Man you are really good. I'll let you know how it turns out.

Thanks Again

Tobin Sparks
 
handleman,

Well that really does the trick.
I still don't see how you were able to turn that SW API help page into this code. I mean now that you wrote it out I can kinda sorta see where you got it from, but, I could have looked at the SW API Help for a week and not produced what you did.

Now I'll have to let this sink in a bit to see how I can use it.

Thanks Again :)

Tobin Sparks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor