Access CATIA V5 with win32com (LONG)

goermezer at htp-tel.de goermezer at htp-tel.de
Thu Nov 18 10:55:16 EST 2004


Hello,

I got it ! There was an example (for Office I think) in the test-directory of
Pywin32, where I have the first lines from. But this is dynamic binding. Can
anybody explain this for early binding ?

And it would be fine when the pulldown-menu in Pythonwin works to see the
exposed Methods of the Type Libraries.
-----------------------------------------------------------

import win32com.client

dispatch = win32com.client.dynamic._GetGoodDispatch("CATIA.Application")
typeinfo = dispatch.GetTypeInfo()
attr = typeinfo.GetTypeAttr()
olerepr = win32com.client.build.DispatchItem(typeinfo, attr, None, 0)
catia = win32com.client.dynamic.CDispatch(dispatch, olerepr)
dispatch = typeinfo = attr = olerepr = None

doc = catia.ActiveDocument.Product
print "------------------"
print "Number : Partname:"
print "------------------"
count = catia.ActiveDocument.Product.Products.Count
for partnum in range(count):
    print "Part", partnum + 1, ":",
catia.ActiveDocument.Product.Products.Item(partnum+1).Name
---------------------------------------------------------------

This is the result. And it works fine.

------------------
Number : Partname:
------------------
Part 1 : 433275-14.1
Part 2 : Part1.1
Part 3 : Part3.1
Part 4 : Product5.1

------------------------------------
htp - Hannovers Telefon Partner GmbH
http://www.htp-tel.de



More information about the Python-list mailing list