By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

Access CATIA V5 with win32com (LONG)

P: n/a
Hello,

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
Product
'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
my_product_document.Count()

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
automatically...

best regards

Mustafa Görmezer

------------------------------------
htp - Hannovers Telefon Partner GmbH
http://www.htp-tel.de
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.