I'm trying to get XRecords' data [DXF group codes + values] in a python script with the help of the VBA macro and the python function provided in this answer.
In python, I get the handle of the XRecord using the Handle
property, however, not all XRecords does return successfully their data, and an Unknown handle error is thrown at the line Set myXRecord = mydoc.HandleToObject(handler)
at the VBA macro.
I've looked for an explanation, one of them is this one, but my case is different in that it takes the XRecord's handle at first then supply it, so, no assumptions are made on how handles are created at the AutoCAD drawing.
So, how can an XRecord return its handle, then HandleToObject
method can't find that XRecord from its Handle
property's value?!
Edit:-
I guess the problem is with HandleToObject
itself, I get python to preview the handle which invokes the error (say "3E7") then I open the drawing and get the XRecord's data from the ordinary entget
preview using (entget (handent "3E7"))
in AutoCAD's command line, and the result is successful.
((-1 . <Entity name: 7ff649f06e70>) (0 . "XRECORD") (5 . "3E7") (102 . "{ACAD_REACTORS") (330 . <Entity name: 7ff649f06e20>) (102 . "}") (330 . <Entity name: 7ff649f06e20>) (100 . "AcDbXrecord") (280 . 1) (1 . "Wall1"))
Can there be any workaround to this issue?!!