reclosedev / pyautocad

AutoCAD Automation for Python ⛺
http://pypi.python.org/pypi/pyautocad/
BSD 2-Clause "Simplified" License
497 stars 142 forks source link

To get the coordinate of the intersection point of a grid by clicking the point #54

Open son00007 opened 7 months ago

son00007 commented 7 months ago

When I run this python code for the captioned, the error occured as follows, File "c:\Users\sonsun\AppData\Local\Programs\Python\Python311\Lib\site-packages\comtypes\automation.py", line 843, in _invoke self.__com_Invoke(memid, riid_null, lcid, invkind, dp, var, None, argerr) _ctypes.COMError: (-2147352567, '예외가 발생했습니다.', ('Invalid argument Point in GetPoint', 'AutoCAD', 'C:\Program Files\Autodesk\AutoCAD 2019\HELP\OLE_ERR.CHM', -2145320939, None)) for the following code, from pyautocad import Autocad, APoint acad = Autocad(create_if_not_exists=True) doc = acad.ActiveDocument def gpuser(): sp = APoint(0, 0, 0) # Initializing sp with coordinates (0, 0, 0) ep = APoint(0, 0, 0) # Initializing ep with coordinates (0, 0, 0) rp = APoint(0, 0, 0) # Initializing rp with coordinates (0, 0, 0) sp = doc.Utility.GetPoint("\nBottom-left corner on the column:") ep = doc.Utility.GetPoint("\nBottom-right corner on the column:") rp = doc.Utility.GetPoint("\nTop-left corner on the row:") print("sp(1) input =", sp[0]) # Assuming you want to print the X coordinate of the 'sp' point gpuser() How can I fix the error and to get the correct response from the active autocad drawing. Thanks in advance, Sun, Son

CEXT-Dan commented 7 months ago

ActiveX get point can accept a base point. Play around with

GetPoint(None, Prompt) or GetPoint(pythoncom.Empty, Prompt) or

From my wrappers https://github.com/CEXT-Dan/PyRx/blob/fb2f51acf279239869f7d24d1040647f996e8ca5/PyRxStubs/AxApp24.py#L24705-L24715