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
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
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
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
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