×
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

API: opening a part with SW Viewer

API: opening a part with SW Viewer

API: opening a part with SW Viewer

(OP)
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

RE: API: opening a part with SW Viewer

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)

RE: API: opening a part with SW Viewer

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.

batHonesty may be the best policy, but insanity is a better defense.bat
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: API: opening a part with SW Viewer

Another tidbit of information from here.

Quote (SolidWorks API Examples site):


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)

RE: API: opening a part with SW Viewer

(OP)
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.

RE: API: opening a part with SW Viewer

(OP)
Ah, yes, you already pointed that out. :) I'll try to read the whole post next time...

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