Reply

Detect multiple Solid Edge instances and connect selectively

Is there a way to detect multiple running SE instances? Its common in our company to work with two SE instances, one with managed Teamcenter mode and one for local files. Usually, I'd want my program to connect to the SE instance which is focued at the moment. However, it always connects to the one that was opened first.

14 REPLIES

Re: Detect multiple Solid Edge instances and connect selectively

It is possible via the IRunningObjectTable interface. I've done it in the past but don't have any sample code handy to show. What programming language are you using? A quick google search turned up this article that has some sample code. Take a look at it and if you still need help, I'd be happy to code an example.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Detect multiple Solid Edge instances and connect selectively

Well this sucks. I got the code working but it appears that you still cannot get a reference to the 2nd instance of Solid Edge. The following code uses the running object table API and I do see two entries but the call to GetObject() end up referencing only one of the instances. Very strange. Perhaps Solid Edge development can shed some light into this observation.

 

public static SolidEdgeFramework.Application[] GetRunningInstances()
{
    List<SolidEdgeFramework.Application> instances = new List<SolidEdgeFramework.Application>();
    Type type = Type.GetTypeFromProgID(SolidEdge.PROGID.Application);
    var clsid = type.GUID.ToString();

    // get Running Object Table ...
    IRunningObjectTable rot = null;
    GetRunningObjectTable(0, out rot);

    if (rot != null)
    {
        // get enumerator for ROT entries
        IEnumMoniker monikerEnumerator = null;
        rot.EnumRunning(out monikerEnumerator);

        if (monikerEnumerator != null)
        {
            monikerEnumerator.Reset();

            IntPtr pNumFetched = new IntPtr();
            IMoniker[] monikers = new IMoniker[1];

            while (monikerEnumerator.Next(1, monikers, pNumFetched) == 0)
            {
                IBindCtx bindCtx;
                CreateBindCtx(0, out bindCtx);
                if (bindCtx == null)
                    continue;

                string displayName;
                monikers[0].GetDisplayName(bindCtx, null, out displayName);

                Guid pClassID = Guid.Empty;
                monikers[0].GetClassID(out pClassID);
                        
                if (displayName.IndexOf(clsid, StringComparison.OrdinalIgnoreCase) > 0)
                {
                    object comObject;
                    rot.GetObject(monikers[0], out comObject);

                    if (comObject != null)
                    {
                        var applicationInstance = comObject as SolidEdgeFramework.Application;
                        if (applicationInstance != null)
                        {
                            instances.Add(applicationInstance);
                        }
                    }
                }

            }
        }
    }

    return instances.ToArray();
}

 

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Detect multiple Solid Edge instances and connect selectively

I ran into the exact same problem. It detects how many instances there are, but the list always contains the same COM object. I tried to mess around with the moniker, but no luck there.

Re: Detect multiple Solid Edge instances and connect selectively

Has anyone found a way around this?  I purposely write macros, instead of addins, because I don't have to worry about making SE unstable and all the support nightmares that brings.  But, we have more and more need to have multiple SE sessions.

Re: Detect multiple Solid Edge instances and connect selectively

As a community, I believe we are out of things to try. Someone filing an IR with GTAC seems to be the next prudent step.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Detect multiple Solid Edge instances and connect selectively

I struggled on this topic few years ago without result.

Having a way to attach with proper solidedge instance would be very very useful.

 

Meanwhile, i have found some hints googling around i unfortunately don't have too much time to spend with.

 

http://blogs.msdn.com/b/andreww/archive/2008/11/30/starting-or-connecting-to-office-apps.aspx

 

Look at "AccessibleObjectFromWindow" way. I can potentially enumerate windows and return the application object via the window, then check using SEApp.ProcessID if the instance is really the instance i need to attach into.

 

It's just a desperate attempt, but maybe it could work.

Re: Detect multiple Solid Edge instances and connect selectively

Hello,

 

is there any progress on this issue? With ST8 it is still not working. The ROT returns always the same instance. No way to get one of the other running instances.

 

Has anybody sent a request to siemens already? If so, could you please send me the ticket number? We are going to file another request and if we have the number of an existing request then it might get more attention at siemens.

 

Thanks,

tole

Re: Detect multiple Solid Edge instances and connect selectively

FYI, running multiple instances of Solid Edge is not a supported workflow.  Therefore there should be no expectation to get code to run multiple instances either. 


There is an existing ER 5717477 on this.

Re: Detect multiple Solid Edge instances and connect selectively

Hello Dave,

 

having multiple instances is a required workflow in some cases.

 

For example: If we want to update a draft file of a larger construction then this can take hours. During this time the instance is completely locked down and cannot be used. Thus we have to open a second instance to continue working. Sure, a job server would be an option, but why waste the CPU power of the local PC? Beside that it requires additional licences and people would have to wait until their job is being processed.

 

We are currently able to run one visible instance and several invisible instances in the background for certain long running tasks (which are being controlled by our program). This works as long as the visible instance is the oldest one and the macros / other programs are getting this instance. Once the user closes the visible instance and opens a new one then one of the invisible instances might become the oldest one and things are getting messy...

 

Therefore we need code to iterate over all open instances and select the one we want. We would flag the invisible instances in some way and would add code to all macros to ignore the flagged instances.

 

Thank you for the quick response and the ticket number. We will add our request there.

 

Greetings,

tole