Using Solidworks API sample programs in visual basic
Using Solidworks API sample programs in visual basic
(OP)
I'm not familiar with visual basic...However, all I'm trying to do is use one of the sample programs in the Solidworks API for visual basics but I can't do it. It seems to compile just fine, but nothing happens, I don't know if I need to set something...I'm all confused...If any of you have any ideas please help me out...





RE: Using Solidworks API sample programs in visual basic
"use one of the sample programs in the Solidworks API for visual basics"
What exactly are you trying to do? and what have you included the VB app?
Remember...
"If you don't use your head,
your going to have to use your feet."
RE: Using Solidworks API sample programs in visual basic
RE: Using Solidworks API sample programs in visual basic
RE: Using Solidworks API sample programs in visual basic
Since you are not familar with Visual Basic, you may also not be familar with early binding (the way object variables are declared). The example you choose (and probably many others require that you set up VB for early binding. If you do a search in API help on early binding you will find two hits that should help you: "Early Binding" and "Early and Late Binding". Essentially what you have to do in VB is from the menu select Project, References. The References dialog will appear. From the list check "SldWorks 200x Type Library" and "SolidWorks 200x Constant type library". If you are using SolidWorks 2004 check the "SolidWorks Constant type library" (No year in the name). Now run the example program. It should work. Write back and let me know.
Regards,
Regg
RE: Using Solidworks API sample programs in visual basic
I tried what you suggested and it still doesn't work...It might be that I'm not putting the code in the right place in visual basic. When I go in, I choose standard EXE for project type, I then double click in the form and paste the code from solidworks, I then click start and nothing happens, no errors, nothing...I've been looking for online tutorials and they all seem to point in this direction for writing the code....Am I doing this right?
Thank for your help...
Javier
RE: Using Solidworks API sample programs in visual basic
You should really be running the example code from the VBA editor in SolidWorks. However, to run the code from VB, you must not paste the code into a form. You must remove the form and insert a module. Paste the code into the module, set your references and then change the line of code that reads:
Set swApp = Application.SldWorks
to
Set swApp = CreateObject("SldWorks.Application")
Now run the code. It should work. I just used your example code and followed the steps I described and it ran perfectly.
Having struggled with all this API stuff when I first began, I should have looked more closely at the example code. For that I say, I am sorry. I would have set you on a better course if I would have taken the time the first time.
Regards,
Regg
RE: Using Solidworks API sample programs in visual basic
What type of output did you get? I guess I still don't get anything or I am not clear where to look...I'll keep trying...but anyways thanks for all your help...I'm sure going in a better track now...
RE: Using Solidworks API sample programs in visual basic
From the VB menu select View, Immediate Window. I do not have the example code up right now but you should see some debug.print statements. That indicates that output goes to the immediate window. Anytime you see this statement in the examples, look for the output to be there. Funny, when I ran the program last night, the immediate window automatically opened for me. Maybe because I use it myself for debugging my programs. I am still learning too.
Regards,
Regg
RE: Using Solidworks API sample programs in visual basic
Thank you so much...It finally worked...
Javier B