I use SomeCallMeDave's vbassoc function and I have Frank's Vlax class. Since I don't know lisp the latter is a bit hard to use. I'm messing with an xref class or functions right now and would like to know if an xref is attached or overlayed. So far it dxf code 70 seems to be what I need for the block but I am not sure how to go about it. Using SCMD's function I get a nil. I presume the answer is a list and and just needs processing correctly. Any ideas?
Here is the vbassoc
'SomeCallMeDave
'http://www.vbdesign.net/expresso/showthread.php?postid=83887#post83887
'Changed pAcadObj As AcadObject to pAcadObj As Object to access imagedef as well
Public Function vbAssoc(pAcadObj, pDXFCode As Integer) As Variant
Dim VLisp As Object
Dim VLispFunc As Object
Dim varRetVal As Variant
Dim obj1 As Object
Dim obj2 As Object
Dim strHnd As String
Dim strVer As String
Dim lngCount As Long
Dim i As Long
Dim j As Long
On Error GoTo vbAssocError
strHnd = pAcadObj.handle
If Left(ThisDrawing.Application.Version, 2) = "16" Then
Set VLisp = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
Else
Set VLisp = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
End If
Set VLispFunc = VLisp.ActiveDocument.Functions
Set obj1 = VLispFunc.item("read").funcall("pDXF")
varRetVal = VLispFunc.item("set").funcall(obj1, pDXFCode)
Set obj1 = VLispFunc.item("read").funcall("pHandle")
varRetVal = VLispFunc.item("set").funcall(obj1, strHnd)
Set obj1 = VLispFunc.item("read").funcall("(vl-princ-to-string (cdr (assoc pDXF (entget (handent pHandle)))))")
varRetVal = VLispFunc.item("eval").funcall(obj1)
vbAssoc = varRetVal
'clean up the newly created LISP symbols
Set obj1 = VLispFunc.item("read").funcall("(setq pDXF nil)")
varRetVal = VLispFunc.item("eval").funcall(obj1)
Set obj1 = VLispFunc.item("read").funcall("(setq pHandle nil)")
varRetVal = VLispFunc.item("eval").funcall(obj1)
'release the objects or Autocad gets squirrely (no offense RR)
Set obj2 = Nothing
Set obj1 = Nothing
Set VLispFunc = Nothing
Set VLisp = Nothing
Exit Function
vbAssocError:
Set obj2 = Nothing
Set obj1 = Nothing
Set VLispFunc = Nothing
Set VLisp = Nothing
MsgBox "Error occurred " & Err.Description
End Function
Debug.Print "lisp", vbAssoc(oBlock, 2), vbAssoc(oBlock, 70)