Last active
July 9, 2020 18:07
-
-
Save WolfpackWilson/9185e787b1dae488575e832f38cf0709 to your computer and use it in GitHub Desktop.
A small script to test extracting information from CATIA via Python [instead of VBA]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client | |
def get_catia(): | |
catia = win32com.client.Dispatch("CATIA.Application") | |
return catia | |
def main(): | |
cat = get_catia() | |
doc = win32com.client.gencache.EnsureDispatch(cat.ActiveDocument) | |
part = doc.Part | |
print(part.Name) | |
bodies = part.Bodies | |
part_body = bodies.Item(1) | |
for i in range(1, part_body.Shapes.Count + 1): | |
print(part_body.Shapes.Item(i).Name) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes for iterating through CATIA objects:
win32com.client.gencache.EnsureDispatch
seems to be required for each new library object/interface.Item
attributes do not appear under<obj>._pro_map_get_
but underdir(<obj>)
.Application
andParent
.