×
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

Getting Started, Basics, SW API

Getting Started, Basics, SW API

Getting Started, Basics, SW API

(OP)
hello all,

Im looking to integrate Excel and Solidworks 2001. I am using Visual Basic 6.0. As a test, I tried the following code, to extract data from Solidworks, and display on the screen:

Sub Command1_Click()

Dim swApp As Object
Dim Part As Object
Dim Length As Double

Set swApp = CreateObject("SldWorks.Application")

SwApp.Visible = True
swApp.UserControl = True

Set Part = swApp.ActiveDoc

Set Length = Part.Parameter("Line1@Sketch1").SystemValue

MsgBox("Line1 in sketch1 is of length: " & length & ".")

End Sub

I did this in Visual Basic as a Standard EXE (on a button click), not as a Macro. Solidworks is open at the time, and the sketch active.

Do i have to use macros?? If i use VB6.0, do i have to declare functions from .dll's?? if so, how do i know which functions are in which .dll??

When compiling, VB didnt like the line "Set Length = ..."

Any assistance is greatly appreciated

API Beginner

RE: Getting Started, Basics, SW API

I'm confused??

If your wanting to intergrate Excel into SW...Why are using VB?

In Fact Excel is already intergrated into SW. You can use Design Tables in SW parts and assemblies to get there. You can then use VBA to control those parts.

Plus you can take excel and make a spreadsheet that controls a SW part or assembly and it doesn't need to be embedded as a DT. See my website
http://members.sigecom.net/sbaugh/

Download ExcelVBAexample.zip

This will explain it better than I can write it.

If you are wanting to use dll's in your programs, your going to have to learn C++ I believe. I don't think VB can handle that.

I always record macro first, because I can usally get the proper API code required to do the job, but not always.

dsi is the best at answering these kind of Questions, but you may not hear from him till after the new year.

Hope that helps....?

Scott Baugh, CSWP
George Koch Sons,LLC
Evansville, IN 47714
sjb@kochllc.com

RE: Getting Started, Basics, SW API

(OP)
Thanks for your rapid reply.

Im more concerned about taking values FROM SW, and importing TO excel. Since i started this thread, ive had some luck. I asked about VB, as i plan to have a stand-alone program, that will have its own user interface and work with both programs. My understanding is that macros dont allow much user interfacing (just running in the background)

Please excuse my ignorance, im VERY new to all this.

seedie54

RE: Getting Started, Basics, SW API

The SystemValue property does not return an object, so you should not use the Set command.

Length = Part.Parameter("Line1@Sketch1").SystemValue

Don't forget that the SystemValue property returns a value of meters and Line1@Sketch1 should be the name of a dimension.


DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: Getting Started, Basics, SW API

What you want to do is write a comm add-in to solidworks - this will allow you to launch your application from a custom menu and/or toolbar.  The only tricky part is to properly register the add-in so that it shows up the in tools-addins list without pointing to it manually (not a problem if you are writing a custom app for deployment to only a few users).  

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