Код: Выделить всё
import win32com.client
from pycatia import catia
# Open the CATIA document
caa = catia()
# Open the CATIA document
documents = win32com.client.Dispatch('CATIA.Application').Documents
file_name = './Part.CATPart'
part_document = documents.Open(file_name)
part = part_document.Part
bodies = part.Bodies
body = bodies.Item('PartBody')
# Access the Sketch
sketches = body.Sketches
sketch = sketches.Item('Sketch.1')
# Open the sketch for edition
factory2D = sketch.OpenEdition()
# Access the geometric elements in the sketch
geometric_elements = sketch.GeometricElements
# Find the specific point by name
point_name = 'Point.22'
point = None
for i in range(1, geometric_elements.Count + 1):
element = geometric_elements.Item(i)
if element.Name == point_name:
point = element
break
# Check if the point was found and retrieve its coordinates
if point is not None:
try:
# Assuming the point has X, Y properties directly accessible
x = point.X
y = point.Y
print(f"Coordinates of {point_name}: X={x}, Y={y}")
except AttributeError as e:
print(f"{point_name} found but coordinates could not be retrieved: {e}")
try:
coord = point.GetCoordinates()
except Exception as e:
print(e)
else:
print(f"{point_name} not found in the sketch.")
# Close the sketch edition
sketch.CloseEdition()
Есть какие-нибудь предложения? Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/788 ... ng-pycatia