Discussion Groups

Robot Structural Analysis

Reply
Contributor
d.robin
Posts: 25
Registered: ‎11-29-2013
Accepted Solution

API Crash on exit

150 Views, 5 Replies
11-29-2013 05:53 AM

Hi,

 

I'm using vb.net 2010 with Robot RSA 2011 sp6 and 2012 sp5

 

I've got a crash on exiting Robot when my programm exit or when I call closeRobot like that :

 

 

Public Shared gRobotApplication As RobotOM.RobotApplication = New RobotOM.RobotApplication()
        Private Shared gProjet As RobotOM.RobotProject = Nothing

 

 Public Shared Sub closeRobot()
                If gProjet IsNot Nothing Then
                    gProjet.Close()
                    gProjet = Nothing
                End If
                If gRobotApplication IsNot Nothing Then
                    gRobotApplication.Quit(IRobotQuitOption.I_QO_DISCARD_CHANGES)
                    gRobotApplication = Nothing
                End If
        End Sub

Please use plain text.
Distinguished Contributor
mirko.jurcevic
Posts: 223
Registered: ‎01-12-2013

Re: API Crash on exit

12-03-2013 12:18 AM in reply to: d.robin

Have you tried by using interfaces:

 

Public Shared gRobotApplication As RobotOM.IRobotApplication = New RobotOM.IRobotApplication()
Private Shared gProjet As RobotOM.IRobotProject = Nothing

INTELIKA

Mirko Jurcevic M.Eng.
INTELIKA d.o.o.
www.intelika.hr
Please use plain text.
Contributor
d.robin
Posts: 25
Registered: ‎11-29-2013

Re: API Crash on exit

12-03-2013 12:37 AM in reply to: d.robin

Hi,

 

thx

it doesn't works... error :

Impossible d'effectuer un cast d'un objet COM de type 'System.__ComObject' en type d'interface 'RobotOM.IRobotApplication'. Cette opération a échoué, car l'appel QueryInterface sur le composant COM pour l'interface avec l'IID '{F787078F-CDE5-11D1-8FF1-00A02447BAAE}' a échoué en raison de l'erreur suivante : Cette interface n’est pas prise en charge (Exception de HRESULT : 0x80004002 (E_NOINTERFACE)).

Please use plain text.
Distinguished Contributor
mirko.jurcevic
Posts: 223
Registered: ‎01-12-2013

Re: API Crash on exit

12-03-2013 01:00 AM in reply to: d.robin

You're right. My answer was wrong.

 

Have you set reference to RobotOM?

 

I've tested this code and works for me:

 

Public Class Form1

    Public Shared gRobotApplication As RobotOM.RobotApplication = New RobotOM.RobotApplication()
    Private Shared gProjet As RobotOM.RobotProject = Nothing

    Public Shared Sub closeRobot()
        If gProjet IsNot Nothing Then
            gProjet.Close()
            gProjet = Nothing
        End If
        If gRobotApplication IsNot Nothing Then
            gRobotApplication.Quit(RobotOM.IRobotQuitOption.I_QO_DISCARD_CHANGES)
            gRobotApplication = Nothing
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        closeRobot()
    End Sub
End Class

 

I use C#, I'm not so much used to VB.NET ...

INTELIKA

Mirko Jurcevic M.Eng.
INTELIKA d.o.o.
www.intelika.hr
Please use plain text.
Product Support
Rafal.Gaweda
Posts: 5,596
Registered: ‎04-26-2010

Re: API Crash on exit

12-03-2013 09:44 AM in reply to: mirko.jurcevic
Try this approach to register / reregister interfaces:
http://forums.autodesk.com/t5/Robot-Structural-Analysis/VBA-Excel-macro-for-any-object-geometry-modi...


Rafal Gaweda
Please use plain text.
Contributor
d.robin
Posts: 25
Registered: ‎11-29-2013

Re: API Crash on exit

12-05-2013 02:18 AM in reply to: Rafal.Gaweda
I've a solution that works, all others I've tried do not work

Public Shared gRobotApplication As RobotOM.IRobotApplication = Nothing
Public Shared Sub killRobot()
Try
Dim PR As Process() = Process.GetProcessesByName("robot")
If PR.Length > 0 Then
For Each P As Process In PR
Try
gRobotApplication = New RobotOM.RobotApplication
gRobotApplication.Interactive = CInt(False)
gRobotApplication.Project.Close()
gRobotApplication = Nothing
P.CloseMainWindow()
Catch ex As Exception
addError(ex)
End Try
Next
End If
Catch ex As Exception
addError(ex)
End Try
End Sub
Please use plain text.