The command AddNewDirectionByCoord(0.000000, 0.000000, 1.000000) got the job done. –
Decode of The command AddNewDirectionByCoord(0.000000, 0.000000, 1.000000) got the job done. –
An error occurred: <unknown>.HybridShapes
An error occurred: <unknown>.HybridShapes
Traceback (most recent call last):
File "C:\Users\lenovo\PycharmProjects\pythonProject\venv\Trail_10.py", line 97, in <module>
hybridShapeLineExplicit1 = hybridShapes1.Item("Z Axis")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<COMObject <unknown>>", line 2, in Item
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'CATIAHybridShapes', 'The method Item failed', None, 0, -2147352573), None)
Process finished with exit code 1
import win32com.client as win32
def main():
try:
catia = win32.Dispatch("CATIA.Application")
documents = catia.Documents
part_document = documents.Add("Part")
part = part_document.Part
# Access the HybridShapes collection
hybrid_shapes = part.HybridShapes
# Create a point hybrid shape
point = hybrid_shapes.AddNewPointCoord(0, 0, 0)
point.Name = "MyPoint" # Set a name for the point
# Access the hybrid shape by name using .Item
retrieved_point = hybrid_shapes.Item("MyPoint")
print("Retrieved point hybrid shape:", retrieved_point.Name)
except Exception as e:
print("An error occurred:", str(e))
if __name__ == "__main__":
main()