Использовал вышеуказанные советы, чтобы передать набор из VBA в Lisp.
Получается странная вещь: когда ставлю точку останова на
ThisDrawing.SendCommand "(ssVBA->ssLisp " & CStr(SetNum) & ")" & vbCr
и затем по F8 захожу в Lisp и дальше F5, то созданные объекты подсвечиваются, а если просто выполнять программу без остановов, то набора нет.
Вот код:
Sub Example_AddItems()
If ThisDrawing.SelectionSets.Count > 0 Then
For I = 1 To ThisDrawing.SelectionSets.Count
ThisDrawing.SelectionSets.Item(0).Delete
Next I
End If
Dim dss As AcadSelectionSets
Set dss = ThisDrawing.SelectionSets
Dim ssetObj As AcadSelectionSet ' Create the new selection set
Set ssetObj = ThisDrawing.SelectionSets.Add("selset2")
Dim plineObj As AcadLWPolyline
Dim points(0 To 5) As Double
points(0) = 3: points(1) = 7: points(2) = 9: points(3) = 2
points(4) = 3: points(5) = 5
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
Dim lineObj As AcadLine
Dim startPoint(0 To 2) As Double, endPoint(0 To 2) As Double
startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
endPoint(0) = 2: endPoint(1) = 2: endPoint(2) = 0
Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
Dim circObj As AcadCircle
Dim centerPt(0 To 2) As Double, radius As Double
centerPt(0) = 20: centerPt(1) = 30: centerPt(2) = 0: radius = 3
Set circObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius)
ReDim objs(0 To 2) As AcadEntity
Set objs(0) = plineObj: Set objs(1) = lineObj: Set objs(2) = circObj
ssetObj.AddItems objs
On Error Resume Next
For I = 1 To dss.Count
If (dss.Item(I) Is ssetObj) Then SetNum = I: Exit For
Next I
ThisDrawing.SendCommand "(ssVBA->ssLisp " & CStr(SetNum) & ")" & vbCr
End Sub
(defun ssVBA->ssLisp ( vba-ssInt / ob ss ssVBA)
(setq allSS (vlax-get-property (vlax-get-property (vlax-get-acad-object)
'ActiveDocument)'SelectionSets))
(setq ss(ssadd))
(if(and vba-ssInt
(< vba-ssInt (vlax-get-property allSS 'Count))
(>= vba-ssInt 0)
)
(progn
(setq ssVBA (vlax-invoke-method allSS 'Item vba-ssInt))
(vlax-for ob ssVBA (setq ss(ssadd(vlax-vla-object->ename ob)ss)))
(vlax-release-object allSS)
(command "select" ss "")
(sssetfirst nil ss)
)
)
(sslength ss)
;(princ (sslength ss))
);;ssVBA->ssLisp