Jegsaran
Automotive
- Dec 16, 2020
- 42
I have a VBA code which gets the centerpoint coordinate of an edge. I want that to be done in python.
I tried various methods mentioned below using win32com & pycatia but nothing worked.
Code:
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim ref As Reference
Dim SPA As Workbench
Dim Measurable
Dim csCoords(2)
Dim Sel As Selection
Set Sel = CATIA.ActiveDocument.Selection
Set ref = Sel.Item(1).Reference
Set SPA = partDocument1.GetWorkbench("SPAWorkbench")
Set Measurable = SPA.GetMeasurable(ref)
Measurable.GetCenter csCoords
Sel.Clear
I tried various methods mentioned below using win32com & pycatia but nothing worked.
Python:
# Pycatia
coordinates = measurable.get_point()
#win32com.client
coordinates = [0.0, 0.0, 0.0]
measurable.GetPoint(coordinates)
coordinates = pythoncom.CreateSafeArray(pythoncom.VT_VARIANT, 3)
measurable.GetPoint(coordinates)