Not getting instance of Edge

I've done a macro that works on most machines, I'm using the same connect routine as I normally do.

I'm using Marshal.GetActiveObject to get the running instance of Edge but it does not seem to work on some machines.

Any ideas.

 

TIA,

James

 

Posted by: James Singleton
Post date: 2/14/2007 12:46:48 AM

10 REPLIES

RE: Not getting instance of Edge

Hey James,

 

On the machines that it fails, try this:

 

Open Excel

Tools -> Macros -> Visual Basic Editor

Double click "ThisWorkbook"

Paste this code

 

 

Sub Test()

Dim objApp

Set objApp = GetObject(, "SolidEdge.Application")

If Not objApp Is Nothing Then

MsgBox "Got it!"

Else

MsgBox "GetObject() failed!"

End If

End Sub

 

 

Now press F8 and see what you get. If Excel's VBA can connect to Solid Edge then it would appear to be a .NET issue. If it can't then it would appear that Solid Edge is not getting registered in the ROT (Running Object Table).

 

Are we dealing with the exact same versions of Solid Edge here? Is there anything common about the ones that fail? OS, SE Ver., etc.

 

Posted by: Jason Newell
Post date: 2/14/2007 5:34:35 AM

RE: Not getting instance of Edge

Hi Jason, thanks for the response.

 

Windows XP Pro, SE v19 with various service packs. Mostly everything else is the same. Don't know if it makes a difference but some of the ones it does not work on are AMD processors.

My gut feeling is that Edge is not getting registered in the ROT, is there any way I can check if it is?

 

I first saw this with the nSided Polygon macro that ships with edge, the hexpro macro worked on the same machine so I concluded it must be .Net. I thought it was an isolated incident at the time and didn't manage to find a cure.

I have had some issues with ocx's/dlls not being registered in V19 on various machines and am wondering if this problem is as a result of something like that.

 

Thanks again,

James

 

 

Posted by: James Singleton
Post date: 2/15/2007 1:54:59 AM

RE: Not getting instance of Edge

James,

 

There is a very old program called irotview.exe that shipped with older versions of Visual Studio. I can't find it on my machine and I couldn't find it via google but if you can find it then you can view the ROT.

 

Did you try the excel VBA code on the machine that didn't work?

 

Posted by: Jason Newell
Post date: 2/15/2007 2:20:29 AM

RE: Not getting instance of Edge

Found a downloadable irotview.exe

 

irotview.exe

 

Posted by: Jason Newell
Post date: 2/15/2007 2:27:23 AM

RE: Not getting instance of Edge

Hi Jason,

Yes tried the excel code and it works fine, only .NET that does not work.

Thanks for the link to the irotview I'll give it a go.

 

James

 

Posted by: James Singleton
Post date: 2/16/2007 2:54:47 AM

RE: Not getting instance of Edge

James,

 

If the excel code works then it is registered in the ROT. Read this artcile and see if it applies to your situation.

 

KB316125

 

Posted by: Jason Newell
Post date: 2/16/2007 3:25:06 AM

RE: Not getting instance of Edge

I'm sure this is an easy one for most of you. Along the lines of grabbing and existing instance of Solid Edge, how can I determine which one fires off an .exe if there are multiple SE windows open?

 

For example, if the FIRST SE windows contains a .dft and the SECOND containes an .asm. If the user call a BOM program from within the 2nd window, it automatically connects to the FIRST SE occurance.

 

Since I use VB6 and am not familiar with creating add-ins, this is a problem I constantly run in to.

 

Thanks,

 

Posted by: Bill Ledbetter
Post date: 2/20/2007 6:04:29 AM

RE: Not getting instance of Edge

Bill,

 

This is a 30 second fix on the Solid Edge side. Here is the root problem. GetObject(, "SolidEdge.Application") will only return the 1st instance of Solid Edge, as you've described. Have you ever wondered what the 1st parameter of GetObject() does? It's the difference between "File Monikers" & "Item Monikers".

 

Bascially if you knew the path to the assembly, you could do a GetObject("C:\Asm1.asm") and get the 2nd instance of Solid Edge. See the following code.

 

Dim objApp As SolidEdgeFramework.Application

Dim objDocument1 As SolidEdgeFramework.SolidEdgeDocument

Dim objDocument2 As SolidEdgeFramework.SolidEdgeDocument

 

Set objApp = GetObject(, "SolidEdge.Application")

Set objDocument1 = GetObject("C:\Draft1.dft")

Set objDocument2 = GetObject("Asm1.asm") *File may not be saved yet.

 

So objApp is the same as objDocument1.Application (i.e. The 1st instance of Solid Edge), but it is not the same comapred to objDocument2.Application. Make sense?

 

So here's what we need to do. You need to submit an IR with the following verbage:

 

--Begin IR--

 

Since Solid Edge's "Run Macro" command does not pass the path of the current file as a command line parameter to the macro executable, a macro has no reliable method of attaching to the desired specific instance of Solid Edge, assuming there are multiple. This means that if we have 2 instance of Solid Edge running concurrently and the "Run Macro" command is executed in the 2nd instance, the macro will no be able to connect to the 2nd instance when it calls GetObject(, "SolidEdge.Application"). If the full path to the file were to be specified to the macro as a command line parameters, the macro could then call GetObject("C:\Asm1.asm") to get a reference to the 2nd instance of Solid Edge.

 

' Running Object Table (ROT) Example

' Keywords: "Item Moniker" & "File Moniker"

Dim objApp As SolidEdgeFramework.Application

Dim objDocument1 As SolidEdgeFramework.SolidEdgeDocument

Dim objDocument2 As SolidEdgeFramework.SolidEdgeDocument

 

Set objApp = GetObject(, "SolidEdge.Application") '1st SE instance

Set objDocument1 = GetObject("C:\Draft1.dft") '1st SE instance

Set objDocument2 = GetObject("Asm1.asm") '2nd SE instance. File may not be saved yet.

 

--End IR--

 

 

Posted by: Jason Newell
Post date: 2/20/2007 7:29:00 AM

RE: Not getting instance of Edge

Hi Jason,

Sorry for not getting back sooner, been out of the office and unable to test.

 

I ran the irotview.exe and it is shown in the ROT, also tried the steps in that KB artical still with no effect

 

James

 

Posted by: James Singleton
Post date: 3/1/2007 12:20:07 AM