Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

API: no brainer ?

Status
Not open for further replies.

rocheey

Industrial
Jan 21, 2001
230
God, I hope this one is a &quot;brainer&quot; <grin>

using: SW03, SP0

I just want to FORCE a new instance of SW to start, whether an instance is running or not.

Tried CREATEOBJECT, and even the NEW keyword
(set swapp=NEW SldWrks.SldWrks)

both resulted in hooking the existing application.

I coulda swore CreateObject worked for second instances, in earlier versions (b4 2001, i believe)
 
Replies continue below

Recommended for you

For all other applications, CreateObject will create a new instance. I am not sure how they did it, but it will only create a new instance if one is not opened.

Out of curiosity, why would you want another instance?

Anyway, it looks like you can shell a new instance. You'll have to use the existing instance to get the path of the executable, assuming you don't want to hardcode it. I just did this from a macro, so it may require some tweaking. But, run it and you'll get to applications.
Code:
Sub StartSWAgain()
    Dim sPath As String, res
    Set swApp = Application.SldWorks
    sPath = swApp.GetExecutablePath
    sPath = sPath & &quot;\SldWorks.exe&quot;
    res = Shell(sPath, 1)
End Sub

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Oops! That's &quot;two&quot; applications, not &quot;to&quot; applications.

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
well, Im not averse to shell/createprocess API calls,
but I still won't have the OLE object handle ...

'-------------------------------------------------
Set swApp = Application.SldWorks ' <--- handle of existing app

res = Shell(sPath, 1) ' <--- starts a second instance, but still have only the original OLE object handle.

'----------------------------------------------

Possibly I can use the processID here somehow.

The reason for this is that I have an application that runs pretty much continously, but does not take much resources.
It deals with SW files over a *slow* network connection, at several different IP's. Also, when opening assemblies, etc,
I generally have plenty of computing power left, the long delays are partially due to SW resolving references, etc.

Ive got 'uber-ram' in this box, so having an invisible copy that crawls around, doing it's thing, with an ability to run another copy manually on an as-needed basis, would be ideal.
 
Have you tried GetObject right after the Shell instance is fired up? This may give you the latest application handle.

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
I had a similar need to get the SolidWorks object for a second session. According to APIsupport, the program must expose some COM interfaces to receive the second session's object. I did not have the time at work to explore this so I have not gotten any further with it.

Regg [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor