Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API: opening a part with SW Viewer

Status
Not open for further replies.

razzendahcuben

Mechanical
Jan 10, 2009
79
The following code fails to open a part in SW Viewer. It opens the Viewer, but the OpenDoc6 method doesn't seem to work. Any ideas? Thanks.


========

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim part As ModelDoc2
Dim longstatus As Long, longwarnings As Long

Sub main()
'Set swApp = Application.SldWorks
'Set part = swApp.ActiveDoc

Set swApp = CreateObject("SWViewer.Application")

swApp.Visible = True

'Set retval = swApp.opendoc6(vFile, iType, 2, "", SWerror, SWwarning)
Set part = swApp.opendoc6("C:\1Keith\1types\2009\Assembly.SLDASM", 1, 0, "", longstatus, longwarnings)

End Sub
 
Replies continue below

Recommended for you

The SolidWorks viewer is a separate program.

It is not part of SolidWorks.

You cannot automate the SolidWorks viewer using SolidWorks API.

-handleman, CSWP (The new, easy test)
 
You may be able to use Windows API to open a doc in SW viewer. The Windows API call Shellexecute opens a doc in its default application. There may be a similar call to direct a doc to open with a particular application.

Another possibility might be to have the program change the default application, call ShellExecute, then change the default back to what it was.

[bat]Honesty may be the best policy, but insanity is a better defense.[bat]
-SolidWorks API VB programming help
 
Another tidbit of information from here.

SolidWorks API Examples site said:
Is there an API for SolidWorks Viewer?


The API for SolidWorks Viewer is disabled. However, there is an API for the eDrawings viewer. Download the eDrawings API SDK from the Downloads section of this web site.

-handleman, CSWP (The new, easy test)
 
I could use ShellExecute to open SW Viewer but if I open the part itself it will just open the default program, which is Solid Works.

I had heard that OpenDoc6 worked in SW Viewer in SW 2008 but perhaps I was mistaken.
 
Ah, yes, you already pointed that out. :) I'll try to read the whole post next time...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor