×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Help with Macro Syntax

Help with Macro Syntax

Help with Macro Syntax

(OP)
Howdy All!

I probably didn't write a "good" question the last time smile . 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
www.nov.com

RE: Help with Macro Syntax

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)

RE: Help with Macro Syntax

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)

RE: Help with Macro Syntax

(OP)
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
www.nov.com

RE: Help with Macro Syntax

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

Thanks Again

Tobin Sparks
www.nov.com

RE: Help with Macro Syntax

(OP)
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 smile

Tobin Sparks
www.nov.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources