API problem in 2005?
API problem in 2005?
(OP)
Has anyone had any problems with the basic Solidworks objects in Solidworks 2005? My code includes the following lines in a sub (pretty standard stuff):
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Debug.Print swModel.GetPathName
When I run the code I get a run-time error 91: "Object variable or with block variable not set" at the debug.print line above. The swmodel variable is also "nothing" at the point where the error occurs, even though Solidworks 2005 is running and I have a document open. I'm using VB6.
Any thoughts?
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Debug.Print swModel.GetPathName
When I run the code I get a run-time error 91: "Object variable or with block variable not set" at the debug.print line above. The swmodel variable is also "nothing" at the point where the error occurs, even though Solidworks 2005 is running and I have a document open. I'm using VB6.
Any thoughts?






RE: API problem in 2005?
BBJT CSWP
RE: API problem in 2005?
BBJT CSWP
RE: API problem in 2005?
When editing the macro, in the VB environment, go to Tools/References and check the box "sldworks 2005 type library". Otherwise the Dim command will not be recognized with this sintax.
Regards
RE: API problem in 2005?
This piece of code is how most of the examples in the API help begin. I'm wondering why it won't work in Solidworks 2005.
Thanks!
RE: API problem in 2005?
BBJT CSWP
RE: API problem in 2005?
System: Dell Precision 650—Intel Xeo @ 2.66 GHz with 1/2G RAM
OS: Windows 2000 SP3
Graphics: NVidia Quadro FX 500 128Mb (OpenGL set to Solidworks)
Version: Solidworks 2005, SP0.1
RE: API problem in 2005?
>> selected in references and IActiveDoc2 gave me the
>> same error as ActiveDoc.
Try a little voodoo here. Bring up the 'References' window again, select the SldWorks.tlb file, and "Browse" back to the file in your SWX install dir, and re-select it.
RE: API problem in 2005?
I am facing the same problem as engAlright.
Please let me know what you did to solve this.
ifrg
RE: API problem in 2005?
Are you sure you have an open document? Also, are you running VBA (macro recorder) or VB/VB.NET?
Evan
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: API problem in 2005?
RE: API problem in 2005?
Haven't tried it on SP1.1 though...
RE: API problem in 2005?
CODE
use this:
CODE
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: API problem in 2005?
RE: API problem in 2005?
set swApp=CreateObject("SldWorks.Application")
or
Set swApp=New SldWorks.SldWorks
VBA runs as an internal process to SW, so you can just use the
Set swApp=Application.SldWorks
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...