Access CATIA V5 with win32com (LONG)

Discussion in 'Python' started by, Nov 18, 2004.

  1. Guest


    I have some problems to automate a CAD (computer aided design) Software called
    CATIA V5 from Dassault Systemes.

    CATIA V5 has a builtin VB-Editor like Word, Excel, … and registers itself as a
    COM-server. With VB one can automate everything in CATIA V5 with a lot of
    registered Object Libraries.

    A VB example:
    'Create a new product document object by adding a document with the
    'type to the document collection of the CATIA application.
    Dim oProductDoc As Document
    Set oProductDoc = CATIA.Documents.Add("Product")

    'Retrieve the root product.
    Dim oRoot As Product
    Set oRoot = oProductDoc.Product

    'Retrieve the root product collection of products.
    Dim oRootCol As Products
    Set oRootCol = oRoot.Products

    The problem is that CATIA V5 has not only one Object Library like Word or Excel
    to get access for. Dassault splitted all functionalities of the CAD system
    to separate Object Libraries. Therefore to automate this CAD-system with Python
    I want to use the following Type Libraries in a script.

    "CATIA V5 Interfaces Object Library" to get access to the core functionalities
    of the CAD system (the Application):
    Similar to "Dim mydoc as Document" in VB - but in Python

    "CATIA V5 ProductStructureInterfaces ObjectLibrary" to get access to the parts
    of an mechanical assembly:
    Similar to "Dim my_product_document as Product" in VB - but in Python

    This should use both TypeLibs:

    import win32com.client
    catapp = win32com.client.Dispatch("CATIA.Application") # Connects to CATIA V5
    and uses CATIA V5 Interfaces Object Library
    my_product_document = catapp.ActiveDocument.Product #".Product" makes the error

    But the last 2 lines gives me the following error:
    AttributeError: '<win32com.gen_py.CATIA V5 InfInterfaces Object Library.Document
    instance at 0x19543064>' object has no attribute 'Products'

    Yes OK, the attribute "Product" is from "CATIA V5 ProductStructureInterfaces
    Object Library" (which has the CLSID {5065F8B6-61BB-11D1-9D85-0000F8759F82})
    and not from "CATIA V5 Interfaces Object Library" ("CATIA.Application") which I
    automatically use.

    When I try to use the CLSID of "CATIA V5 ProductStructureInterfaces Object
    Library" I get a Class not registered:

    import win32com.client
    catapp = win32com.client.Dispatch("CATIA.Application") # Connects to CATIA V5
    Interfaces Object Library
    catprod = win32com.client.Dispatch("{5065F8B6-61BB-11D1-9D85-0000F8759F82}")#
    Connects to CATIA V5 ProductStructureInterfaces Object Library

    To get access to the wanted ProductDocument Object I get an error:
    com_error: (-2147221164, 'Class not registered', None, None)

    How can I register it ?

    And how can I use both TypeLibs and can have access to the very important
    Product-Object? The builtin VB editor makes everything

    best regards

    Mustafa Görmezer

    htp - Hannovers Telefon Partner GmbH
    , Nov 18, 2004
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SoftStore2005
    Jan 10, 2006
  2. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Eric Sosman
    Jul 8, 2003
  3. Replies:
  4. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Peter Shaggy Haywood
    Sep 20, 2005
  5. Vikas
    David Harmon
    Aug 15, 2007

Share This Page