Jan 29
    2008

    Opening CATIA-V5 using VB.Net

    Shailesh Sangle
    Hi Friends,
                
                    I want to connect CATIA-V5 and VB.Net to create an application which will draft the machine parts (like knuckel,Cotter etc.), inputs for which will be supplied from Vb.net.
    I got the code for drafting parts into CATIA from macro application.I just want to know how to open CATIA window(when CATIA is running as well as not running). If u have code for this please reply me.
                    Guys, reply soon it is BE Project. Thanx in advance.
    Grzegorz Olesinski
    [IBS Poland]

    Dim CATIA As INFITF.Application

    CATIA = GetObject(, "CATIA.Application")

    If Err.Number 0 Then

       CATIA = CreateObject(CATIA.Application)

      CATIA.Visible = True

    End If

     

    Thats how to get/open Catia. You could search the forum - there are some topics about Catia in VB.NET

    Shailesh Sangle

    Thanks GRZECHU, for replaying.

    I typed the code given by u behind the button, but I got following error

    "A first chance exception of type 'System.Exception' occurred in Microsoft.VisualBasic.dll"

    could you help on it.Please, reply soon.

    Grzegorz Olesinski
    [IBS Poland]
    Did you add proper reference?
    Shailesh Sangle
    Yes I have added almost all the reference files. But if u know any important one then tell me, I will check it again
    Grzegorz Olesinski
    [IBS Poland]

    Look there:
    http://www.coe.org/Collaboration/DiscussionForum/ActiveDiscussions/tabid/210/forumid/10/postid/113709/view/topic/Default.aspx

    Do you get this error while compilling project in VB, or when you publish it on a servere? If while compilling, write in which line?

    Test Admin
    [Admin Group]

    I get this error for following line while compiling

    CATIA = GetObject(, "CATIA.Application")

    Grzegorz Olesinski
    [IBS Poland]

    Could you paste here code of whole function, in which you get this error? Or if it's to big, at least begin of it - head of the function and code you use to open catia.

    And I forgot about one thing - put: On Error Resume Next before line, when you got the error, and On Error GoTo 0 after End If

    Test Admin
    [Admin Group]
    Public Class Form1

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim CATIA As INFITF.Application

            CATIA = GetObject(, "CATIA.Application"

            If Err.Number 0 Then

                CATIA = CreateObject(CATIA.Application)

                CATIA.Visible = True

            End If

        End Sub
    End Class

    Error :  "first chance exception of type 'System.Exception' occurred in Microsoft.VisualBasic.dll "  it pop-up on Immediate window and not on error window.

    This is the code of program. I have not yet added any code for drafting, I thought I should open CATIA window first, then I will be no problem to draft part by code.
    Grzegorz Olesinski
    [IBS Poland]

    I've tried to invoke that kind of error, but I wasn't able. I hope you have Catia installed on your machine? You need to add InfInterfaces Object Library (InfTypeLib.tlb) to your project, put code like:

    Dim CATIA As INFITF.Application

            On Error Resume Next

            CATIA = GetObject(, "CATIA.Application"

            If Err.Number 0 Then

                CATIA = CreateObject(CATIA.Application)

                CATIA.Visible = True

            End If
            On Error GoTo 0

    and it must works

    Shailesh Sangle
    A first chance exception of type 'System.Exception' occurred in Microsoft.VisualBasic.dll
    A first chance exception of type 'System.NullReferenceException' occurred in Catia.exe
    A first chance exception of type 'System.NullReferenceException' occurred in Catia.exe

    Hi GRZECHU,
                 Now I started new project. In that I add the file- "
    InfTypeLib.tlb" as follows:
    Project - Add References - Browse - C:\Program Files\Dessult System\Bin\Intel_a\code\bin\IntTypeLib.tld. and typed the code given by u. Still it shows the above messages on Immediate windows.

    References includes:
     - INFITF
     - System
     - System.Data
     - System.Deployment
     - System.Drawing
     - System.window.forms
     - System.xml

    I don't have the original Catia software does it make any difference?
    Sorry for the inconvenience cause by me
    Grzegorz Olesinski
    [IBS Poland]
    I've seen VB applications work on "not original version" of catia, so it shouldn't be that. What kind of VB environment you use? You could try on Visual Basic 2005 Express - it's free. And to add references you can use as follow: Project - Add References - COM. There are all Catia references
    Test Admin
    [Admin Group]
    You can try this:

    1. Open command-line and change to your local CATIA-Install-Path (..intel_a\code\bin)
    2. execute cnext /unregserver  'Clears all settings
    3. execute cnext /regserver 'registers CATIA as a COM-Server

    After that, you should be able to select the INFITF.dll under the COM-Tab in the "AddReference"-Dialog.

    Another way to get  the CATIA-Object in your app is this:

    Dim CATIA As INFITF.Application
    CATIA = System.Runtime.InteropServices.Marshal.GetActiveObject("CATIA.Application"

    Hope that helps...
    regards
    Kaoru

    All Times America/New_York

    Copyright 2013 COE. All Rights Reserved
    800-COE-CALL - 330 N. Wabash Ave, Suite 2000 - Chicago, IL 60611 USA
    All material, files, logos and trademarks within this site are properties of their respective organizations.
    Terms of Service - Privacy Policy - Contact